@@ -21,7 +21,7 @@ use std::path::PathBuf;
2121use std:: sync:: Arc ;
2222use std:: time:: Instant ;
2323
24- use arrow:: datatypes:: { DataType , Field , Schema } ;
24+ use arrow:: datatypes:: { DataType , DateUnit , Field , Schema } ;
2525use arrow:: util:: pretty;
2626use datafusion:: datasource:: parquet:: ParquetTable ;
2727use datafusion:: datasource:: { CsvFile , MemTable , TableProvider } ;
@@ -187,7 +187,7 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
187187 from
188188 lineitem
189189 where
190- l_shipdate <= '1998-09-02'
190+ l_shipdate <= date '1998-09-02'
191191 group by
192192 l_returnflag,
193193 l_linestatus
@@ -256,8 +256,8 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
256256 c_mktsegment = 'BUILDING'
257257 and c_custkey = o_custkey
258258 and l_orderkey = o_orderkey
259- and o_orderdate < '1995-03-15'
260- and l_shipdate > '1995-03-15'
259+ and o_orderdate < date '1995-03-15'
260+ and l_shipdate > date '1995-03-15'
261261 group by
262262 l_orderkey,
263263 o_orderdate,
@@ -337,8 +337,8 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
337337 and s_nationkey = n_nationkey
338338 and n_regionkey = r_regionkey
339339 and r_name = 'ASIA'
340- and o_orderdate >= '1994-01-01'
341- and o_orderdate < '1995-01-01'
340+ and o_orderdate >= date '1994-01-01'
341+ and o_orderdate < date '1995-01-01'
342342 group by
343343 n_name
344344 order by
@@ -363,9 +363,9 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
363363 from
364364 lineitem
365365 where
366- l_shipdate >= '1994-01-01'
367- and l_shipdate < '1995-01-01'
368- and l_discount between 0.06 - 0.01 and 0.06 + 0.01
366+ l_shipdate >= date '1994-01-01'
367+ and l_shipdate < date '1995-01-01'
368+ and l_discount > 0.06 - 0.01 and l_discount < 0.06 + 0.01
369369 and l_quantity < 24;"
370370 ) ,
371371
@@ -399,7 +399,7 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
399399 (n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY')
400400 or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')
401401 )
402- and l_shipdate > '1995-01-01' and l_shipdate < '1996-12-31'
402+ and l_shipdate > date '1995-01-01' and l_shipdate < date '1996-12-31'
403403 ) as shipping
404404 group by
405405 supp_nation,
@@ -442,7 +442,7 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
442442 and n1.n_regionkey = r_regionkey
443443 and r_name = 'AMERICA'
444444 and s_nationkey = n2.n_nationkey
445- and o_orderdate between '1995-01-01' and '1996-12-31'
445+ and o_orderdate between date '1995-01-01' and date '1996-12-31'
446446 and p_type = 'ECONOMY ANODIZED STEEL'
447447 ) as all_nations
448448 group by
@@ -486,6 +486,39 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
486486 o_year desc;"
487487 ) ,
488488
489+ // 10 => ctx.create_logical_plan(
490+ // "select
491+ // c_custkey,
492+ // c_name,
493+ // sum(l_extendedprice * (1 - l_discount)) as revenue,
494+ // c_acctbal,
495+ // n_name,
496+ // c_address,
497+ // c_phone,
498+ // c_comment
499+ // from
500+ // customer,
501+ // orders,
502+ // lineitem,
503+ // nation
504+ // where
505+ // c_custkey = o_custkey
506+ // and l_orderkey = o_orderkey
507+ // and o_orderdate >= date '1993-10-01'
508+ // and o_orderdate < date '1993-10-01' + interval '3' month
509+ // and l_returnflag = 'R'
510+ // and c_nationkey = n_nationkey
511+ // group by
512+ // c_custkey,
513+ // c_name,
514+ // c_acctbal,
515+ // c_phone,
516+ // n_name,
517+ // c_address,
518+ // c_comment
519+ // order by
520+ // revenue desc;"
521+ // ),
489522 10 => ctx. create_logical_plan (
490523 "select
491524 c_custkey,
@@ -504,8 +537,8 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
504537 where
505538 c_custkey = o_custkey
506539 and l_orderkey = o_orderkey
507- and o_orderdate >= '1993-10-01'
508- and o_orderdate < '1994-01-01'
540+ and o_orderdate >= date '1993-10-01'
541+ and o_orderdate < date '1994-01-01'
509542 and l_returnflag = 'R'
510543 and c_nationkey = n_nationkey
511544 group by
@@ -606,8 +639,8 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
606639 (l_shipmode = 'MAIL' or l_shipmode = 'SHIP')
607640 and l_commitdate < l_receiptdate
608641 and l_shipdate < l_commitdate
609- and l_receiptdate >= '1994-01-01'
610- and l_receiptdate < '1995-01-01'
642+ and l_receiptdate >= date '1994-01-01'
643+ and l_receiptdate < date '1995-01-01'
611644 group by
612645 l_shipmode
613646 order by
@@ -649,8 +682,8 @@ fn create_logical_plan(ctx: &mut ExecutionContext, query: usize) -> Result<Logic
649682 part
650683 where
651684 l_partkey = p_partkey
652- and l_shipdate >= '1995-09-01'
653- and l_shipdate < '1995-10-01';"
685+ and l_shipdate >= date '1995-09-01'
686+ and l_shipdate < date '1995-10-01';"
654687 ) ,
655688
656689 15 => ctx. create_logical_plan (
@@ -1072,7 +1105,7 @@ fn get_schema(table: &str) -> Schema {
10721105 Field :: new( "o_custkey" , DataType :: UInt32 , false ) ,
10731106 Field :: new( "o_orderstatus" , DataType :: Utf8 , false ) ,
10741107 Field :: new( "o_totalprice" , DataType :: Float64 , false ) , // decimal
1075- Field :: new( "o_orderdate" , DataType :: Utf8 , false ) ,
1108+ Field :: new( "o_orderdate" , DataType :: Date32 ( DateUnit :: Day ) , false ) ,
10761109 Field :: new( "o_orderpriority" , DataType :: Utf8 , false ) ,
10771110 Field :: new( "o_clerk" , DataType :: Utf8 , false ) ,
10781111 Field :: new( "o_shippriority" , DataType :: UInt32 , false ) ,
@@ -1090,9 +1123,9 @@ fn get_schema(table: &str) -> Schema {
10901123 Field :: new( "l_tax" , DataType :: Float64 , false ) , // decimal
10911124 Field :: new( "l_returnflag" , DataType :: Utf8 , false ) ,
10921125 Field :: new( "l_linestatus" , DataType :: Utf8 , false ) ,
1093- Field :: new( "l_shipdate" , DataType :: Utf8 , false ) ,
1094- Field :: new( "l_commitdate" , DataType :: Utf8 , false ) ,
1095- Field :: new( "l_receiptdate" , DataType :: Utf8 , false ) ,
1126+ Field :: new( "l_shipdate" , DataType :: Date32 ( DateUnit :: Day ) , false ) ,
1127+ Field :: new( "l_commitdate" , DataType :: Date32 ( DateUnit :: Day ) , false ) ,
1128+ Field :: new( "l_receiptdate" , DataType :: Date32 ( DateUnit :: Day ) , false ) ,
10961129 Field :: new( "l_shipinstruct" , DataType :: Utf8 , false ) ,
10971130 Field :: new( "l_shipmode" , DataType :: Utf8 , false ) ,
10981131 Field :: new( "l_comment" , DataType :: Utf8 , false ) ,
0 commit comments