Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion datafusion/core/benches/sql_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ fn register_clickbench_hits_table(rt: &Runtime) -> SessionContext {
format!("{BENCHMARKS_PATH_2}{CLICKBENCH_DATA_PATH}")
};

let sql = format!("CREATE EXTERNAL TABLE hits STORED AS PARQUET LOCATION '{path}'");
let sql =
format!("CREATE EXTERNAL TABLE hits_raw STORED AS PARQUET LOCATION '{path}'");

// ClickBench partitioned dataset was written by an ancient version of pyarrow that
// that wrote strings with the wrong logical type. To read it correctly, we must
Expand All @@ -139,6 +140,17 @@ fn register_clickbench_hits_table(rt: &Runtime) -> SessionContext {
.unwrap();
rt.block_on(ctx.sql(&sql)).unwrap();

// ClickBench stores EventDate as UInt16 (days since 1970-01-01). Create a view
// that exposes it as SQL DATE so that queries comparing it with date literals
// (e.g. "EventDate >= '2013-07-01'") work correctly during planning.
rt.block_on(ctx.sql(
"CREATE VIEW hits AS \
SELECT * EXCEPT (\"EventDate\"), \
CAST(CAST(\"EventDate\" AS INTEGER) AS DATE) AS \"EventDate\" \
FROM hits_raw",
))
.unwrap();

let count =
rt.block_on(async { ctx.table("hits").await.unwrap().count().await.unwrap() });
assert!(count > 0);
Expand Down
Loading