Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][Connector-V2][Docs] Unified format for connector-v2 docs #4544

Open
2 tasks done
zhilinli123 opened this issue Apr 11, 2023 · 10 comments
Open
2 tasks done

[Feature][Connector-V2][Docs] Unified format for connector-v2 docs #4544

zhilinli123 opened this issue Apr 11, 2023 · 10 comments

Comments

@zhilinli123
Copy link
Contributor

zhilinli123 commented Apr 11, 2023

MySQL

JDBC Mysql Sink Connector

Support Connector Version

  • 5.5/5.6/5.7/8.0

Support Those Engines

Spark

Flink

Seatunnel Zeta

Key Features

Use Xa transactions to ensure exactly-once. So only support exactly-once for the database which is
support Xa transactions. You can set is_exactly_once=true to enable it.

Description

Write data through jdbc. Support Batch mode and Streaming mode, support concurrent writing, support exactly-once
semantics (using XA transaction guarantee).

Supported DataSource Info

Datasource Supported Versions Driver Url Maven
Mysql Different dependency version has different driver class. com.mysql.cj.jdbc.Driver jdbc:mysql://localhost:3306:3306/test Download

Database Dependency

Please download the support list corresponding to 'Maven' and copy it to the '$SEATNUNNEL_HOME/plugins/jdbc/lib/' working directory

For example Mysql datasource: cp mysql-connector-java-xxx.jar $SEATNUNNEL_HOME/plugins/jdbc/lib/

Data Type Mapping

