Skip to content

Commit 67d3ec5

Browse files
update tpch examples for new pyarrow interval
Fixes apache#665
1 parent e519c1b commit 67d3ec5

9 files changed

+11
-27
lines changed

examples/tpch/q01_pricing_summary_report.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
# want to report results for. It should be between 60-120 days before the end.
4949
DAYS_BEFORE_FINAL = 90
5050

51-
# Note: this is a hack on setting the values. It should be set differently once
52-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
53-
interval = pa.scalar((0, 0, DAYS_BEFORE_FINAL), type=pa.month_day_nano_interval())
51+
interval = pa.scalar((0, DAYS_BEFORE_FINAL, 0), type=pa.month_day_nano_interval())
5452

5553
print("Final date in database:", greatest_ship_date)
5654

examples/tpch/q04_order_priority_checking.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
# Create a date object from the string
5050
date = datetime.strptime(DATE_OF_INTEREST, "%Y-%m-%d").date()
5151

52-
# Note: this is a hack on setting the values. It should be set differently once
53-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
54-
interval = pa.scalar((0, 0, INTERVAL_DAYS), type=pa.month_day_nano_interval())
52+
interval = pa.scalar((0, INTERVAL_DAYS, 0), type=pa.month_day_nano_interval())
5553

5654
# Limit results to cases where commitment date before receipt date
5755
# Aggregate the results so we only get one row to join with the order table.

examples/tpch/q05_local_supplier_volume.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141

4242
date = datetime.strptime(DATE_OF_INTEREST, "%Y-%m-%d").date()
4343

44-
# Note: this is a hack on setting the values. It should be set differently once
45-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
46-
interval = pa.scalar((0, 0, INTERVAL_DAYS), type=pa.month_day_nano_interval())
44+
interval = pa.scalar((0, INTERVAL_DAYS, 0), type=pa.month_day_nano_interval())
4745

4846
# Load the dataframes we need
4947

examples/tpch/q06_forecasting_revenue_change.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@
4545

4646
date = datetime.strptime(DATE_OF_INTEREST, "%Y-%m-%d").date()
4747

48-
# Note: this is a hack on setting the values. It should be set differently once
49-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
50-
interval = pa.scalar((0, 0, INTERVAL_DAYS), type=pa.month_day_nano_interval())
48+
interval = pa.scalar((0, INTERVAL_DAYS, 0), type=pa.month_day_nano_interval())
5149

5250
# Load the dataframes we need
5351

examples/tpch/q10_returned_item_reporting.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838

3939
date_start_of_quarter = lit(datetime.strptime(DATE_START_OF_QUARTER, "%Y-%m-%d").date())
4040

41-
# Note: this is a hack on setting the values. It should be set differently once
42-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
43-
interval_one_quarter = lit(pa.scalar((0, 0, 92), type=pa.month_day_nano_interval()))
41+
interval_one_quarter = lit(pa.scalar((0, 92, 0), type=pa.month_day_nano_interval()))
4442

4543
# Load the dataframes we need
4644

examples/tpch/q12_ship_mode_order_priority.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151

5252
date = datetime.strptime(DATE_OF_INTEREST, "%Y-%m-%d").date()
5353

54-
# Note: this is a hack on setting the values. It should be set differently once
55-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
56-
interval = pa.scalar((0, 0, 365), type=pa.month_day_nano_interval())
54+
interval = pa.scalar((0, 365, 0), type=pa.month_day_nano_interval())
5755

5856

5957
df = df_lineitem.filter(col("l_receiptdate") >= lit(date)).filter(

examples/tpch/q14_promotion_effect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
DATE = "1995-09-01"
3535

3636
date_of_interest = lit(datetime.strptime(DATE, "%Y-%m-%d").date())
37-
# Note: this is a hack on setting the values. It should be set differently once
38-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
39-
interval_one_month = lit(pa.scalar((0, 0, 30), type=pa.month_day_nano_interval()))
37+
38+
interval_one_month = lit(pa.scalar((0, 30, 0), type=pa.month_day_nano_interval()))
4039

4140
# Load the dataframes we need
4241

examples/tpch/q15_top_supplier.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434
DATE = "1996-01-01"
3535

3636
date_of_interest = lit(datetime.strptime(DATE, "%Y-%m-%d").date())
37-
# Note: this is a hack on setting the values. It should be set differently once
38-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
39-
interval_3_months = lit(pa.scalar((0, 0, 91), type=pa.month_day_nano_interval()))
37+
38+
interval_3_months = lit(pa.scalar((0, 91, 0), type=pa.month_day_nano_interval()))
4039

4140
# Load the dataframes we need
4241

examples/tpch/q20_potential_part_promotion.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656

5757
date = datetime.strptime(DATE_OF_INTEREST, "%Y-%m-%d").date()
5858

59-
# Note: this is a hack on setting the values. It should be set differently once
60-
# https://github.com/apache/datafusion-python/issues/665 is resolved.
61-
interval = pa.scalar((0, 0, 365), type=pa.month_day_nano_interval())
59+
interval = pa.scalar((0, 365, 0), type=pa.month_day_nano_interval())
6260

6361
# Filter down dataframes
6462
df_nation = df_nation.filter(col("n_name") == lit(NATION_OF_INTEREST))

0 commit comments

Comments
 (0)