Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public String getStringValue() {

@Override
public String toSql() {
return toString();
return String.format("'%s'", toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public double getDouble() {

@Override
public String toSql() {
return toString();
return String.format("'%s'", toString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ public void testDateTypeDateTimeArithmeticFunctions() {
VarcharLiteral format = new VarcharLiteral("%Y-%m-%d");

String[] answer = {
"2000-01-30", "1999-12-01", "2029-12-31", "1969-12-31",
"2002-06-30", "1997-06-30", "2000-07-28", "1999-06-04",
"2000-01-30", "1999-12-01",
"'2000-01-30'", "'1999-12-01'", "'2029-12-31'", "'1969-12-31'",
"'2002-06-30'", "'1997-06-30'", "'2000-07-28'", "'1999-06-04'",
"'2000-01-30'", "'1999-12-01'",
"1999", "4", "12", "6", "31", "365", "31",
"'1999-12-31'", "1999-12-27", "1999-12-31"
"'1999-12-31'", "'1999-12-27'", "'1999-12-31'"
};
int answerIdx = 0;

Expand Down Expand Up @@ -348,12 +348,12 @@ public void testDateTimeTypeDateTimeArithmeticFunctions() {
VarcharLiteral format = new VarcharLiteral("%Y-%m-%d");

String[] answer = {
"2000-01-30 23:59:59", "1999-12-01 23:59:59", "2029-12-31 23:59:59", "1969-12-31 23:59:59",
"2002-06-30 23:59:59", "1997-06-30 23:59:59", "2000-01-30 23:59:59", "1999-12-01 23:59:59",
"2000-01-02 05:59:59", "1999-12-30 17:59:59", "2000-01-01 00:29:59",
"1999-12-31 23:29:59", "2000-01-01 00:00:29", "1999-12-31 23:59:29",
"'2000-01-30 23:59:59'", "'1999-12-01 23:59:59'", "'2029-12-31 23:59:59'", "'1969-12-31 23:59:59'",
"'2002-06-30 23:59:59'", "'1997-06-30 23:59:59'", "'2000-01-30 23:59:59'", "'1999-12-01 23:59:59'",
"'2000-01-02 05:59:59'", "'1999-12-30 17:59:59'", "'2000-01-01 00:29:59'",
"'1999-12-31 23:29:59'", "'2000-01-01 00:00:29'", "'1999-12-31 23:59:29'",
"1999", "4", "12", "6", "31", "365", "31", "23", "59", "59",
"'1999-12-31'", "1999-12-27", "1999-12-31", "1999-12-31", "730484", "1999-12-31"
"'1999-12-31'", "'1999-12-27'", "'1999-12-31'", "'1999-12-31'", "730484", "'1999-12-31'"
};
int answerIdx = 0;

Expand Down Expand Up @@ -403,10 +403,10 @@ public void testDateV2TypeDateTimeArithmeticFunctions() {
VarcharLiteral format = new VarcharLiteral("%Y-%m-%d");

String[] answer = {
"2000-01-30", "1999-12-01", "2029-12-31", "1969-12-31",
"2002-06-30", "1997-06-30", "2000-01-30", "1999-12-01",
"'2000-01-30'", "'1999-12-01'", "'2029-12-31'", "'1969-12-31'",
"'2002-06-30'", "'1997-06-30'", "'2000-01-30'", "'1999-12-01'",
"1999", "4", "12", "6", "31", "365", "31",
"'1999-12-31'", "1999-12-27", "1999-12-31"
"'1999-12-31'", "'1999-12-27'", "'1999-12-31'"
};
int answerIdx = 0;

Expand Down Expand Up @@ -440,12 +440,12 @@ public void testDateTimeV2TypeDateTimeArithmeticFunctions() {
VarcharLiteral format = new VarcharLiteral("%Y-%m-%d");

String[] answer = {
"2000-01-30 23:59:59", "1999-12-01 23:59:59", "2029-12-31 23:59:59", "1969-12-31 23:59:59",
"2002-06-30 23:59:59", "1997-06-30 23:59:59", "2000-01-30 23:59:59", "1999-12-01 23:59:59",
"2000-01-02 05:59:59", "1999-12-30 17:59:59", "2000-01-01 00:29:59",
"1999-12-31 23:29:59", "2000-01-01 00:00:29", "1999-12-31 23:59:29", "1999-12-31 23:59:59",
"'2000-01-30 23:59:59'", "'1999-12-01 23:59:59'", "'2029-12-31 23:59:59'", "'1969-12-31 23:59:59'",
"'2002-06-30 23:59:59'", "'1997-06-30 23:59:59'", "'2000-01-30 23:59:59'", "'1999-12-01 23:59:59'",
"'2000-01-02 05:59:59'", "'1999-12-30 17:59:59'", "'2000-01-01 00:29:59'",
"'1999-12-31 23:29:59'", "'2000-01-01 00:00:29'", "'1999-12-31 23:59:29'", "'1999-12-31 23:59:59'",
"1999", "4", "12", "6", "31", "365", "31", "23", "59", "59",
"'1999-12-31'", "1999-12-27", "1999-12-31", "1999-12-31", "730484", "1999-12-31", "1999-12-31"
"'1999-12-31'", "'1999-12-27'", "'1999-12-31'", "'1999-12-31'", "730484", "'1999-12-31'", "'1999-12-31'"
};
int answerIdx = 0;

Expand Down Expand Up @@ -528,14 +528,14 @@ public void testDateTrunc() {
String[] tags = {"year", "month", "day", "hour", "minute", "second"};

String[] answer = {
"2001-01-01 00:00:00", "2001-01-01 00:00:00", "2001-12-01 00:00:00", "2001-12-01 00:00:00",
"2001-12-31 00:00:00", "2001-12-31 00:00:00", "2001-12-31 01:00:00", "2001-12-31 01:00:00",
"2001-12-31 01:01:00", "2001-12-31 01:01:00", "2001-12-31 01:01:01", "2001-12-31 01:01:01",
"2001-01-01 00:00:00", "2001-01-01 00:00:00", "2001-01-01 00:00:00",
"2001-04-01 00:00:00", "2001-04-01 00:00:00", "2001-04-01 00:00:00",
"2001-07-01 00:00:00", "2001-07-01 00:00:00", "2001-07-01 00:00:00",
"2001-10-01 00:00:00", "2001-10-01 00:00:00", "2001-10-01 00:00:00",
"2001-01-15 00:00:00", "2001-02-12 00:00:00", "2001-03-12 00:00:00",
"'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'", "'2001-12-01 00:00:00'", "'2001-12-01 00:00:00'",
"'2001-12-31 00:00:00'", "'2001-12-31 00:00:00'", "'2001-12-31 01:00:00'", "'2001-12-31 01:00:00'",
"'2001-12-31 01:01:00'", "'2001-12-31 01:01:00'", "'2001-12-31 01:01:01'", "'2001-12-31 01:01:01'",
"'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'", "'2001-01-01 00:00:00'",
"'2001-04-01 00:00:00'", "'2001-04-01 00:00:00'", "'2001-04-01 00:00:00'",
"'2001-07-01 00:00:00'", "'2001-07-01 00:00:00'", "'2001-07-01 00:00:00'",
"'2001-10-01 00:00:00'", "'2001-10-01 00:00:00'", "'2001-10-01 00:00:00'",
"'2001-01-15 00:00:00'", "'2001-02-12 00:00:00'", "'2001-03-12 00:00:00'",
};
int answerIdx = 0;

Expand All @@ -561,7 +561,7 @@ public void testDateTrunc() {
@Test
public void testDateConstructFunction() {
String[] answer = {
"2001-07-19", "6411-08-17", "0000-01-01", "'1977-06-03 17:57:24'",
"'2001-07-19'", "'6411-08-17'", "'0000-01-01'", "'1977-06-03 17:57:24'",
"'1977-06-03'", "1008909293", "1008864000"
};
int answerIdx = 0;
Expand Down Expand Up @@ -594,7 +594,7 @@ public void testDateConstructFunction() {

@Test
public void testFoldNestedExpression() {
assertRewriteExpression("makedate(year('2010-04-10'), dayofyear('2010-04-11'))", "2010-04-11");
assertRewriteExpression("makedate(year('2010-04-10'), dayofyear('2010-04-11'))", "'2010-04-11'");
assertRewriteExpression("null in ('d', null)", "NULL");
assertRewriteExpression("null not in ('d', null)", "NULL");
assertRewriteExpression("'a' in ('d', null)", "NULL");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void testSql() {
.rewrite()
.matches(
logicalFilter()
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a < 2023-06-16 00:00:00)")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a < '2023-06-16 00:00:00')")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(b < 111.12)")))
);

Expand All @@ -66,7 +66,7 @@ void testSql() {
.rewrite()
.matches(
logicalFilter()
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a <= 2023-06-16 00:00:00)")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a <= '2023-06-16 00:00:00')")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(b <= 111.11)")))
);

Expand All @@ -82,7 +82,7 @@ void testSql() {
.rewrite()
.matches(
logicalFilter()
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a > 2023-06-16 00:00:00)")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a > '2023-06-16 00:00:00')")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(b > 111.11)")))
);

Expand All @@ -91,7 +91,7 @@ void testSql() {
.rewrite()
.matches(
logicalFilter()
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a >= 2023-06-16 00:00:00)")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(a >= '2023-06-16 00:00:00')")))
.when(f -> f.getConjuncts().stream().anyMatch(e -> e.toSql().equals("(b >= 111.12)")))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
--------PhysicalDistribute
----------hashAgg[LOCAL]
------------PhysicalProject
--------------hashJoin[INNER_JOIN] hashCondition=((store_returns.sr_returned_date_sk = date_dim.d_date_sk))otherCondition=()
--------------hashJoin[INNER_JOIN](store_returns.sr_returned_date_sk = date_dim.d_date_sk)
----------------PhysicalProject
------------------PhysicalOlapScan[store_returns]
----------------PhysicalDistribute
Expand All @@ -31,7 +31,7 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
------------------------PhysicalCteConsumer ( cteId=CTEId#0 )
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------filter((cast(s_state as VARCHAR(*)) = 'SD'))
--------------------------filter((store.s_state = 'SD'))
----------------------------PhysicalOlapScan[store]
------------------hashAgg[GLOBAL]
--------------------PhysicalDistribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ PhysicalResultSink
------------------------------------------------PhysicalOlapScan[date_dim]
------------------------------------PhysicalDistribute
--------------------------------------hashJoin[INNER_JOIN](c.c_current_addr_sk = ca.ca_address_sk)
----------------------------------------PhysicalProject
------------------------------------------PhysicalOlapScan[customer]
----------------------------------------PhysicalDistribute
------------------------------------------PhysicalProject
--------------------------------------------PhysicalOlapScan[customer]
----------------------------------------PhysicalDistribute
------------------------------------------PhysicalProject
--------------------------------------------filter(ca_county IN ('Storey County', 'Marquette County', 'Warren County', 'Cochran County', 'Kandiyohi County'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN](customer.c_customer_sk = store_sales.ss_customer_sk)
------------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = date_dim.d_date_sk)
--------------------PhysicalProject
----------------------filter('s' IN ('s', 'w'))
------------------------PhysicalOlapScan[store_sales]
--------------------PhysicalDistribute
------------------PhysicalDistribute
--------------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = date_dim.d_date_sk)
----------------------PhysicalProject
------------------------PhysicalOlapScan[store_sales]
----------------------PhysicalDistribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PhysicalResultSink
--------------------------------PhysicalOlapScan[web_sales]
------------------------------PhysicalDistribute
--------------------------------PhysicalProject
----------------------------------filter((date_dim.d_date <= 1998-05-06)(date_dim.d_date >= 1998-04-06))
----------------------------------filter((date_dim.d_date <= '1998-05-06')(date_dim.d_date >= '1998-04-06'))
------------------------------------PhysicalOlapScan[date_dim]
--------------------------PhysicalDistribute
----------------------------PhysicalProject
Expand Down
52 changes: 34 additions & 18 deletions regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query14.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,48 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
----------PhysicalDistribute
------------PhysicalProject
--------------hashJoin[INNER_JOIN](store_sales.ss_item_sk = iss.i_item_sk)
----------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = d1.d_date_sk)
------------------PhysicalProject
--------------------PhysicalOlapScan[store_sales]
------------------PhysicalDistribute
----------------PhysicalDistribute
------------------hashJoin[INNER_JOIN](store_sales.ss_sold_date_sk = d1.d_date_sk)
--------------------PhysicalProject
----------------------filter((d1.d_year <= 2002)(d1.d_year >= 2000))
------------------------PhysicalOlapScan[date_dim]
----------------------PhysicalOlapScan[store_sales]
--------------------PhysicalDistribute
----------------------PhysicalProject
------------------------filter((d1.d_year <= 2002)(d1.d_year >= 2000))
--------------------------PhysicalOlapScan[date_dim]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------PhysicalOlapScan[item]
----------PhysicalDistribute
------------PhysicalProject
--------------hashJoin[INNER_JOIN](catalog_sales.cs_item_sk = ics.i_item_sk)
----------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = d2.d_date_sk)
----------------PhysicalDistribute
------------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = d2.d_date_sk)
--------------------PhysicalProject
----------------------PhysicalOlapScan[catalog_sales]
--------------------PhysicalDistribute
----------------------PhysicalProject
------------------------filter((d2.d_year >= 2000)(d2.d_year <= 2002))
--------------------------PhysicalOlapScan[date_dim]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN](web_sales.ws_item_sk = iws.i_item_sk)
----------------------hashJoin[INNER_JOIN](web_sales.ws_sold_date_sk = d3.d_date_sk)
------------------------PhysicalProject
--------------------------PhysicalOlapScan[web_sales]
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------filter((d3.d_year <= 2002)(d3.d_year >= 2000))
------------------------------PhysicalOlapScan[date_dim]
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------PhysicalOlapScan[item]
--------------------PhysicalOlapScan[item]
----------PhysicalDistribute
------------PhysicalProject
--------------hashJoin[INNER_JOIN](web_sales.ws_item_sk = iws.i_item_sk)
----------------PhysicalDistribute
------------------hashJoin[INNER_JOIN](web_sales.ws_sold_date_sk = d3.d_date_sk)
--------------------PhysicalProject
----------------------PhysicalOlapScan[web_sales]
--------------------PhysicalDistribute
----------------------PhysicalProject
------------------------filter((d3.d_year <= 2002)(d3.d_year >= 2000))
--------------------------PhysicalOlapScan[date_dim]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------PhysicalOlapScan[item]
--------PhysicalDistribute
----------PhysicalProject
------------PhysicalOlapScan[item]
--PhysicalCteAnchor ( cteId=CTEId#1 )
----PhysicalCteProducer ( cteId=CTEId#1 )
------hashAgg[GLOBAL]
Expand Down
45 changes: 23 additions & 22 deletions regression-test/data/nereids_tpcds_shape_sf100_p0/shape/query15.out
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !ds_shape_15 --
PhysicalTopN
--PhysicalDistribute
----PhysicalTopN
------hashAgg[GLOBAL]
--------PhysicalDistribute
----------hashAgg[LOCAL]
------------PhysicalProject
--------------hashJoin[INNER_JOIN](catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)((substring(ca_zip, 1, 5) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792') OR ca_state IN ('CA', 'WA', 'GA')) OR (catalog_sales.cs_sales_price > 500.00))
----------------PhysicalDistribute
------------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)
--------------------PhysicalProject
----------------------PhysicalOlapScan[catalog_sales]
--------------------PhysicalDistribute
PhysicalResultSink
--PhysicalTopN
----PhysicalDistribute
------PhysicalTopN
--------hashAgg[GLOBAL]
----------PhysicalDistribute
------------hashAgg[LOCAL]
--------------PhysicalProject
----------------hashJoin[INNER_JOIN](catalog_sales.cs_bill_customer_sk = customer.c_customer_sk)((substring(ca_zip, 1, 5) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792') OR ca_state IN ('CA', 'WA', 'GA')) OR (catalog_sales.cs_sales_price > 500.00))
------------------PhysicalDistribute
--------------------hashJoin[INNER_JOIN](catalog_sales.cs_sold_date_sk = date_dim.d_date_sk)
----------------------PhysicalProject
------------------------filter((date_dim.d_qoy = 1)(date_dim.d_year = 2001))
--------------------------PhysicalOlapScan[date_dim]
----------------PhysicalDistribute
------------------PhysicalProject
--------------------hashJoin[INNER_JOIN](customer.c_current_addr_sk = customer_address.ca_address_sk)
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------PhysicalOlapScan[customer]
------------------------PhysicalOlapScan[catalog_sales]
----------------------PhysicalDistribute
------------------------PhysicalProject
--------------------------PhysicalOlapScan[customer_address]
--------------------------filter((date_dim.d_qoy = 1)(date_dim.d_year = 2001))
----------------------------PhysicalOlapScan[date_dim]
------------------PhysicalDistribute
--------------------PhysicalProject
----------------------hashJoin[INNER_JOIN](customer.c_current_addr_sk = customer_address.ca_address_sk)
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[customer]
------------------------PhysicalDistribute
--------------------------PhysicalProject
----------------------------PhysicalOlapScan[customer_address]

Loading