sharpca opened a new pull request, #13083:
URL: https://github.com/apache/seatunnel/pull/13083

   ### Purpose of this pull request
   
   Fixes #13079.
   
   The JDBC dialect type converters convert the source type name with 
`String#toUpperCase()` / `String#toLowerCase()` without a locale before 
matching it against the dialect type constants. Under a Turkish or Azerbaijani 
default locale a lower-case `integer` upper-cases to `INTEGER` with a dotted 
capital I, and an upper-case `INT4` lower-cases to `int4` with a dotless i, so 
the type name no longer matches any constant and the converter falls through to 
its unsupported-type branch.
   
   This PR passes `Locale.ROOT` to every remaining case conversion in 
`connector-jdbc`:
   
   The ten converters listed in the issue:
   
   - `DB2TypeConverter`, `DmdbTypeConverter`, `IrisTypeConverter`, 
`KingbaseTypeConverter`, `OracleTypeConverter`
   - `PostgresTypeConverter`, `RedshiftTypeConverter`, `SapHanaTypeConverter`, 
`XuguTypeConverter`, `YashanDbTypeConverter`
   
   Other conversions found while scanning the rest of the connector, which have 
the same defect:
   
   - Type mappers and converters: `Gbase8aTypeMapper`, `HiveTypeMapper`, 
`PhoenixTypeConverter`, `PrestoTypeMapper`, `SnowflakeTypeConverter`, 
`SqliteTypeMapper`, `TablestoreTypeMapper`, `TeradataTypeMapper`, 
`VerticaTypeMapper`, and the column type lookup in `PostgresDialect`.
   - Catalog code: `DamengDataTypeConvertor`, `DuckDBCatalog`, `MySqlCatalog`, 
`OceanBaseMySqlCatalog`, `OceanBaseOracleCreateTableSqlBuilder`, 
`RedshiftCatalog`, `RedshiftDataTypeConvertor`, `SqlServerURLParser`, 
`XuguCatalog`, `YashanDbCatalog`.
   
   Not touched, because they are already covered by #13063, #13076 and #13077: 
`JdbcDialect`, `CatalogUtils`, `MySqlTypeConverter`, 
`OceanBaseMySqlTypeConverter`, `SqlServerTypeConverter`. The 
`query.toLowerCase().contains("where")` checks in the dialects are also left 
alone: `where` contains no `i`, so the default locale cannot change the result.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No behaviour change on the default locale. On a Turkish or Azerbaijani JVM 
the converters now map the same source type to the same SeaTunnel type as on 
any other locale, instead of failing with an unsupported-type error.
   
   ### How was this patch tested?
   
   Added `JdbcTypeConverterLocaleTest`, which sets the default locale to 
`tr-TR` and converts a lower-case `integer` / `int` (and an upper-case `INT4` 
for PostgreSQL) through the ten converters from the issue, asserting the 
resulting SeaTunnel type.
   
   ```shell
   mvn -pl seatunnel-connectors-v2/connector-jdbc \
     
-Dtest='JdbcTypeConverterLocaleTest,Db2TypeConverterTest,DmdbTypeConverterTest,\
   IrisTypeConverterTest,KingbaseTypeConverterTest,OracleTypeConverterTest,\
   
PostgresTypeConverterTest,RedshiftTypeConverterTest,SapHanaTypeConverterTest,\
   XuguTypeConverterTest,YashanDbTypeConverterTest' test
   ```
   
   Result: 321 tests, 0 failures. The new test also fails against the unpatched 
`DB2TypeConverter` under `tr-TR` (`Unsupported type integer`), so it guards the 
regression.
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   * [ ] If you are contributing the connector code, please check that the 
following files are updated:
     1. Update 
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
 and add new connector information in it
     2. Update the pom file of 
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in 
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in 
[seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector 
[plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


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