You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/01/02 12:16:07 UTC
[GitHub] [incubator-seatunnel] zixi0825 opened a new pull request #927: [Feature][seatunnel-connector] Add tidb spark source
zixi0825 opened a new pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
- Name the pull request in the form "[SeaTunnel #XXXX] [component] Title of the pull request", where *SeaTunnel #XXXX* should be replaced by the actual issue number.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
## Purpose of this pull request
This pull request adds tidb spark source.
## Check list
* [ ] Code changed are covered with tests, or it does not need tests for reason:
* [ ] Change does not need document change, or I will submit document change to https://github.com/apache/incubator-seatunnel-website later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1013615105
@zixi0825 Please resolve the conflicts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on a change in pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on a change in pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#discussion_r777207580
##########
File path: seatunnel-connectors/seatunnel-connector-spark-tidb/src/main/scala/org/apache/seatunnel/spark/source/Tidb.scala
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.spark.source
+
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.spark.SparkEnvironment
+import org.apache.seatunnel.spark.batch.SparkBatchSource
+import org.apache.spark.sql.{Dataset, Row, TiContext}
+
+class Tidb extends SparkBatchSource {
+
+ override def prepare(env: SparkEnvironment): Unit = {}
+
+ override def checkConfig(): CheckResult = {
+ config.hasPath("pre_sql") && config.hasPath("database") match {
+ case true => new CheckResult(true, "")
+ case false => new CheckResult(false, "please specify [pre_sql] and [database]")
+ }
+ }
+
+ override def getData(env: SparkEnvironment): Dataset[Row] = {
+ val database = config.getString("database")
+
+ val ti = new TiContext(env.getSparkSession)
+ ti.tidbMapDatabase(database)
+ env.getSparkSession.sql(config.getString("pre_sql"))
+ }
+}
Review comment:
File must end with a newline character.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on a change in pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on a change in pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#discussion_r777207208
##########
File path: docs/en/configuration/source-plugins/Tidb.md
##########
@@ -0,0 +1,57 @@
+# Source plugin: Tidb
+
+## Description
+
+Read data from Tidb.
+
+## Env Options
+
+| name | type | required | default value |
+| -------------- | ------ | -------- | ------------- |
+| spark.tispark.pd.addresses | string | yes | - |
+| spark.sql.extensions | string | yes | org.apache.spark.sql.TiExtensions |
+
+### spark.tispark.pd.addresses [string]
+
+your pd servers
+
+### spark.sql.extensions [string]
+
+default value : org.apache.spark.sql.TiExtensions
+
+## Options
+
+| name | type | required | default value |
+| -------------- | ------ | -------- | ------------- |
+| database | string | yes | - |
Review comment:
The docs markdown should be like demo below to support redirect.
```
| database(#database-string) | string | yes | - |
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] zixi0825 commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
zixi0825 commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1003855916
@RickyHuo @CalvinKirs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1013598192
The directory of doc seem error with branch of dev.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] zixi0825 commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
zixi0825 commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1013806284
@RickyHuo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] zixi0825 commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
zixi0825 commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1004574123
> @zixi0825 According to https://github.com/pingcap/tispark
>
> > For TiSpark version >= 2.0:
>
> ```
> spark.sql("use tpch_test")
> spark.sql("select count(*) from lineitem").show
> ```
>
> Have you check with current version ?
It's my mistake. I'll recheck and modify it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo merged pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo merged pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] zixi0825 commented on a change in pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
zixi0825 commented on a change in pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#discussion_r777284948
##########
File path: pom.xml
##########
@@ -115,6 +115,7 @@
<docker.tag>${project.version}</docker.tag>
<jcommander.version>1.81</jcommander.version>
<junit.version>4.13.2</junit.version>
+ <tispark.version>2.1.9-spark_2.4</tispark.version>
Review comment:
change version to 2.4.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on a change in pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on a change in pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#discussion_r777206115
##########
File path: pom.xml
##########
@@ -115,6 +115,7 @@
<docker.tag>${project.version}</docker.tag>
<jcommander.version>1.81</jcommander.version>
<junit.version>4.13.2</junit.version>
+ <tispark.version>2.1.9-spark_2.4</tispark.version>
Review comment:
I think Tispark 2.4.x would be better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] RickyHuo commented on pull request #927: [Feature][seatunnel-connector] Add tidb spark source
Posted by GitBox <gi...@apache.org>.
RickyHuo commented on pull request #927:
URL: https://github.com/apache/incubator-seatunnel/pull/927#issuecomment-1004118216
@zixi0825 According to https://github.com/pingcap/tispark
> For TiSpark version >= 2.0:
```
spark.sql("use tpch_test")
spark.sql("select count(*) from lineitem").show
```
Have you check with current version ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org