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

   ### Search before asking
   
   - [X] I had searched in the issues and found no similar issues.
   
   ### What happened
   
   `JdbcDialect.getFieldIde` and `CatalogUtils.getFieldIde` look up the 
`field_ide` value and convert identifiers with the JVM default locale:
   
   ```java
   switch (FieldIdeEnum.valueOf(fieldIde.toUpperCase())) {
       case LOWERCASE:
           return identifier.toLowerCase();
       case UPPERCASE:
           return identifier.toUpperCase();
   ```
   
   Under a Turkish or Azerbaijani default locale, `"original".toUpperCase()` is 
`ORİGİNAL` with a dotted capital I, which is not a `FieldIdeEnum` constant, and 
`i` / `I` in identifiers map to `İ` / `ı`.
   
   This is not limited to jobs that set `field_ide`. When the option is not 
set, `JdbcSink` uses `"original"` (`getDatabaseTableSchema` and 
`getSaveModeHandler`), and `createWriter` calls `getDatabaseTableSchema()` for 
every sink, which resolves the table name through 
`CatalogUtils.quoteTableIdentifier(tableName, "original")`.
   
   Measured with a real `JdbcSink` (MySQL dialect, `query` only, `field_ide` 
not set) calling `createWriter`:
   
   | default locale | `createWriter` |
   | --- | --- |
   | `ROOT` | returns a `JdbcSinkWriter` |
   | `tr-TR` | `IllegalArgumentException: No enum constant 
...FieldIdeEnum.ORİGİNAL` |
   | `az-AZ` | `IllegalArgumentException: No enum constant 
...FieldIdeEnum.ORİGİNAL` |
   
   So on a worker whose default locale is Turkish or Azerbaijani, every JDBC 
sink fails when its writer is created. The `createWriter` path has been there 
since #8031.
   
   With `field_ide` set, measured through `MysqlDialect.quoteIdentifier` and 
`CatalogUtils.getFieldIde` under `tr-TR`:
   
   | `field_ide` | identifier | expected | actual |
   | --- | --- | --- | --- |
   | `original` | `id` | `` `id` `` | `IllegalArgumentException` |
   | `lowercase` | `USER_ID` | `` `user_id` `` | `` `user_ıd` `` |
   | `uppercase` | `user_id` | `` `USER_ID` `` | `` `USER_İD` `` |
   
   `getFieldIde` quotes every identifier in the statements the sink generates 
for MySQL, SQL Server, Oracle, OceanBase, IRIS and YashanDB, and the CREATE 
TABLE builders read the same value through `CatalogUtils`.
   
   ### What you expected to happen
   
   The JDBC sink and `field_ide` behave the same under any JVM default locale.
   
   ### SeaTunnel Version
   
   dev, verified at commit `f7a575432`.
   
   ### SeaTunnel Config
   
   ```conf
   sink {
     Jdbc {
       url = "jdbc:mysql://localhost:3306/test"
       driver = "com.mysql.cj.jdbc.Driver"
       user = "root"
       password = "******"
       query = "insert into orders(id) values(?)"
     }
   }
   ```
   
   ### Running Command
   
   ```shell
   Any command, on a worker JVM whose default locale is Turkish or Azerbaijani, 
for example started with -Duser.language=tr -Duser.country=TR.
   ```
   
   ### Error Exception
   
   ```log
   java.lang.IllegalArgumentException: No enum constant 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum.ORİGİNAL
        at java.base/java.lang.Enum.valueOf(Enum.java:273)
   ```
   
   ### Zeta or Flink or Spark Version
   
   Not engine specific. The failure is in the sink.
   
   ### Java or Scala Version
   
   Not version specific. Measured on JDK 17.
   
   ### 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
   


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

Reply via email to