Skip to content

Commit

Permalink
Upper-case SQL keywords in TestMergeWindows' queries
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejgrzybek authored and martint committed Oct 13, 2016
1 parent 236b1de commit 62780d1
Showing 1 changed file with 62 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public TestMergeWindows()
@Test
public void testMergeableWindowsAllOptimizers()
{
@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_quantity_A, " +
"sum(quantity) over (partition by orderkey order by shipdate rows between UNBOUNDED preceding and CURRENT ROW) sum_quantity_B, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_A, " +
"SUM(quantity) OVER (PARTITION BY orderkey ORDER BY shipdate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_B, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

PlanMatchPattern pattern =
anyTree(
Expand All @@ -133,11 +133,11 @@ public void testMergeableWindowsAllOptimizers()
@Test
public void testIdenticalWindowSpecificationsABA()
{
@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_quantity_A, " +
"sum(quantity) over (partition by orderkey order by shipdate rows between UNBOUNDED preceding and CURRENT ROW) sum_quantity_B, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_A, " +
"SUM(quantity) OVER (PARTITION BY orderkey ORDER BY shipdate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_B, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand All @@ -152,11 +152,11 @@ public void testIdenticalWindowSpecificationsABA()
@Test
public void testIdenticalWindowSpecificationsABcpA()
{
@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_quantity_A, " +
"lag(quantity, 1, 0.0) over (partition by orderkey order by shipdate rows between UNBOUNDED preceding and CURRENT ROW) sum_quantity_B, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_A, " +
"LAG(quantity, 1, 0.0) OVER (PARTITION BY orderkey ORDER BY shipdate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_B, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand All @@ -171,11 +171,11 @@ public void testIdenticalWindowSpecificationsABcpA()
@Test
public void testIdenticalWindowSpecificationsAAcpA()
{
@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_quantity_A, " +
"lag(quantity, 1, 0.0) over (partition by suppkey order by orderkey rows between UNBOUNDED preceding and CURRENT ROW) sum_quantity_B, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_A, " +
"LAG(quantity, 1, 0.0) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_B, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand All @@ -201,11 +201,11 @@ public void testIdenticalWindowSpecificationsDefaultFrame()
ImmutableList.of(new SortItem(new SymbolReference("shipdate"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)),
Optional.empty());

@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey), " +
"sum(quantity) over (partition by orderkey order by shipdate), " +
"sum(discount) over (partition by suppkey order by orderkey) " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION By suppkey ORDER BY orderkey), " +
"SUM(quantity) OVER (PARTITION BY orderkey ORDER BY shipdate), " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey) " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand Down Expand Up @@ -240,11 +240,11 @@ public void testMergeDifferentFrames()
ImmutableList.of(new SortItem(new SymbolReference("orderkey"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)),
Optional.of(frameD));

@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_quantity_C, " +
"avg(quantity) over (partition by suppkey order by orderkey rows between current row and unbounded following) avg_quantity_D, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_C " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_C, " +
"AVG(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) avg_quantity_D, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_C " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand Down Expand Up @@ -273,11 +273,11 @@ public void testMergeDifferentFramesWithDefault()
ImmutableList.of(new SortItem(new SymbolReference("orderkey"), SortItem.Ordering.ASCENDING, SortItem.NullOrdering.UNDEFINED)),
Optional.of(frameD));

@Language("SQL") String sql = "select " +
"sum(quantity) over (partition by suppkey order by orderkey) sum_quantity_C, " +
"avg(quantity) over (partition by suppkey order by orderkey rows between current row and unbounded following) avg_quantity_D, " +
"sum(discount) over (partition by suppkey order by orderkey) sum_discount_C " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey) sum_quantity_C, " +
"AVG(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) avg_quantity_D, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey) sum_discount_C " +
"FROM lineitem";

