zhang-arvin opened a new pull request, #13394:
URL: https://github.com/apache/gravitino/pull/13394

   ### What changes were proposed in this pull request?
   
   Add structured read and create support for the one-column ClickHouse 
partition expressions `toStartOfWeek(column)` and `toStartOfMonth(column)`.
   
   - `Transforms` gains `NAME_OF_TO_START_OF_WEEK` / 
`NAME_OF_TO_START_OF_MONTH`, the `ToStartOfWeekTransform` / 
`ToStartOfMonthTransform` single-field transforms, and the `toStartOfWeek(...)` 
/ `toStartOfMonth(...)` factories, so the ClickHouse function name is preserved 
in the partition transform.
   - Load: `ClickHouseTableSqlUtils.parsePartitioning` recognizes the strictly 
one-column forms and returns the corresponding transform with the column 
argument preserved.
   - Create: `toPartitionExpression` emits `toStartOfWeek(\`column\`)` / 
`toStartOfMonth(\`column\`)`.
   - `toPartitionExpression` matched only lower-case transform names, so the 
camel-cased ClickHouse names are now compared case-insensitively.
   
   Scope is deliberately limited to the one-argument forms, as the issue asks. 
`toStartOfWeek(column, mode)` and `toStartOfWeek(column, mode, timezone)`, 
nested function expressions and other `toStartOf*` functions are rejected, so 
loading such a table still leaves `Table.partitioning()` unstructured and 
preserves the canonical expression in the read-only `partition-key` property. 
`toStartOfWeek(column)` uses ClickHouse's default week mode `0` (Sunday start) 
and the server timezone.
   
   ### Why are the changes needed?
   
   ClickHouse MergeTree tables can be partitioned by these expressions, but the 
catalog returned an empty `Table.partitioning()` for them and could not create 
a table from the corresponding function transforms.
   
   Fixes #13391
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Tables partitioned by one-column `toStartOfWeek(column)` / 
`toStartOfMonth(column)` now expose a structured transform in 
`Table.partitioning()`, and those transforms can be used to create a table.
   
   ### How was this patch tested?
   
   Unit tests in `TestClickHouseTableOperationsPartitioning` cover parse of the 
single-column forms (including backtick-quoted and case-insensitive input, and 
tuple combinations), rejection of the out-of-scope multi-argument / nested / 
other `toStartOf*` forms, SQL generation for create, and a parse-to-DDL round 
trip.
   
   `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test :api:test 
-PskipITs --tests "*Partitioning*" --tests "*Transforms*"` passes.


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