Skip to content

[GLUTEN-4730][CH] feat: Support date_from_unix_date function: Add ClickHouse backend implementation#12410

Open
navaneethsujith09 wants to merge 5 commits into
apache:mainfrom
navaneethsujith09:date-from-unix-date
Open

[GLUTEN-4730][CH] feat: Support date_from_unix_date function: Add ClickHouse backend implementation#12410
navaneethsujith09 wants to merge 5 commits into
apache:mainfrom
navaneethsujith09:date-from-unix-date

Conversation

@navaneethsujith09

@navaneethsujith09 navaneethsujith09 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Implement SparkFunctionDateFromUnixDate in C++
Register function in CommonScalarFunctionParser
Add unit test in GlutenDateFunctionsSuite (Spark 3.5) for correctness
This enables Spark SQL queries using date_from_unix_date to work with the ClickHouse backend.
Implemented the feedback recieved from @taiyang-li

What changes are proposed in this pull request?

This pull request adds support for the date_from_unix_date function in the ClickHouse backend of Apache Gluten.
Specifically, it includes:
Implementation of the SparkFunctionDateFromUnixDate C++ function, which converts a unix date (number of days since epoch) to a Spark-compatible date.
Registration of the function in the ClickHouse function factory and the scalar function parser, enabling Substrait-to-ClickHouse translation.
Addition of unit tests in GlutenDateFunctionsSuite (Spark 3.5) to verify correctness and expected behavior.

How was this patch tested?

Added unit tests in gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenDateFunctionsSuite.scala to cover:
Typical values (e.g., date_from_unix_date(0) returns 1970-01-01)
Larger values (e.g., date_from_unix_date(1000) returns 1972-09-27)
Null handling (date_from_unix_date(null) returns null)
Ran the full test suite to ensure no regressions.

Was this patch authored or co-authored using generative AI tooling?

Generated-by Claude Opus 4.8

Related issue: #4730

Copilot AI review requested due to automatic review settings June 30, 2026 22:23

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added CORE works for Gluten Core CLICKHOUSE labels Jun 30, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@prestodb-ci

Copy link
Copy Markdown

Failed to query issues imported from #12410:

dial tcp 10.167.38.130:3306: connect: connection timed out

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI review requested due to automatic review settings June 30, 2026 22:33

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@lgbo-ustc

Copy link
Copy Markdown
Contributor

@navaneethsujith09

engine/Functions/CMakeFiles/gluten_spark_functions_obj.dir/SparkFunctionDateFromUnixDate.cpp.o -MF utils/extern-local-engine/Functions/CMakeFiles/gluten_spark_functions_obj.dir/SparkFunctionDateFromUnixDate.cpp.o.d -o utils/extern-local-engine/Functions/CMakeFiles/gluten_spark_functions_obj.dir/SparkFunctionDateFromUnixDate.cpp.o -c /home/jenkins/agent/workspace/gluten/gluten-ci/gluten/cpp-ch/ClickHouse/utils/extern-local-engine/Functions/SparkFunctionDateFromUnixDate.cpp

[2026-06-30T22:42:20.727Z] /home/jenkins/agent/workspace/gluten/gluten-ci/gluten/cpp-ch/local-engine/Functions/SparkFunctionDateFromUnixDate.cpp:26:2: error: expected '}'

[2026-06-30T22:42:20.727Z]    26 | }

[2026-06-30T22:42:20.727Z]       |  ^

[2026-06-30T22:42:20.727Z] /home/jenkins/agent/workspace/gluten/gluten-ci/gluten/cpp-ch/local-engine/Functions/SparkFunctionDateFromUnixDate.cpp:21:1: note: to match this '{'

[2026-06-30T22:42:20.727Z]    21 | {

[2026-06-30T22:42:20.727Z]       | ^

[2026-06-30T22:42:20.727Z] 1 error generated.

[2026-06-30T22:42:24.869Z] [10726/13871] Linking CXX executable contrib/llvm-project/llvm/bin/llvm-tblgen

[2026-06-30T22:42:24.869Z] ninja: build stopped: subcommand failed.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@navaneethsujith09

Copy link
Copy Markdown
Contributor Author

@lgbo-ustc Ok, I think I have fixed the issue. Please let me know if anything else needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLICKHOUSE CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants