Skip to content

[Fix][API] Parse the schema option independently of the default locale - #13074

Open
SEPURI-SAI-KRISHNA wants to merge 1 commit into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-schema-type-locale
Open

SEPURI-SAI-KRISHNA wants to merge 1 commit into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-schema-type-locale

Conversation

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator

Yes, glad to contribute to Apache SeaTunnel.

Purpose of this pull request

Fixes #13071.

The schema option was parsed with case conversions that use the JVM default locale. Under tr-TR and az-AZ, i upper cases to İ (U+0130), so lowercase values containing an i matched nothing:

  • Field types. string, int, bigint, timestamp, decimal(10, 2) and the arrays and maps built from them failed with COMMON-07 unsupported data type.
  • Vector index keys. indexType and metricType values such as ivf_flat, inverted, ip and cosine were rejected, although the schema documentation says both are case insensitive.

ReadonlyConfigParser handles the schema option of every connector that has one, so such jobs failed at startup on those workers.

All toUpperCase() calls on this path now use Locale.ROOT:

  • SeaTunnelDataTypeConvertorUtil:
    • :50 the SqlType.valueOf lookup;
    • :130 the MAP, ARRAY and DECIMAL prefix checks;
    • :196 the decimal map key check;
    • :117 the long, short and byte aliases. These contain no i, so this one never failed. It is changed so that no default locale conversion is left in the class.
  • VectorIndex: IndexType.of and MetricType.of.

Does this PR introduce any user facing change?

Yes, only on workers whose default locale is Turkish or Azerbaijani: values that failed there now parse. I compared dev's classes with these on 125 type declarations and 81 vector index values, each in lowercase, upper case and capitalised form:

  • tr-TR and az-AZ: 38 declarations and 25 index values that failed now parse. No value that parsed before gives a different result, and every result now equals the ROOT one.
  • ROOT: identical results before and after.

So no working job changes, and no entry in incompatible-changes.md is needed. No option, default or API signature changed.

How was this patch tested?

Two tests, each in the existing test class:

  • SeaTunnelDataTypeConvertorUtilTest.testParseDoesNotDependOnTheDefaultLocale parses string, int, timestamp, decimal(10, 2), array<int> and map<decimal(10, 2), string>.
  • ReadonlyConfigParserTest.parseVectorIndexKeyDoesNotDependOnTheDefaultLocale parses a vector index key with ivf_flat and cosine. The existing case insensitivity test uses hnsw and l2, which contain no i.

Both run under tr-TR and az-AZ, and restore the base locale and the FORMAT and DISPLAY defaults afterwards. Both fail with dev's classes. Reverting the calls one at a time, :50, :130 and :196 each fail the first test.

I also ran the whole seatunnel-api suite in a JVM started with -Duser.language=tr -Duser.country=TR. On dev, 13 existing schema parsing tests fail, for example CatalogTableUtilTest.testSimpleSchemaParse. With this change, 11 of them pass. The other 2, ReadonlyConfigParserTest.parseColumn and parseField, now parse correctly but fail on the test's own toLowerCase() of the expected type name. The default CI locale is unaffected, so I left those assertions alone. The run also shows 3 failures in GravitinoTableSchemaConvertorTest. That is the metalake type conversion, a separate code path not touched here.

There is no E2E change. The failure depends on the default locale of the engine JVM, and the E2E suites run the engine in containers with their own default locale.

Checks, JDK 17:

  • ./mvnw clean test -pl seatunnel-api: 412 tests, 0 failures.
  • ./mvnw spotless:check -pl seatunnel-api: clean.
  • ./mvnw -B -T 1 clean test -D"license.skipAddThirdParty"=true -pl seatunnel-ci-tools: 34 tests, 0 failures, 2 skipped by the module.

Open PRs #10221 and #11493 also edit SeaTunnelDataTypeConvertorUtil and its test. A three-way merge with either one is conflict free.

Check list

  • Code changed are covered with tests, or it does not need tests for reason
  • If any new Jar binary package adding in your PR, please add License Notice according to
    License Notice: none added.
  • If necessary, please update the documentation to describe the new feature: not needed. The documented type names and index values now parse in every locale, as the documentation already says.
  • If you are contributing the connector code, please check that the following files are updated: not applicable, no connector change.
  • Update the release-note: not applicable, the file was removed from dev in [Improve] Remove release-note.md in dev branch #9304.

@github-actions github-actions Bot added the api label Oct 31, 2026

@DanielLeens DanielLeens 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.

Thanks for the contribution! I reviewed the complete four-file diff and the schema/config callers at 922dad23444c71db2c6841871e788851bcce02fd. No blocking source issue was found.

What Problem Does This PR Solve?

User pain point: lowercase schema tokens such as string, int, timestamp, ivf_flat and cosine can fail under Turkish/Azerbaijani JVM defaults because locale uppercasing produces dotted I rather than the enum's ASCII spelling.

Fix approach: use Locale.ROOT for type-token dispatch, legacy aliases, complex-type detection, decimal map-key splitting and vector index/metric enums.

One-sentence summary and example: schema.fields { id = int } and an IVF_FLAT/COSINE vector constraint now parse identically across default locales, instead of rejecting valid configuration before a job starts.

1. Code Change Review

1.1 Core Logic Analysis

The production changes are seatunnel-api/.../table/catalog/SeaTunnelDataTypeConvertorUtil.java:50,117,130,196 and VectorIndex.java:93,109 (source root src/main/java/org/apache/seatunnel/api/).

Before/after:

// before
SqlType.valueOf(compatible.toUpperCase().replace(" ", ""));
return valueOf(name.toUpperCase());
// after
SqlType.valueOf(compatible.toUpperCase(Locale.ROOT).replace(" ", ""));
return valueOf(name.toUpperCase(Locale.ROOT));

