You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "ic4y (via GitHub)" <gi...@apache.org> on 2023/05/11 11:16:45 UTC

[GitHub] [incubator-seatunnel] ic4y commented on a diff in pull request #4634: [Improve][Connector-V2][Jdbc-Source]Support Compatible Mysql bigint(20) used as a partition_column

ic4y commented on code in PR #4634:
URL: https://github.com/apache/incubator-seatunnel/pull/4634#discussion_r1190966392


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/JdbcSourceFactory.java:
##########
@@ -200,7 +202,10 @@ static void validationPartitionColumn(String partitionColumn, SeaTunnelRowType r
     }
 
     private static boolean isNumericType(SeaTunnelDataType<?> type) {
-        return type.equals(BasicType.INT_TYPE) || type.equals(BasicType.LONG_TYPE);
+        // Currently, only numeric types are supported for reading partition keys
+        return type.equals(BasicType.INT_TYPE)
+                || type.equals(BasicType.LONG_TYPE)
+                || type.equals(new DecimalType(20, 0));

Review Comment:
   The current implementation support any DecimalType with scale=0.



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-1/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcMysqlIT.java:
##########
@@ -64,6 +64,7 @@ public class JdbcMysqlIT extends AbstractJdbcIT {
     private static final String CREATE_SQL =
             "CREATE TABLE IF NOT EXISTS %s\n"
                     + "(\n"
+                    + "    `c_bigint_30`          BIGINT(40) unsigned   DEFAULT NULL,\n"

Review Comment:
   It is recommended to directly use DECIMAL(30,0) for partition field testing.



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-1/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcMysqlIT.java:
##########
@@ -194,11 +196,14 @@ Pair<String[], List<SeaTunnelRow>> initTestData() {
                 };
 
         List<SeaTunnelRow> rows = new ArrayList<>();
+        // Define a large bigint data value to test for compatibility above bigint(20)
+        BigDecimal testBigDecimalValue = new BigDecimal("2844674407371055000");
         for (int i = 0; i < 100; i++) {
             byte byteArr = Integer.valueOf(i).byteValue();
             SeaTunnelRow row =
                     new SeaTunnelRow(
                             new Object[] {
+                                testBigDecimalValue.add(BigDecimal.valueOf(i)),

Review Comment:
   Do not delete the column c_bit_1.



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-1/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcMysqlIT.java:
##########
@@ -194,11 +196,14 @@ Pair<String[], List<SeaTunnelRow>> initTestData() {
                 };
 
         List<SeaTunnelRow> rows = new ArrayList<>();
+        // Define a large bigint data value to test for compatibility above bigint(20)
+        BigDecimal testBigDecimalValue = new BigDecimal("2844674407371055000");

Review Comment:
   The number 2844674407371055000 is within the storage range of a long. You should use a value that is outside of long's storage capacity, such as 899,999,999,999,999,999,999,999,999,999.



-- 
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