Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,15 @@ case class Literal (value: Any, dataType: DataType) extends LeafExpression {
case null => "null"
case binary: Array[Byte] => s"0x" + DatatypeConverter.printHexBinary(binary)
case d: ArrayBasedMapData => s"map(${d.toString})"
case other => other.toString
case other =>
dataType match {
case DateType =>
DateTimeUtils.toJavaDate(value.asInstanceOf[Int]).toString
case TimestampType =>
DateTimeUtils.toJavaTimestamp(value.asInstanceOf[Long]).toString
Comment thread
wangyum marked this conversation as resolved.
Outdated
case _ =>
other.toString
}
}

override def hashCode(): Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,9 @@ class LiteralExpressionSuite extends SparkFunSuite with ExpressionEvalHelper {
assert(Literal(Array("1", "2", "3")) ==
Literal.create(Array("1", "2", "3"), ArrayType(StringType)))
}

test("Date/Timestamp toString") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe JIRA prefix in the test title.

assert(Literal.default(DateType).toString === "1970-01-01")
assert(Literal.default(TimestampType).toString === "1969-12-31 16:00:00.0")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Input [2]: [d_date_sk#10, d_date#11]

(13) Filter [codegen id : 2]
Input [2]: [d_date_sk#10, d_date#11]
Condition : (((isnotnull(d_date#11) AND (d_date#11 >= 10997)) AND (d_date#11 <= 11057)) AND isnotnull(d_date_sk#10))
Condition : (((isnotnull(d_date#11) AND (d_date#11 >= 2000-02-10)) AND (d_date#11 <= 2000-04-10)) AND isnotnull(d_date_sk#10))

(14) BroadcastExchange
Input [2]: [d_date_sk#10, d_date#11]
Expand Down Expand Up @@ -131,7 +131,7 @@ Input [6]: [inv_warehouse_sk#2, inv_quantity_on_hand#3, i_item_id#7, d_date#11,
(23) HashAggregate [codegen id : 4]
Input [4]: [inv_quantity_on_hand#3, w_warehouse_name#14, i_item_id#7, d_date#11]
Keys [2]: [w_warehouse_name#14, i_item_id#7]
Functions [2]: [partial_sum(CASE WHEN (d_date#11 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END), partial_sum(CASE WHEN (d_date#11 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Functions [2]: [partial_sum(CASE WHEN (d_date#11 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END), partial_sum(CASE WHEN (d_date#11 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum#16, sum#17]
Results [4]: [w_warehouse_name#14, i_item_id#7, sum#18, sum#19]

Expand All @@ -142,9 +142,9 @@ Arguments: hashpartitioning(w_warehouse_name#14, i_item_id#7, 5), ENSURE_REQUIRE
(25) HashAggregate [codegen id : 5]
Input [4]: [w_warehouse_name#14, i_item_id#7, sum#18, sum#19]
Keys [2]: [w_warehouse_name#14, i_item_id#7]
Functions [2]: [sum(CASE WHEN (d_date#11 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END), sum(CASE WHEN (d_date#11 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#11 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#21, sum(CASE WHEN (d_date#11 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#22]
Results [4]: [w_warehouse_name#14, i_item_id#7, sum(CASE WHEN (d_date#11 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#21 AS inv_before#23, sum(CASE WHEN (d_date#11 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#22 AS inv_after#24]
Functions [2]: [sum(CASE WHEN (d_date#11 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END), sum(CASE WHEN (d_date#11 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#11 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#21, sum(CASE WHEN (d_date#11 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#22]
Results [4]: [w_warehouse_name#14, i_item_id#7, sum(CASE WHEN (d_date#11 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#21 AS inv_before#23, sum(CASE WHEN (d_date#11 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#22 AS inv_after#24]

(26) Filter [codegen id : 5]
Input [4]: [w_warehouse_name#14, i_item_id#7, inv_before#23, inv_after#24]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TakeOrderedAndProject [w_warehouse_name,i_item_id,inv_before,inv_after]
WholeStageCodegen (5)
Filter [inv_before,inv_after]
HashAggregate [w_warehouse_name,i_item_id,sum,sum] [sum(CASE WHEN (d_date < 11027) THEN inv_quantity_on_hand ELSE 0 END),sum(CASE WHEN (d_date >= 11027) THEN inv_quantity_on_hand ELSE 0 END),inv_before,inv_after,sum,sum]
HashAggregate [w_warehouse_name,i_item_id,sum,sum] [sum(CASE WHEN (d_date < 2000-03-11) THEN inv_quantity_on_hand ELSE 0 END),sum(CASE WHEN (d_date >= 2000-03-11) THEN inv_quantity_on_hand ELSE 0 END),inv_before,inv_after,sum,sum]
InputAdapter
Exchange [w_warehouse_name,i_item_id] #1
WholeStageCodegen (4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Input [2]: [d_date_sk#13, d_date#14]

(19) Filter [codegen id : 3]
Input [2]: [d_date_sk#13, d_date#14]
Condition : (((isnotnull(d_date#14) AND (d_date#14 >= 10997)) AND (d_date#14 <= 11057)) AND isnotnull(d_date_sk#13))
Condition : (((isnotnull(d_date#14) AND (d_date#14 >= 2000-02-10)) AND (d_date#14 <= 2000-04-10)) AND isnotnull(d_date_sk#13))

(20) BroadcastExchange
Input [2]: [d_date_sk#13, d_date#14]
Expand All @@ -131,7 +131,7 @@ Input [6]: [inv_quantity_on_hand#3, inv_date_sk#4, w_warehouse_name#7, i_item_id
(23) HashAggregate [codegen id : 4]
Input [4]: [inv_quantity_on_hand#3, w_warehouse_name#7, i_item_id#10, d_date#14]
Keys [2]: [w_warehouse_name#7, i_item_id#10]
Functions [2]: [partial_sum(CASE WHEN (d_date#14 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END), partial_sum(CASE WHEN (d_date#14 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Functions [2]: [partial_sum(CASE WHEN (d_date#14 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END), partial_sum(CASE WHEN (d_date#14 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum#16, sum#17]
Results [4]: [w_warehouse_name#7, i_item_id#10, sum#18, sum#19]

Expand All @@ -142,9 +142,9 @@ Arguments: hashpartitioning(w_warehouse_name#7, i_item_id#10, 5), ENSURE_REQUIRE
(25) HashAggregate [codegen id : 5]
Input [4]: [w_warehouse_name#7, i_item_id#10, sum#18, sum#19]
Keys [2]: [w_warehouse_name#7, i_item_id#10]
Functions [2]: [sum(CASE WHEN (d_date#14 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END), sum(CASE WHEN (d_date#14 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#14 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#21, sum(CASE WHEN (d_date#14 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#22]
Results [4]: [w_warehouse_name#7, i_item_id#10, sum(CASE WHEN (d_date#14 < 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#21 AS inv_before#23, sum(CASE WHEN (d_date#14 >= 11027) THEN inv_quantity_on_hand#3 ELSE 0 END)#22 AS inv_after#24]
Functions [2]: [sum(CASE WHEN (d_date#14 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END), sum(CASE WHEN (d_date#14 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#14 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#21, sum(CASE WHEN (d_date#14 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#22]
Results [4]: [w_warehouse_name#7, i_item_id#10, sum(CASE WHEN (d_date#14 < 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#21 AS inv_before#23, sum(CASE WHEN (d_date#14 >= 2000-03-11) THEN inv_quantity_on_hand#3 ELSE 0 END)#22 AS inv_after#24]

(26) Filter [codegen id : 5]
Input [4]: [w_warehouse_name#7, i_item_id#10, inv_before#23, inv_after#24]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TakeOrderedAndProject [w_warehouse_name,i_item_id,inv_before,inv_after]
WholeStageCodegen (5)
Filter [inv_before,inv_after]
HashAggregate [w_warehouse_name,i_item_id,sum,sum] [sum(CASE WHEN (d_date < 11027) THEN inv_quantity_on_hand ELSE 0 END),sum(CASE WHEN (d_date >= 11027) THEN inv_quantity_on_hand ELSE 0 END),inv_before,inv_after,sum,sum]
HashAggregate [w_warehouse_name,i_item_id,sum,sum] [sum(CASE WHEN (d_date < 2000-03-11) THEN inv_quantity_on_hand ELSE 0 END),sum(CASE WHEN (d_date >= 2000-03-11) THEN inv_quantity_on_hand ELSE 0 END),inv_before,inv_after,sum,sum]
InputAdapter
Exchange [w_warehouse_name,i_item_id] #1
WholeStageCodegen (4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Input [2]: [d_date_sk#17, d_date#18]

(23) Filter [codegen id : 6]
Input [2]: [d_date_sk#17, d_date#18]
Condition : (((isnotnull(d_date#18) AND (d_date#18 >= 10997)) AND (d_date#18 <= 11057)) AND isnotnull(d_date_sk#17))
Condition : (((isnotnull(d_date#18) AND (d_date#18 >= 2000-02-10)) AND (d_date#18 <= 2000-04-10)) AND isnotnull(d_date_sk#17))

(24) BroadcastExchange
Input [2]: [d_date_sk#17, d_date#18]
Expand Down Expand Up @@ -183,7 +183,7 @@ Input [7]: [cs_warehouse_sk#1, cs_sales_price#4, cr_refunded_cash#10, i_item_id#
(33) HashAggregate [codegen id : 8]
Input [5]: [cs_sales_price#4, cr_refunded_cash#10, w_state#21, i_item_id#14, d_date#18]
Keys [2]: [w_state#21, i_item_id#14]
Functions [2]: [partial_sum(CASE WHEN (d_date#18 < 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END), partial_sum(CASE WHEN (d_date#18 >= 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)]
Functions [2]: [partial_sum(CASE WHEN (d_date#18 < 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END), partial_sum(CASE WHEN (d_date#18 >= 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)]
Aggregate Attributes [4]: [sum#23, isEmpty#24, sum#25, isEmpty#26]
Results [6]: [w_state#21, i_item_id#14, sum#27, isEmpty#28, sum#29, isEmpty#30]

Expand All @@ -194,9 +194,9 @@ Arguments: hashpartitioning(w_state#21, i_item_id#14, 5), ENSURE_REQUIREMENTS, [
(35) HashAggregate [codegen id : 9]
Input [6]: [w_state#21, i_item_id#14, sum#27, isEmpty#28, sum#29, isEmpty#30]
Keys [2]: [w_state#21, i_item_id#14]
Functions [2]: [sum(CASE WHEN (d_date#18 < 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END), sum(CASE WHEN (d_date#18 >= 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#18 < 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#32, sum(CASE WHEN (d_date#18 >= 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#33]
Results [4]: [w_state#21, i_item_id#14, sum(CASE WHEN (d_date#18 < 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#32 AS sales_before#34, sum(CASE WHEN (d_date#18 >= 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#33 AS sales_after#35]
Functions [2]: [sum(CASE WHEN (d_date#18 < 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END), sum(CASE WHEN (d_date#18 >= 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)]
Aggregate Attributes [2]: [sum(CASE WHEN (d_date#18 < 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#32, sum(CASE WHEN (d_date#18 >= 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#33]
Results [4]: [w_state#21, i_item_id#14, sum(CASE WHEN (d_date#18 < 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#32 AS sales_before#34, sum(CASE WHEN (d_date#18 >= 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price#4 as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash#10 as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END)#33 AS sales_after#35]

(36) TakeOrderedAndProject
Input [4]: [w_state#21, i_item_id#14, sales_before#34, sales_after#35]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TakeOrderedAndProject [w_state,i_item_id,sales_before,sales_after]
WholeStageCodegen (9)
HashAggregate [w_state,i_item_id,sum,isEmpty,sum,isEmpty] [sum(CASE WHEN (d_date < 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END),sum(CASE WHEN (d_date >= 11027) THEN CheckOverflow((promote_precision(cast(cs_sales_price as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END),sales_before,sales_after,sum,isEmpty,sum,isEmpty]
HashAggregate [w_state,i_item_id,sum,isEmpty,sum,isEmpty] [sum(CASE WHEN (d_date < 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END),sum(CASE WHEN (d_date >= 2000-03-11) THEN CheckOverflow((promote_precision(cast(cs_sales_price as decimal(13,2))) - promote_precision(cast(coalesce(cast(cr_refunded_cash as decimal(12,2)), 0.00) as decimal(13,2)))), DecimalType(13,2), true) ELSE 0.00 END),sales_before,sales_after,sum,isEmpty,sum,isEmpty]
InputAdapter
Exchange [w_state,i_item_id] #1
WholeStageCodegen (8)
Expand Down
Loading