Mysql Data type Seatunnel Data type
BIT(1)
INT UNSIGNED
BOOLEAN
TINYINT
TINYINT UNSIGNED
SMALLINT
SMALLINT UNSIGNED
MEDIUMINT
MEDIUMINT UNSIGNED
INT
INTEGER
YEAR
INT
INT UNSIGNED
INTEGER UNSIGNED
BIGINT
BIGINT
BIGINT UNSIGNED DECIMAL(20,0)
DECIMAL(x,y)(Get the designated column's specified column size.<38) DECIMAL(x,y)
DECIMAL(x,y)(Get the designated column's specified column size.>38) DECIMAL(38,18)
DECIMAL UNSIGNED DECIMAL((Get the designated column's specified column size)+1,
(Gets the designated column's number of digits to right of the decimal point.)))
FLOAT
FLOAT UNSIGNED
FLOAT
DOUBLE
DOUBLE UNSIGNED
DOUBLE
CHAR
VARCHAR
TINYTEXT
MEDIUMTEXT
TEXT
LONGTEXT
JSON
STRING
DATE DATE
TIME TIME
DATETIME
TIMESTAMP
TIMESTAMP
TINYBLOB
MEDIUMBLOB
BLOB
LONGBLOB
BINARY
VARBINAR
BIT(n)
BYTES
GEOMETRY
UNKNOWN
Not supported yet

Sink Options

Name Type Required Default Description
url String Yes - The URL of the JDBC connection. Refer to a case: jdbc:mysql://localhost:3306:3306/test
driver String Yes - The jdbc class name used to connect to the remote data source,
if you use MySQL the value is com.mysql.cj.jdbc.Driver.
user String No - Connection instance user name
password String No - Connection instance password
query String No - Use this sql write upstream input datas to database. e.g INSERT ...,query have the higher priority
database String No - Use this database and table-name auto-generate sql and receive upstream input datas write to database.
This option is mutually exclusive with query and has a higher priority.
table String No - Use database and this table-name auto-generate sql and receive upstream input datas write to database.
This option is mutually exclusive with query and has a higher priority.
primary_keys Array No - This option is used to support operations such as insert, delete, and update when automatically generate sql.
support_upsert_by_query_primary_key_exist Boolean No false Choose to use INSERT sql, UPDATE sql to process update events(INSERT, UPDATE_AFTER) based on query primary key exists. This configuration is only used when database unsupport upsert syntax. Note: that this method has low performance
connection_check_timeout_sec Int No 30 The time in seconds to wait for the database operation used to validate the connection to complete.
max_retries Int No 0 The number of retries to submit failed (executeBatch)
batch_size Int No 1000 For batch writing, when the number of buffered records reaches the number of batch_size or the time reaches batch_interval_ms
, the data will be flushed into the database
batch_interval_ms Int No 1000 For batch writing, when the number of buffers reaches the number of batch_size or the time reaches batch_interval_ms, the data will be flushed into the database
is_exactly_once Boolean No false Whether to enable exactly-once semantics, which will use Xa transactions. If on, you need to
set xa_data_source_class_name.
xa_data_source_class_name String No - The xa data source class name of the database Driver, for example, mysql is com.mysql.cj.jdbc.MysqlXADataSource, and
please refer to appendix for other data sources
max_commit_attempts Int No 3 The number of retries for transaction commit failures
transaction_timeout_sec Int No -1 The timeout after the transaction is opened, the default is -1 (never timeout). Note that setting the timeout may affect
exactly-once semantics
auto_commit Boolean No true Automatic transaction commit is enabled by default
common-options no - Sink plugin common parameters, please refer to Sink Common Options for details

Tips

If partition_column is not set, it will run in single concurrency, and if partition_column is set, it will be executed in parallel according to the concurrency of tasks.

Task Example

Simple:

This example defines a SeaTunnel synchronization task that automatically generates data through FakeSource and sends it to JDBC Sink. FakeSource generates a total of 16 rows of data (row.num=16), with each row having two fields, name (string type) and age (int type). The final target table is test_table will also be 16 rows of data in the table. Before run this job, you need create database test and table test_table in your mysql. And if you have not yet installed and deployed SeaTunnel, you need to follow the instructions in Install SeaTunnel to install and deploy SeaTunnel. And then follow the instructions in Quick Start With SeaTunnel Engine to run this job.

# Defining the runtime environment
env {
  # You can set flink configuration here
  execution.parallelism = 1
  job.mode = "BATCH"
}

source {
  # This is a example source plugin **only for test and demonstrate the feature source plugin**
  FakeSource {
    parallelism = 1
    result_table_name = "fake"
    row.num = 16
    schema = {
      fields {
        name = "string"
        age = "int"
      }
    }
  }
  # If you would like to get more information about how to configure seatunnel and see full list of source plugins,
  # please go to https://seatunnel.apache.org/docs/category/source-v2
}

transform {
  # If you would like to get more information about how to configure seatunnel and see full list of transform plugins,
    # please go to https://seatunnel.apache.org/docs/category/transform-v2
}

sink {
    jdbc {
        url = "jdbc:mysql://localhost:3306/test"
        driver = "com.mysql.cj.jdbc.Driver"
        user = "root"
        password = "123456"
        query = "insert into test_table(name,age) values(?,?)"
        }
  # If you would like to get more information about how to configure seatunnel and see full list of sink plugins,
  # please go to https://seatunnel.apache.org/docs/category/sink-v2
}

Exactly-once :

For accurate write scene we guarantee accurate once

sink {
    jdbc {
        url = "jdbc:mysql://localhost:3306/test"
        driver = "com.mysql.cj.jdbc.Driver"
    
        max_retries = 0
        user = "root"
        password = "123456"
        query = "insert into test_table(name,age) values(?,?)"
    
        is_exactly_once = "true"
    
        xa_data_source_class_name = "com.mysql.cj.jdbc.MysqlXADataSource"
    }
}

CDC(Change Data Capture) Event

CDC change data is also supported by us In this case, you need config database, table and primary_keys.

sink {
    jdbc {
        url = "jdbc:mysql://localhost:3306/test"
        driver = "com.mysql.cj.jdbc.Driver"
        user = "root"
        password = "123456"
        
        generate_sink_sql = true
        # You need to configure both database and table
        database = test
        table = sink_table
        primary_keys = ["id","name"]
    }
}
@zhilinli123 zhilinli123 changed the title [Improve][connector][Doc] Unified case for the connector document on the official website of the new version [Improve][connector][doc] Unified case for the connector document on the official website of the new version Apr 11, 2023
@zhilinli123
Copy link
Contributor Author

@TyrantLucifer review

@zhilinli123
Copy link
Contributor Author

zhilinli123 commented Apr 13, 2023

After discussion with Seatunnel community Pmc Commiter and good developers, the results are as follows:

  1. Data source title (required)

  2. Support Connector Version (required)

  3. Data source description (required)

  4. Introduction to Data Source Support Engine (required)

  5. Which data source list is supported, such as jdbc: Oracle MySQL Sql Server (required)

  6. Do you need to add additional dependency packages, such as mysql connector javaxxx. jar (choose to add)

  7. Data source and Seatunnel data type mapping with supported version boundaries (required)

  8. Data Source Options Introduction and Details (must be filled in)

  9. To better support the user experience, developers provide some technical suggestions to users, such as: parallel read memory allocation, which is unclear for these users (choose to add)

10.Task Example The final example module plus the complete structure and a few more examples from easy to hard order (must be filled in) different strategies for reading and writing examples we all have to perform such as: cut read & single parallel read

  1. Feature Progress (Select Add)

中文版本:

经过与Seatunnel社区Pmc提交者和优秀开发人员的讨论,结果如下:
1.数据源标题(必须填写)

2.连接器支持版本(必须填写)

3.数据源描述(必须填写)

4.数据源支持引擎介绍(必须填写)

5.支持数据源列表 例如jdbc:支持 Oracle Mysql Sql-Server(必须填写)

6.是否需要额外添加其他依赖包 例如:mysql-connector-javaxxx.jar (选择添加)

7.数据源与Seatunnel数据类型影射 加上支持版本边界(必须填写)

8.数据源 Options介绍且详细(必须填写)

9.为更好支持用户使用体验 我们开发者给予用户一些技术建议 例如:并行读取 内存比例分配 这些用户都是不清晰的(选择添加)

10.Task Example 最后的example模块加上完整的结构和多几个示例 从易到难顺序 (必须填写) 不同策略读取写入例子我们都要表现 例如:切割读取&单并行读取

11.Feature 进展(选择添加)

We have added the connector version title this time CC @MonsterChenzhuo @TaoZex @EricJoy2048 @ic4y @TyrantLucifer @Carl-Zhou-CN @zhangchengming601 @lightzhao

@TyrantLucifer
Copy link
Member

Could you please offer an example document according to the result of discussion? @zhilinli123

@apache apache deleted a comment from zhilinli123 Apr 14, 2023
@TyrantLucifer TyrantLucifer changed the title [Improve][connector][doc] Unified case for the connector document on the official website of the new version [Feature][Connector-V2][Docs] Unified format for connector-v2 docs Apr 14, 2023
@apache apache deleted a comment from zhilinli123 Apr 14, 2023
@apache apache deleted a comment from zhilinli123 Apr 14, 2023
@kim-up
Copy link
Contributor

kim-up commented Apr 14, 2023

@zhilinli123 Data source version is also necessary. For example: #4574

@zhilinli123
Copy link
Contributor Author

@zhilinli123 Data source version is also necessary. For example: #4574

It's within the bounds of support

@MonsterChenzhuo
Copy link
Contributor

Restrictions on parameter names:
1.In English, the hyphen (-) is commonly used to connect two or more closely related words to form a compound word. In programming and configuration files, the hyphen is also frequently used to represent multiple components of variable names, parameter names, property names, etc. This is a naming convention aimed at improving code readability and maintainability.
2.Multiple words are separated by a period (.)
for example:
max-retries、retry.interval、is.exactly-once

@EricJoy2048
Copy link
Member

Restrictions on parameter names: 1.In English, the hyphen (-) is commonly used to connect two or more closely related words to form a compound word. In programming and configuration files, the hyphen is also frequently used to represent multiple components of variable names, parameter names, property names, etc. This is a naming convention aimed at improving code readability and maintainability. 2.Multiple words are separated by a period (.) for example: max-retries、retry.interval、is.exactly-once

I suggest not modifying existing parameters, and adding new parameters can require this format.

@TyrantLucifer
Copy link
Member

Restrictions on parameter names: 1.In English, the hyphen (-) is commonly used to connect two or more closely related words to form a compound word. In programming and configuration files, the hyphen is also frequently used to represent multiple components of variable names, parameter names, property names, etc. This is a naming convention aimed at improving code readability and maintainability. 2.Multiple words are separated by a period (.) for example: max-retries、retry.interval、is.exactly-once

I suggest not modifying existing parameters, and adding new parameters can require this format.

+1

@zhilinli123
Copy link
Contributor Author

zhilinli123 commented May 15, 2023

@ic4y
Copy link
Contributor

ic4y commented Aug 8, 2023

Add support version information to the document template @zhilinli123

like
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants