SEPURI-SAI-KRISHNA opened a new issue, #13073:
URL: https://github.com/apache/seatunnel/issues/13073

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   ### What happened
   
   `MySqlCatalog.buildColumn` reads `DATA_TYPE` from 
`INFORMATION_SCHEMA.COLUMNS` and upper cases it with the JVM default locale 
(`MySqlCatalog.java:224`):
   
   ```java
   String dataType = resultSet.getString("DATA_TYPE").toUpperCase();
   ```
   
   MySQL reports `DATA_TYPE` in lower case. In the MySQL 8.0 server source, the 
view defines it as `SUBSTRING_INDEX(SUBSTRING_INDEX(col.column_type_utf8, '(', 
1), ' ', 1)` (`sql/dd/impl/system_views/columns.cc`), and the column type text 
is written with lower case literals such as `"int"`, `"bigint"`, 
`"decimal(%d,%d)"` and `"datetime"` (`sql/field.cc`).
   
   Under `tr-TR` and `az-AZ`, `"i".toUpperCase()` is `"İ"` (U+0130). So `int` 
becomes `İNT`, `MySqlTypeConverter` finds no matching type, and the column 
fails to convert. Every type name with an `i` is affected: `int`, `bigint`, 
`tinyint`, `smallint`, `mediumint`, `decimal`, `datetime`, `time`, `timestamp`, 
`binary`, `varbinary`, and any `unsigned` variant.
   
   A JDBC source with `table_path` reads its schema through 
`catalog.getTable(tablePath)`, which calls `buildColumn` for every column. On a 
worker whose default locale is Turkish or Azerbaijani, reading almost any MySQL 
table this way fails. `TiDBCatalog` extends `MySqlCatalog`, and 
`OceanBaseMySqlCatalog.buildColumn` has the same line (`:145`).
   
   The type converters have the same call (`MySqlTypeConverter:199`, 
`OceanBaseMySqlTypeConverter:124`). Their own tests pass lowercase names, so in 
a JVM started with `-Duser.language=tr -Duser.country=TR`, 15 of the 48 tests 
in `MySqlTypeConverterTest` fail on `dev`. `MySqlCatalogUnsignedDetectionTest` 
passes there only because it mocks `DATA_TYPE` as `"INT"`, which a real server 
does not return.
   
   The query path (`query = ...`) is not affected: MySQL Connector/J reports 
`getColumnTypeName` in upper case.
   
   ### SeaTunnel Version
   
   dev (f3e1c2ee3b)
   
   ### SeaTunnel Config
   
   ```conf
   source {
     Jdbc {
       url = "jdbc:mysql://localhost:3306/test"
       driver = "com.mysql.cj.jdbc.Driver"
       user = "root"
       password = "..."
       table_path = "test.orders"
     }
   }
   ```
   
   with, for example, `CREATE TABLE orders (id INT PRIMARY KEY, created 
DATETIME)`.
   
   ### Running Command
   
   ```shell
   Any job reading a MySQL table through table_path, on a worker started with 
-Duser.language=tr -Duser.country=TR
   ```
   
   ### Error Exception
   
   Measured by passing `DATA_TYPE = "int"` to `MySqlCatalog.buildColumn` under 
`tr-TR`:
   
   ```log
   ErrorCode:[COMMON-17], ErrorDescription:['MySQL' unsupported convert type 
'İNT' of 'test' to SeaTunnel data type.]
   ```
   
   ### Zeta or Flink or Spark Version
   
   All engines. The catalog is in `connector-jdbc`.
   
   ### Java or Scala Version
   
   Reproduced on JDK 17.
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [I] [Bug][Connector-V2][JDBC] ... SEPURI-SAI-KRISHNA (via GitHub) via commits

Reply via email to