Skip to content

Support MySQL LENGTH, BIT_LENGTH and LOCATE functions in SQL Federation#38704

Open
Phixsura wants to merge 1 commit into
apache:masterfrom
Phixsura:04-feat-federation-mysql-string-functions
Open

Support MySQL LENGTH, BIT_LENGTH and LOCATE functions in SQL Federation#38704
Phixsura wants to merge 1 commit into
apache:masterfrom
Phixsura:04-feat-federation-mysql-string-functions

Conversation

@Phixsura
Copy link
Copy Markdown

Background

SQL Federation rejects three common MySQL string functions because they are not registered in MySQLOperatorTable, producing No match found for function signature LENGTH/BIT_LENGTH/LOCATE(...). Reported in #31897, #31898, #31899.

Changes

  • Add MySQLLengthFunction, MySQLBitLengthFunction, MySQLLocateFunction as SqlUserDefinedFunction subclasses with operand metadata matching MySQL semantics (UTF-8 byte count for character values, raw length for byte[], 1-based positions with the optional start position respected and clamped).
  • Register LENGTH, BIT_LENGTH, LOCATE, and LOCATE_WITH_POSITION in MySQLOperatorTable.
  • Calcite's SqlLibraryOperators.LENGTH lives in HIVE / POSTGRESQL / BIG_QUERY libraries and uses character-count semantics, so a MySQL-specific implementation is required.

Verification

  • 30 new unit tests across the three functions covering null, empty, multi-byte UTF-8, byte[], and LOCATE position boundaries.
  • 4 new cases in federation-query-sql-cases.xml pinning the generated Calcite plan; SQLStatementCompilerIT 111 / 111 (107 baseline + 4 new).
  • spotless:check, checkstyle:check, apache-rat:check all green on kernel/sql-federation/compiler.

Closes #31897
Closes #31898
Closes #31899

@Phixsura Phixsura force-pushed the 04-feat-federation-mysql-string-functions branch from 0a307e6 to e8bfdc6 Compare May 20, 2026 06:09
@Phixsura
Copy link
Copy Markdown
Author

Rebased onto latest master (now at 63b0fdbe). Previous CI on head 0a307e61 had two failures, both unrelated to this PR:

  • CI job: PipelineJobProgressPersistServiceTest.assertPersistNowUpdatesProgressWhenJobItemContextPresentWithoutLogging failed with a Mockito UnfinishedStubbingException (cross-test stubbing leakage). The test lives in kernel/data-pipeline/core and is unrelated to the federation change here. I ran it locally on this branch (PipelineJobProgressPersistServiceTest: 9 tests, 0 failures, 0.8s).
  • E2E - SQL (Smoke) (proxy, Cluster, MySQL, db_tbl_sql_federation): failed at step 3 "Download Source Snapshot" with Failed to ListArtifacts: (403) Forbidden. The federation tests never started; the failure is in artifact-download infrastructure.

Workflows are awaiting committer approval again after the rebase. Could a maintainer kindly approve them?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support federated query mysql LOCATE function Support federated query mysql bit_length function Support federated query mysql length function

1 participant