close
Skip to content

[Feature][Connector-V2] Jdbc mysql support read tinyint(1) to byte(tinyint)#9373

Merged
hailin0 merged 3 commits into
apache:devfrom
Hisoka-X:mysql-bit
Jun 6, 2025
Merged

[Feature][Connector-V2] Jdbc mysql support read tinyint(1) to byte(tinyint)#9373
hailin0 merged 3 commits into
apache:devfrom
Hisoka-X:mysql-bit

Conversation

@Hisoka-X

Copy link
Copy Markdown
Member

Purpose of this pull request

Before this pr, when SeaTunnel read tinyint(1) from MySQL. It will be convert to boolean type.
This pr introduce new option named int_type_narrowing. By set int_type_narrowing to false, let SeaTunnel read tinyint(1) as SeaTunnel Byte type (same as tinyint).

Does this PR introduce any user-facing change?

no

How was this patch tested?

add new test.

Check list

@nielifeng nielifeng requested a review from Copilot May 29, 2025 02:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an int_type_narrowing option to let SeaTunnel read MySQL TINYINT(1) as a byte instead of a boolean when set to false.

  • Introduce and wire int_type_narrowing through JdbcOptions, JdbcConnectionConfig, source factory, catalog utils, converters, mappers, and catalog implementations
  • Update integration tests, SQL/CONN fixture files, and unit tests to cover both boolean and byte mapping
  • Enhance documentation (EN/ZH) to describe the new option

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
connector-jdbc/src/main/java/.../JdbcOptions.java Add INT_TYPE_NARROWING option key and description
connector-jdbc/src/main/java/.../JdbcConnectionConfig.java New intTypeNarrowing field, builder, and config mapping
connector-jdbc/src/main/java/.../MySqlTypeConverter.java Adjust constructor overloads and branch on intTypeNarrowing
connector-jdbc/src/main/java/.../MySqlCatalog.java & AbstractJdbcCatalog.java Pass tinyInt1isBit=false when narrowing disabled
connector-jdbc/src/main/java/.../JdbcSourceFactory.java Include INT_TYPE_NARROWING in optionRule()
connector-jdbc/.../MySqlTypeMapperTest.java & JdbcMysqlMultipleTablesIT.java Add unit and integration tests for both mapping modes
seatunnel-e2e/.../*.conf & .sql Update queries and table definitions to use new c_tinyint_1 column
docs/zh/connector-v2/source/Mysql.md & docs/en/.../Mysql.md, Jdbc.md Document int_type_narrowing and its effects
Comments suppressed due to low confidence (1)

docs/en/connector-v2/source/Mysql.md:94

  • [nitpick] You have duplicated int_type_narrowing docs here and in Jdbc.md; consider moving shared option descriptions into a common section to reduce duplication and maintain consistency.
| int_type_narrowing                         | Boolean    | No       | true            | Int type narrowing, if true, the tinyint(1) type will be narrowed to the boolean type if without loss of precision. Support for MySQL at now. |

.withDescription(
"decimal type narrowing, if true, the decimal type will be narrowed to the int or long type if without loss of precision. Only support for Oracle at now.");

Option<Boolean> INT_TYPE_NARROWING =

Copilot AI May 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider rephrasing the description to "Currently supported for MySQL only." to improve clarity and correct grammar.

Copilot uses AI. Check for mistakes.
private final MySqlVersion version;
private final boolean intTypeNarrowing;

public MySqlTypeConverter() {

Copilot AI May 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The constructors for MySqlTypeConverter (no-arg, single-arg, two-arg) are interleaved; grouping and ordering them together can improve readability.

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot removed the jdbc label May 29, 2025
@Hisoka-X Hisoka-X linked an issue May 29, 2025 that may be closed by this pull request
3 tasks
@hailin0 hailin0 merged commit 7b87aa6 into apache:dev Jun 6, 2025
2 checks passed
dybyte pushed a commit to dybyte/seatunnel that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][Connector-MySql-CDC]] Field type mapping

4 participants