Add native Flink SQL timestamp and hash functions#639
Merged
yangzhg merged 1 commit intoJun 15, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds native Flink SQL implementations for key datetime and hashing functions to improve Flink-compatibility of Bolt’s FlinkSQL function surface (Fixes #638).
Changes:
- Introduces Flink-native
TIMESTAMPDIFFwith Calcite/Flink month-boundary semantics and Java-styleintnarrowing behavior. - Implements
TO_TIMESTAMPwith Flink-like format selection, plus a parsing fallback for non-zero-padded dates/timestamps. - Adds
HASH_CODEfor common scalar types plus DECIMAL support via a vector function, and expands FlinkSQL test coverage accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| bolt/functions/prestosql/DateTimeImpl.h | Switches Presto datetime diff helpers to a shared lib header (TimeDiffUtils.h). |
| bolt/functions/lib/TimeDiffUtils.h | New shared diffTimestamp / diffDate helpers extracted for reuse. |
| bolt/functions/flinksql/ToTimestampFunction.h | New Flink to_timestamp implementation with auto-format selection and fallback parsing. |
| bolt/functions/flinksql/tests/FlinkSqlDataTimeFunctionsTest.cpp | Adds extensive coverage for timestampdiff, to_timestamp, and hash_code Flink-compatible behavior. |
| bolt/functions/flinksql/registration/Register.cpp | Registers new FlinkSQL functions (timestampdiff, to_timestamp, hash_code) across supported types. |
| bolt/functions/flinksql/HashCodeFunction.h | New Flink hash_code scalar implementation for supported primitive/string/timestamp types. |
| bolt/functions/flinksql/HashCodeFunction.cpp | Adds DECIMAL hash_code vector function + signatures for DECIMAL support. |
| bolt/functions/flinksql/DateTimeDiff.h | New Flink timestampdiff implementation with Calcite/Flink month subtraction semantics. |
| bolt/functions/flinksql/CMakeLists.txt | Adds HashCodeFunction.cpp to the Flink function implementation library build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
df9db69 to
0cdc50e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #638
Summary
TIMESTAMPDIFF,TO_TIMESTAMP, andHASH_CODE.Flink compatibility notes
TIMESTAMPDIFFfollows Flink/Calcite month boundary behavior throughSqlFunctionUtils.subtractMonths.TO_TIMESTAMPkeeps Flink's default format selection and fallback toTimestamp.valueOf/Date.valueOffor non-zero-padded dates.HASH_CODEfollows Flink codegen behavior fromCodeGenUtils.hashCodeForType.