weiqingy opened a new pull request, #2448:
URL: https://github.com/apache/auron/pull/2448

   # Which issue does this PR close?
   
   Closes #1863.
   
   This is the Flink Java side of `UNIX_TIMESTAMP`. The native function it 
calls merged in #2409.
   
   The 0-argument form is still not supported and is not part of this PR. It is 
a different function rather than a missing branch: Flink binds the niladic form 
to `DateTimeUtils.unixTimestamp()`, which reads the clock per record and parses 
nothing, so it needs its own design pass. The converter rejects it explicitly 
and falls back to Flink's engine. Happy to file a separate issue for it if you 
would rather keep that tracked.
   
   # Rationale for this change
   
   This completes native support for Flink's `UNIX_TIMESTAMP` by wiring the 
Flink Calc converter to emit the native function added in #2409. Without it the 
native function is unreachable, and any Calc containing `UNIX_TIMESTAMP` falls 
back to Flink's engine for the whole Calc.
   
   # What changes are included in this PR?
   
   The converter recognizes `UNIX_TIMESTAMP` and lowers the 1-argument and 
2-argument forms to the native `Flink_UnixTimestamp` node.
   
   `UNIX_TIMESTAMP` resolves to `SqlKind.OTHER_FUNCTION`, so it is matched by 
reference identity on the operator before the supported-kinds switch, the same 
way `TRY_CAST` is handled.
   
   A format scanner translates the supported subset of Java date-format letters 
(`yyyy MM dd HH mm ss` and literals) to the native format. Anything outside 
that subset falls back: other pattern letters, unsupported run-lengths, a 
non-literal format argument, the 0-argument form, and a numeric field adjacent 
to another numeric field where the run-length would not survive translation 
(for example `yyyyMd`). Falling back keeps results correct rather than risking 
a silent divergence.
   
   The session time zone is resolved at plan time and passed into the node. 
This required completing the config threading in the standalone-Calc path, 
which passed a persisted config that does not carry `table.local-time-zone`. 
That gap had no effect until now: `UNIX_TIMESTAMP` is the first 
time-zone-sensitive expression the converter supports, and the earlier ones 
(arithmetic, comparison, logical, cast) never read the session zone. The 
effective node config is threaded through instead, so the configured zone 
reaches the native evaluation.
   
   # Are there any user-facing changes?
   
   Yes. `UNIX_TIMESTAMP(string)` and `UNIX_TIMESTAMP(string, format)` now 
execute on the native engine when the format is a supported literal pattern. 
Unsupported patterns and the 0-argument form continue to run on Flink's engine, 
with the same results as before.
   
   # How was this patch tested?
   
   Unit tests for the scanner (accept/reject, quote escaping, the adjacency 
rule), the converter (node shape, format translation, time-zone propagation), 
and the operator-identity invariant. Fallback tests assert that unsupported 
inputs actually fall back rather than silently producing a native plan.
   
   An end-to-end ITCase runs `UNIX_TIMESTAMP(ts)` with a non-UTC session zone 
and confirms the native result matches the expected epoch values. The executed 
native plan shows the function and the resolved zone, confirming the query runs 
natively rather than falling back.
   
   160 tests pass in `auron-flink-planner` on the rebased branch, with spotless 
clean and 0 checkstyle violations.
   
   # Was this patch authored or co-authored using generative AI tooling?
   - [x] Yes
   - [ ] No
   
   Generated-by: Claude Code (Claude Opus 5)
   


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