AnissaLiu opened a new pull request, #13491:
URL: https://github.com/apache/gluten/pull/13491

   ## What changes are proposed in this pull request?
   Fixes https://github.com/apache/gluten/issues/13485
   velox flinksql implementations (companion velox PR in 
https://github.com/bigo-sg/velox/pull/96):
   ### 1. Temporal expression converter support (FROM_UNIXTIME / UNIX_TIMESTAMP 
/ TIMESTAMPADD)
   
   **FROM_UNIXTIME / UNIX_TIMESTAMP:**
   - `FromUnixtimeRexCallConverter`: accepts the whole INTEGER family for the 
first operand (cast to BIGINT, mirroring Flink codegen), optional STRING format 
operand; maps to the velox flinksql `from_unixtime`
   - `UnixTimestampRexCallConverter`: accepts 0/1/2 string operands; maps to 
the velox flinksql `unix_timestamp` (reuses existing BIGINT result-type 
handling)
   
   **TIMESTAMPADD** (Calcite rewrites it into interval arithmetic, so the 
converters handle the rewritten `+`/`-`/`*` shapes):
   - `IntervalArithmeticRexCallConverter`: plus/minus for (timestamp/date, 
interval) operand shapes; interval-on-left plus is flipped to the canonical 
(datetime, interval) order since velox only registers datetime-on-left 
signatures
   - `IntervalMultiplyRexCallConverter`: interval × numeric for the 
column-amount rewrite `ts + (interval × n)`, normalized to (interval, BIGINT)
   
   **Type mapping fixes in `LogicalTypeConverter`:**
   - `DayTimeIntervalType` now maps to `IntervalDayTimeType` (was incorrectly 
mapped to `BigIntType`)
   - `YearMonthIntervalType` added, maps to `IntervalYearMonthType` (previously 
missing, caused `Unsupported logical type: INTERVAL MONTH`)
   
   **`toVariant` in `RexNodeConverter`** gains interval literal cases: day-time 
family → BigIntValue (millis), year-month family → IntegerValue (months). 
Previously only `INTERVAL_SECOND` was handled.
   
   ### 2. Hash exchange cast fix (prerequisite for e2e testing)
   
   `StreamExecExchange.translateToPlanInternal` unconditionally cast its input 
to `OneInputTransformation` to check `instanceof GlutenOperator`, so any plan 
where the hash exchange sits directly on a `SourceTransformation` (e.g. a plain 
`GROUP BY` over a source) failed planning with a `ClassCastException`. The cast 
is now guarded; non-gluten input shapes take the pre-existing vanilla fallback 
(`KeyGroupStreamPartitioner`).
   
   This fix is included as a separate commit because the temporal expression 
e2e tests include aggregate-context queries that require this path to work. 
Behavior for shapes that already worked is unchanged.
   
   ## How was this patch tested?
   
   - **17 converter UT cases** (`mvn test -pl ut -am`):
     - Type mapping (DayTimeInterval→IntervalDayTimeType, 
YearMonthInterval→IntervalYearMonthType)
     - Interval literal variant conversion
     - plus/minus/multiply converter behavior (operand validation, parameter 
flipping, BIGINT cast insertion, DATE result type)
     - Numeric add regression (plain `+` still maps to "add")
   - **End-to-end dual-run** (native Flink 1.19.2 vs GFV) over 21 bounded SQL 
cases covering all three expressions:
     - FROM_UNIXTIME: basic/format/null/INT-cast/boundary/invalid/nested
     - UNIX_TIMESTAMP: basic/format/null/invalid (Long.MIN_VALUE)/no-arg 
(predicate-wrapped)
     - TIMESTAMPADD: time family, month family (end-of-month clamping), DATE 
input, column amount, NULL, handwritten `ts ± INTERVAL`
     - Regression: existing mapped expressions and PROCTIME path
     - **All 21 cases MATCH** (changelog-folded exact comparison)


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to