…uery API
Add postAnalysisRules (List<RelShuttle>) to LanguageSpec.LanguageExtension
and register DatetimeExtension in UnifiedPplSpec with two rules:
1. DatetimeUdtNormalizeRule rewrites datetime UDT return types
(EXPR_DATE/TIME/TIMESTAMP) on RexCall nodes to standard Calcite
DATE/TIME/TIMESTAMP types via call.clone().
2. DatetimeOutputCastRule adds a final LogicalProject that casts
standard datetime output columns to VARCHAR, aligning with PPL's
wire-format contract (ISO string representation).
Both rules run as postAnalysisRules after the planning strategy produces
the RelNode, applied uniformly to both SQL and PPL paths.
No changes to core/ module — UDF definitions and implementors are
untouched. The mismatch between rewritten signatures and UDF
implementations is a known limitation addressed separately.
Signed-off-by: Chen Dai <daichen@amazon.com>
Description
Add
postAnalysisRulestoLanguageSpec.LanguageExtensionand registerDatetimeExtensioninUnifiedPplSpecwith two post-analysis rules:EXPR_DATE/TIME/TIMESTAMP) on RexCall nodes to standard Calcite types, enabling downstream consumers to process the plan without UDT-related failures.LogicalProjectthat casts standard datetime output columns toVARCHAR, aligning with PPL's wire-format contract (ISO string representation).Examples
UDT Normalize Rule — source=events | eval d = DATE(name) | fields d Before: LogicalProject(d=[DATE($1):EXPR_DATE]) After: LogicalProject(d=[DATE($1):DATE]) Output Cast Rule — source=events | fields hire_date, start_time, created_at Before: LogicalProject(hire_date=[$2], start_time=[$3], created_at=[$4]) LogicalTableScan(table=[[events]]) After: LogicalProject(hire_date=[CAST($0):VARCHAR], start_time=[CAST($1):VARCHAR], created_at=[CAST($2):VARCHAR]) LogicalProject(hire_date=[$2], start_time=[$3], created_at=[$4]) LogicalTableScan(table=[[events]])Notes
This PR partially resolves #5250. After the UDT normalize rule rewrites datetime function signatures to standard Calcite types, a mismatch exists between the RexCall return type (now standard
DATE/TIME/TIMESTAMP) and the underlying PPL UDF implementation (which still expects and produces String values). This does not affect the Analytics Engine path (which reimplements UDFs in DataFusion), but theUnifiedQueryCompilerpath will still fail for queries involving datetime UDFs. A follow-up PR will replace/wrap the function implementations properly.Related Issues
Part of #5250
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.