Skip to content

Add native Flink SQL timestamp and hash functions#639

Merged
yangzhg merged 1 commit into
bytedance:mainfrom
yangzhg:feature/flinksql-native-functions
Jun 15, 2026
Merged

Add native Flink SQL timestamp and hash functions#639
yangzhg merged 1 commit into
bytedance:mainfrom
yangzhg:feature/flinksql-native-functions

Conversation

@yangzhg

@yangzhg yangzhg commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Fixes #638

Summary

  • Add native Flink SQL implementations for TIMESTAMPDIFF, TO_TIMESTAMP, and HASH_CODE.
  • Register Flink SQL signatures for the supported Bolt type surface.
  • Add coverage for Flink-compatible month differences, timestamp parsing fallback, and Java-style hash code results.

Flink compatibility notes

  • TIMESTAMPDIFF follows Flink/Calcite month boundary behavior through SqlFunctionUtils.subtractMonths.
  • TO_TIMESTAMP keeps Flink's default format selection and fallback to Timestamp.valueOf / Date.valueOf for non-zero-padded dates.
  • HASH_CODE follows Flink codegen behavior from CodeGenUtils.hashCodeForType.

Copilot AI review requested due to automatic review settings June 15, 2026 04:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TIMESTAMPDIFF with Calcite/Flink month-boundary semantics and Java-style int narrowing behavior.
  • Implements TO_TIMESTAMP with Flink-like format selection, plus a parsing fallback for non-zero-padded dates/timestamps.
  • Adds HASH_CODE for 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.

@yangzhg yangzhg force-pushed the feature/flinksql-native-functions branch from df9db69 to 0cdc50e Compare June 15, 2026 05:34

@luozenglin luozenglin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yangzhg yangzhg added this pull request to the merge queue Jun 15, 2026
Merged via the queue into bytedance:main with commit 6b54e46 Jun 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add native Flink SQL timestamp and hash functions

3 participants