Skip to content

Commit 0c8b96d

Browse files
committed
fix panic
1 parent 4e8a1a5 commit 0c8b96d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

datafusion/core/benches/sql_planner.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ fn register_clickbench_hits_table(rt: &Runtime) -> SessionContext {
130130
format!("{BENCHMARKS_PATH_2}{CLICKBENCH_DATA_PATH}")
131131
};
132132

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

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

143+
// ClickBench stores EventDate as UInt16 (days since 1970-01-01). Create a view
144+
// that exposes it as SQL DATE so that queries comparing it with date literals
145+
// (e.g. "EventDate >= '2013-07-01'") work correctly during planning.
146+
rt.block_on(ctx.sql(
147+
"CREATE VIEW hits AS \
148+
SELECT * EXCEPT (\"EventDate\"), \
149+
CAST(CAST(\"EventDate\" AS INTEGER) AS DATE) AS \"EventDate\" \
150+
FROM hits_raw",
151+
))
152+
.unwrap();
153+
142154
let count =
143155
rt.block_on(async { ctx.table("hits").await.unwrap().count().await.unwrap() });
144156
assert!(count > 0);

0 commit comments

Comments
 (0)