Skip to content

Fix DataFusion EventDate handling: cast UInt16 to DATE#803

Open
KARTIK64-rgb wants to merge 3 commits intoClickHouse:mainfrom
KARTIK64-rgb:fix/eventdate-cast-to-date
Open

Fix DataFusion EventDate handling: cast UInt16 to DATE#803
KARTIK64-rgb wants to merge 3 commits intoClickHouse:mainfrom
KARTIK64-rgb:fix/eventdate-cast-to-date

Conversation

@KARTIK64-rgb
Copy link

Summary

ClickBench encodes EventDate as a UInt16 representing days since
1970-01-01. The DataFusion runner was treating it as a raw integer,
causing ClickBench queries 36–42 to return 0 rows due to broken date
range predicates.

Changes

  • Updated the DataFusion runner scripts under datafusion/ to cast
    EventDate from UInt16 to a proper SQL DATE:

    CAST(CAST("EventDate" AS INTEGER) AS DATE)

    Correctness fix — no meaningful performance impact.

  • Without this change, queries Q37-Q43 that filter on EventDate using date literals (e.g., >= '2013-07-01') return incorrect results (0 rows) because EventDate is stored as INT32 in the parquet file and DataFusion compares it against string literals. The new view casts EventDate to a proper DATE type

References

@CLAassistant
Copy link

CLAassistant commented Feb 24, 2026

CLA assistant check
All committers have signed the CLA.

@KARTIK64-rgb KARTIK64-rgb force-pushed the fix/eventdate-cast-to-date branch from cb33c5f to f5fa7cb Compare February 25, 2026 13:59
OPTIONS ('binary_as_string' 'true');


CREATE VIEW hits AS
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to apply the same thing to the partitioned version in https://github.com/ClickHouse/ClickBench/tree/main/datafusion-partitioned as well

Copy link
Author

Choose a reason for hiding this comment

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

-Sure sir
-I will update the datafusion-partitioned/create.sql.
thanks for guiding.

@alamb
Copy link
Contributor

alamb commented Feb 27, 2026

Thanks @KARTIK64-rgb - this looks good

@alamb
Copy link
Contributor

alamb commented Feb 27, 2026

This is also related to the discussion here, several years ago

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.

Update ClickBench runner scripts to treat EventDate as a Date (not Int16)

3 participants