Complete affected chain:

connector job schema/config preparation
  -> ReadonlyConfigParser.parse
     -> FieldParser (:85-101) or ColumnParser (:121-149)
        -> deserializeSeaTunnelDataType(field, original declaration)
           -> compatibleTypeDeclare -> simple SqlType dispatch
           -> on complex syntax: original declaration passed to MAP/ARRAY/DECIMAL/ROW parser
              -> recursive key/value/element/ROW field parsing
        -> PhysicalColumn -> TableSchema -> CatalogTable -> source/transform/sink schema
     -> ConstraintKeyParser.parseConstraintKeyColumn (:235-248)
        -> new VectorIndex -> parseIndexType/parseMetricType
           -> IndexType.of / MetricType.of -> enum

Key findings:

  • Normal configuration preparation reaches both paths, before task deployment.
  • ROOT only normalizes machine tokens. Original nested ROW declarations/field names are passed to the existing parsers, so identifiers are not uppercased into the produced schema.
  • Recursive MAP/ARRAY handling retains its existing boundaries and decimal comma handling.
  • This is a precise normalization fix. It does not claim to fix unrelated pre-existing grammar or array-class limitations.

1.2 Compatibility Impact

Fully compatible with the intended case-insensitive schema grammar. Public signatures, options/defaults, enum values, serialVersionUID/state layouts and network protocols remain unchanged. Existing LONG/SHORT/BYTE aliases stay supported. Previously locale-rejected valid tokens are accepted; no migration is needed.

1.3 Performance / Side-Effect Analysis

The same strings are normalized at preparation time; no extra row-time CPU/allocation, GC pressure, network, lock, thread, queue or mutable production state is introduced. Retry, checkpoint, idempotence and resource release are unaffected. ROOT avoids relying on global JVM mutation in production.

1.4 Error Handling and Logging

Simple-token IllegalArgumentException still falls through to complex parsing; unsupported syntax retains the existing contextual error. Vector parse errors still name the column/valid values, and ReadonlyConfigParser wraps them with the constraint location. No new swallow branch, success misreport or credential logging is introduced.

No blocking source issues found. There are no formal numbered findings on this head.

2. Code Quality Assessment

2.1 Coding Standards

Minimal imports/normalization changes match the surrounding code. No new production method or nontrivial field is added, so no new missing method/field contract was identified. The test comments explain dotted-I and category restoration.

2.2 Test Coverage and Test Stability

Stability: Stable. SeaTunnelDataTypeConvertorUtilTest.java:237-283 asserts actual STRING/INT/TIMESTAMP/DECIMAL/ARRAY/MAP types with fixed values. ReadonlyConfigParserTest.java:206-242 traverses the real config-to-VectorIndex boundary and asserts both enums. Both tests restore base/FORMAT/DISPLAY defaults in finally. No hard waits, service/port dependency, random values, resource leak or collection-order assertion is added. This rating assumes the current sequential JUnit configuration; parallel locale-mutating tests need shared coordination.

Focused residual gaps: these additions do not separately pin nested ROW field-name preservation or every legacy alias under the changed locale; the original-declaration call chain and existing parser tests cover those unchanged branches. A full connector database E2E is not necessary for this API-only token correction: the actual config/parser boundary is already exercised directly.

Exact-head fork Build and Apache Build are successful, with no failed/cancelled executed jobs in the retrieved attempt. This is not local runtime evidence.

Local evidence: fetched/checked out independent branch seatunnel-review-13074, read the entire four-file diff and recursive parser/config/index callers using git show/grep; git diff --check passed against merge base f3e1c2ee3b83efd4a1e7fb4cc4fe40b44060c7d0. No local build, unit/IT/E2E test, container or job execution.

2.3 Documentation Updates

The supported grammar, examples, options and defaults remain the same, and existing EN/ZH schema instructions remain usable. No new configuration or migration guide is required. Do not document unrelated grammar expansion as part of this fix.

3. Architectural Soundness

3.1 Elegance of the Solution

Precise fix. The shared API parser is the root-cause layer used by callers across connectors. Repeating ROOT conversions in individual connectors would leave other consumers broken and add maintenance cost.

3.2 Maintainability

The changes retain one grammar and the original error boundaries. A new generic normalization abstraction would enlarge a six-call fix without improving its contract.

3.3 Extensibility

Use locale-neutral normalization for protocol/schema keywords; keep user identifiers and values untouched. Existing recursive parsing remains reusable.

3.4 Historical-Version Compatibility

No plugin rebuild, checkpoint migration or serialized schema change is required by these calls. Live mixed-version execution was not validated here.

4. Issue Summary

Number Issue Location Severity
— No formal issues found Complete four-file diff —

5. Merge Recommendation

Conclusion: Ready to merge

  1. Blockers — must be fixed
    • No source blocker found; required current-head Build is green. Effective maintainer review and repository merge gates still apply.
  2. Recommended fixes — non-blocking
    • No additional unrelated changes requested. The unadded locale variants above are optional hardening, not hidden blockers.

Overall: small, compatible and correctly placed, with discriminating parser assertions. No independent maintainer approval/change request is present in the retrieved history. Daniel's READ-account COMMENT records source clearance; it does not itself satisfy an effective write-reviewer approval or merge-queue requirement. The current comparison drift alone does not justify a sync comment.

Snapshot 2026-11-01T11:47:38.047933+00:00: head 922dad23444c71db2c6841871e788851bcce02fd, base dev; compare diverged, ahead 1 / behind 4; merge blocked / BLOCKED, review decision REVIEW_REQUIRED. Drift is recorded separately; it does not itself request synchronization.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][API] The schema option fails to parse under a Turkish or Azerbaijani locale

2 participants