assertUnitPlan(sql,
anyTree(
Expand All @@ -291,19 +291,19 @@ public void testMergeDifferentFramesWithDefault()
@Test
public void testNotMergeAcrossJoinBranches()
{
@Language("SQL") String sql = "with foo as (" +
"select " +
@Language("SQL") String sql = "WITH foo AS (" +
"SELECT " +
"suppkey, orderkey, partkey, " +
"sum(discount) over (partition by orderkey order by shipdate rows between UNBOUNDED preceding and CURRENT ROW) a " +
"from lineitem where (partkey = 272 or partkey = 273) and suppkey > 50 " +
"SUM(discount) OVER (PARTITION BY orderkey ORDER BY shipdate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) a " +
"FROM lineitem WHERE (partkey = 272 OR partkey = 273) AND suppkey > 50 " +
"), " +
"bar as ( " +
"select " +
"bar AS ( " +
"SELECT " +
"suppkey, orderkey, partkey, " +
"avg(quantity) over (partition by orderkey order by shipdate rows between UNBOUNDED preceding and CURRENT ROW) b " +
"from lineitem where (partkey = 272 or partkey = 273) and suppkey > 50 " +
"AVG(quantity) OVER (PARTITION BY orderkey ORDER BY shipdate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) b " +
"FROM lineitem WHERE (partkey = 272 OR partkey = 273) AND suppkey > 50 " +
")" +
"select * from foo, bar where foo.a = bar.b";
"SELECT * FROM foo, bar WHERE foo.a = bar.b";

assertUnitPlan(sql,
anyTree(
Expand All @@ -319,10 +319,10 @@ public void testNotMergeAcrossJoinBranches()
@Test
public void testNotMergeDifferentPartition()
{
@Language("SQL") String sql = "select " +
"sum(extendedprice) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_extendedprice_A, " +
"sum(quantity) over (partition by quantity order by orderkey rows between unbounded preceding and current row) sum_quantity_C " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(extendedprice) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_extendedprice_A, " +
"SUM(quantity) over (PARTITION BY quantity ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_C " +
"FROM lineitem";

Window windowC = new Window(
ImmutableList.of(new SymbolReference("quantity")),
Expand All @@ -341,10 +341,10 @@ public void testNotMergeDifferentPartition()
@Test
public void testNotMergeDifferentOrderBy()
{
@Language("SQL") String sql = "select " +
"sum(extendedprice) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_extendedprice_A, " +
"sum(quantity) over (partition by suppkey order by quantity rows between unbounded preceding and current row) sum_quantity_C " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(extendedprice) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_extendedprice_A, " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY quantity ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_C " +
"FROM lineitem";

Window windowC = new Window(
ImmutableList.of(new SymbolReference("suppkey")),
Expand All @@ -363,11 +363,11 @@ public void testNotMergeDifferentOrderBy()
@Test
public void testNotMergeDifferentOrdering()
{
@Language("SQL") String sql = "select " +
"sum(extendedprice) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_extendedprice_A, " +
"sum(quantity) over (partition by suppkey order by orderkey desc rows between unbounded preceding and current row) sum_quantity_C, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(extendedprice) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_extendedprice_A, " +
"SUM(quantity) over (PARTITION BY suppkey ORDER BY orderkey DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_C, " +
"SUM(discount) over (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

Window windowC = new Window(
ImmutableList.of(new SymbolReference("suppkey")),
Expand All @@ -387,11 +387,11 @@ public void testNotMergeDifferentOrdering()
@Test
public void testNotMergeDifferentNullOrdering()
{
@Language("SQL") String sql = "select " +
"sum(extendedprice) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_extendedprice_A, " +
"sum(quantity) over (partition by suppkey order by orderkey nulls first rows between unbounded preceding and current row) sum_quantity_C, " +
"sum(discount) over (partition by suppkey order by orderkey rows between unbounded preceding and current row) sum_discount_A " +
"from lineitem";
@Language("SQL") String sql = "SELECT " +
"SUM(extendedprice) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_extendedprice_A, " +
"SUM(quantity) OVER (PARTITION BY suppkey ORDER BY orderkey NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_quantity_C, " +
"SUM(discount) OVER (PARTITION BY suppkey ORDER BY orderkey ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) sum_discount_A " +
"FROM lineitem";

Window windowC = new Window(
ImmutableList.of(new SymbolReference("suppkey")),
Expand Down

0 comments on commit 62780d1

Please sign in to comment.