spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [2/2] spark git commit: [SPARK-16590][SQL] Improve LogicalPlanToSQLSuite to check generated SQL directly
Date Tue, 19 Jul 2016 00:17:42 GMT
[SPARK-16590][SQL] Improve LogicalPlanToSQLSuite to check generated SQL directly

## What changes were proposed in this pull request?

This PR improves `LogicalPlanToSQLSuite` to check the generated SQL directly by **structure**. So far, `LogicalPlanToSQLSuite` relies on  `checkHiveQl` to ensure the **successful SQL generation** and **answer equality**. However, it does not guarantee the generated SQL is the same or will not be changed unnoticeably.

## How was this patch tested?

Pass the Jenkins. This is only a testsuite change.

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #14235 from dongjoon-hyun/SPARK-16590.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/ea78edb8
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/ea78edb8
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/ea78edb8

Branch: refs/heads/master
Commit: ea78edb80bf46e925d53e2aec29666c4eeb66188
Parents: 75f0efe
Author: Dongjoon Hyun <dongjoon@apache.org>
Authored: Mon Jul 18 17:17:37 2016 -0700
Committer: Reynold Xin <rxin@databricks.com>
Committed: Mon Jul 18 17:17:37 2016 -0700

----------------------------------------------------------------------
 sql/hive/src/test/resources/sqlgen/agg1.sql     |   4 +
 sql/hive/src/test/resources/sqlgen/agg2.sql     |   4 +
 sql/hive/src/test/resources/sqlgen/agg3.sql     |   4 +
 .../sqlgen/aggregate_functions_and_window.sql   |   4 +
 sql/hive/src/test/resources/sqlgen/case.sql     |   4 +
 .../test/resources/sqlgen/case_with_else.sql    |   4 +
 .../src/test/resources/sqlgen/case_with_key.sql |   4 +
 .../resources/sqlgen/case_with_key_and_else.sql |   4 +
 .../src/test/resources/sqlgen/cluster_by.sql    |   4 +
 .../sqlgen/data_source_json_parquet_t0.sql      |   4 +
 .../sqlgen/data_source_orc_parquet_t0.sql       |   4 +
 .../sqlgen/data_source_parquet_parquet_t0.sql   |   4 +
 .../resources/sqlgen/distinct_aggregation.sql   |   4 +
 .../src/test/resources/sqlgen/distribute_by.sql |   4 +
 .../sqlgen/distribute_by_with_sort_by.sql       |   4 +
 sql/hive/src/test/resources/sqlgen/except.sql   |   4 +
 .../resources/sqlgen/filter_after_subquery.sql  |   4 +
 .../resources/sqlgen/generate_with_other_1.sql  |   8 +
 .../resources/sqlgen/generate_with_other_2.sql  |  10 +
 .../sqlgen/generator_in_lateral_view_1.sql      |   4 +
 .../sqlgen/generator_in_lateral_view_2.sql      |   4 +
 .../sqlgen/generator_non_referenced_table_1.sql |   4 +
 .../sqlgen/generator_non_referenced_table_2.sql |   4 +
 .../resources/sqlgen/generator_non_udtf_1.sql   |   4 +
 .../resources/sqlgen/generator_non_udtf_2.sql   |   4 +
 .../sqlgen/generator_referenced_table_1.sql     |   4 +
 .../sqlgen/generator_referenced_table_2.sql     |   4 +
 .../sqlgen/generator_with_ambiguous_names_1.sql |   6 +
 .../sqlgen/generator_with_ambiguous_names_2.sql |   6 +
 .../sqlgen/generator_without_from_1.sql         |   4 +
 .../sqlgen/generator_without_from_2.sql         |   4 +
 .../test/resources/sqlgen/grouping_sets_1.sql   |   6 +
 .../test/resources/sqlgen/grouping_sets_2_1.sql |   4 +
 .../test/resources/sqlgen/grouping_sets_2_2.sql |   4 +
 .../test/resources/sqlgen/grouping_sets_2_3.sql |   4 +
 .../test/resources/sqlgen/grouping_sets_2_4.sql |   4 +
 .../test/resources/sqlgen/grouping_sets_2_5.sql |   5 +
 sql/hive/src/test/resources/sqlgen/in.sql       |   4 +
 .../src/test/resources/sqlgen/intersect.sql     |   4 +
 .../src/test/resources/sqlgen/join_2_tables.sql |   7 +
 .../resources/sqlgen/json_tuple_generator_1.sql |   6 +
 .../resources/sqlgen/json_tuple_generator_2.sql |   6 +
 .../test/resources/sqlgen/multi_distinct.sql    |   4 +
 .../nested_generator_in_lateral_view_1.sql      |   7 +
 .../nested_generator_in_lateral_view_2.sql      |   7 +
 sql/hive/src/test/resources/sqlgen/not_in.sql   |   4 +
 sql/hive/src/test/resources/sqlgen/not_like.sql |   4 +
 .../sqlgen/regular_expressions_and_window.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_1_1.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_1_2.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_2_1.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_2_2.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_3_1.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_3_2.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_4_1.sql   |   5 +
 .../test/resources/sqlgen/rollup_cube_4_2.sql   |   5 +
 .../test/resources/sqlgen/rollup_cube_5_1.sql   |   6 +
 .../test/resources/sqlgen/rollup_cube_5_2.sql   |   6 +
 .../test/resources/sqlgen/rollup_cube_6_1.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_6_2.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_6_3.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_6_4.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_6_5.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_6_6.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_7_1.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_7_2.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_7_3.sql   |   4 +
 .../test/resources/sqlgen/rollup_cube_8_1.sql   |   6 +
 .../test/resources/sqlgen/rollup_cube_8_2.sql   |   6 +
 .../test/resources/sqlgen/rollup_cube_9_1.sql   |   8 +
 .../test/resources/sqlgen/rollup_cube_9_2.sql   |   8 +
 .../sqlgen/script_transformation_1.sql          |   4 +
 .../sqlgen/script_transformation_2.sql          |   4 +
 .../sqlgen/script_transformation_alias_list.sql |   4 +
 ...ript_transformation_alias_list_with_type.sql |   6 +
 ...cript_transformation_row_format_multiple.sql |   8 +
 .../script_transformation_row_format_one.sql    |   6 +
 .../script_transformation_row_format_serde.sql  |  10 +
 ..._transformation_row_format_without_serde.sql |   8 +
 .../test/resources/sqlgen/select_distinct.sql   |   4 +
 .../test/resources/sqlgen/select_orc_table.sql  |   4 +
 .../resources/sqlgen/select_parquet_table.sql   |   4 +
 .../src/test/resources/sqlgen/self_join.sql     |   4 +
 .../sqlgen/self_join_with_group_by.sql          |   4 +
 .../resources/sqlgen/sort_by_after_having.sql   |   4 +
 .../src/test/resources/sqlgen/tablesample_1.sql |   4 +
 .../src/test/resources/sqlgen/tablesample_2.sql |   4 +
 .../src/test/resources/sqlgen/tablesample_3.sql |   4 +
 .../src/test/resources/sqlgen/tablesample_4.sql |   4 +
 .../src/test/resources/sqlgen/tablesample_5.sql |   4 +
 .../src/test/resources/sqlgen/tablesample_6.sql |   4 +
 .../test/resources/sqlgen/three_child_union.sql |   6 +
 .../src/test/resources/sqlgen/type_widening.sql |   4 +
 .../test/resources/sqlgen/union_distinct.sql    |   4 +
 .../test/resources/sqlgen/window_basic_1.sql    |   4 +
 .../test/resources/sqlgen/window_basic_2.sql    |   5 +
 .../test/resources/sqlgen/window_basic_3.sql    |   5 +
 .../test/resources/sqlgen/window_with_join.sql  |   5 +
 .../window_with_the_same_window_with_agg.sql    |   7 +
 ...dow_with_the_same_window_with_agg_filter.sql |   7 +
 ..._with_the_same_window_with_agg_functions.sql |   6 +
 ...dow_with_the_same_window_with_agg_having.sql |   6 +
 .../sql/catalyst/LogicalPlanToSQLSuite.scala    | 484 +++++++++++++------
 103 files changed, 820 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/agg1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/agg1.sql b/sql/hive/src/test/resources/sqlgen/agg1.sql
new file mode 100644
index 0000000..9953640
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/agg1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT COUNT(value) FROM parquet_t1 GROUP BY key HAVING MAX(key) > 0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `count(value)` FROM (SELECT `gen_attr` FROM (SELECT count(`gen_attr`) AS `gen_attr`, max(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr` HAVING (`gen_attr` > CAST(0 AS BIGINT))) AS gen_subquery_1) AS gen_subquery_2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/agg2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/agg2.sql b/sql/hive/src/test/resources/sqlgen/agg2.sql
new file mode 100644
index 0000000..0caea28
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/agg2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT COUNT(value) FROM parquet_t1 GROUP BY key ORDER BY MAX(key)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `count(value)` FROM (SELECT `gen_attr` FROM (SELECT count(`gen_attr`) AS `gen_attr`, max(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr` ORDER BY `gen_attr` ASC) AS gen_subquery_1) AS gen_subquery_2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/agg3.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/agg3.sql b/sql/hive/src/test/resources/sqlgen/agg3.sql
new file mode 100644
index 0000000..437afa7
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/agg3.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT COUNT(value) FROM parquet_t1 GROUP BY key ORDER BY key, MAX(key)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `count(value)` FROM (SELECT `gen_attr` FROM (SELECT count(`gen_attr`) AS `gen_attr`, `gen_attr` AS `gen_attr`, max(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr` ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1) AS gen_subquery_2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/aggregate_functions_and_window.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/aggregate_functions_and_window.sql b/sql/hive/src/test/resources/sqlgen/aggregate_functions_and_window.sql
new file mode 100644
index 0000000..3a29bcf
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/aggregate_functions_and_window.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT MAX(c) + COUNT(a) OVER () FROM parquet_t2 GROUP BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(max(c) + count(a) OVER (  ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING))` FROM (SELECT (`gen_attr` + `gen_attr`) AS `gen_attr` FROM (SELECT gen_subquery_1.`gen_attr`, gen_subquery_1.`gen_attr`, count(`gen_attr`) OVER (  ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `gen_attr` FROM (SELECT max(`gen_attr`) AS `gen_attr`, `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr`) AS gen_subquery_1) AS gen_subquery_2) AS gen_subquery_3

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/case.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/case.sql b/sql/hive/src/test/resources/sqlgen/case.sql
new file mode 100644
index 0000000..f6a8c32
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/case.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT CASE WHEN id % 2 > 0 THEN 0 WHEN id % 2 = 0 THEN 1 END FROM parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `CASE WHEN ((id % CAST(2 AS BIGINT)) > CAST(0 AS BIGINT)) THEN 0 WHEN ((id % CAST(2 AS BIGINT)) = CAST(0 AS BIGINT)) THEN 1 END` FROM (SELECT CASE WHEN ((`gen_attr` % CAST(2 AS BIGINT)) > CAST(0 AS BIGINT)) THEN 0 WHEN ((`gen_attr` % CAST(2 AS BIGINT)) = CAST(0 AS BIGINT)) THEN 1 END AS `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/case_with_else.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/case_with_else.sql b/sql/hive/src/test/resources/sqlgen/case_with_else.sql
new file mode 100644
index 0000000..8f1595d
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/case_with_else.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT CASE WHEN id % 2 > 0 THEN 0 ELSE 1 END FROM parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `CASE WHEN ((id % CAST(2 AS BIGINT)) > CAST(0 AS BIGINT)) THEN 0 ELSE 1 END` FROM (SELECT CASE WHEN ((`gen_attr` % CAST(2 AS BIGINT)) > CAST(0 AS BIGINT)) THEN 0 ELSE 1 END AS `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/case_with_key.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/case_with_key.sql b/sql/hive/src/test/resources/sqlgen/case_with_key.sql
new file mode 100644
index 0000000..88353e3
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/case_with_key.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT CASE id WHEN 0 THEN 'foo' WHEN 1 THEN 'bar' END FROM parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `CASE WHEN (id = CAST(0 AS BIGINT)) THEN foo WHEN (id = CAST(1 AS BIGINT)) THEN bar END` FROM (SELECT CASE WHEN (`gen_attr` = CAST(0 AS BIGINT)) THEN "foo" WHEN (`gen_attr` = CAST(1 AS BIGINT)) THEN "bar" END AS `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/case_with_key_and_else.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/case_with_key_and_else.sql b/sql/hive/src/test/resources/sqlgen/case_with_key_and_else.sql
new file mode 100644
index 0000000..bc44f25
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/case_with_key_and_else.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT CASE id WHEN 0 THEN 'foo' WHEN 1 THEN 'bar' ELSE 'baz' END FROM parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `CASE WHEN (id = CAST(0 AS BIGINT)) THEN foo WHEN (id = CAST(1 AS BIGINT)) THEN bar ELSE baz END` FROM (SELECT CASE WHEN (`gen_attr` = CAST(0 AS BIGINT)) THEN "foo" WHEN (`gen_attr` = CAST(1 AS BIGINT)) THEN "bar" ELSE "baz" END AS `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/cluster_by.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/cluster_by.sql b/sql/hive/src/test/resources/sqlgen/cluster_by.sql
new file mode 100644
index 0000000..3bc1dfc
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/cluster_by.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM parquet_t0 CLUSTER BY id
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0 CLUSTER BY `gen_attr`) AS parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/data_source_json_parquet_t0.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/data_source_json_parquet_t0.sql b/sql/hive/src/test/resources/sqlgen/data_source_json_parquet_t0.sql
new file mode 100644
index 0000000..a4f46da
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/data_source_json_parquet_t0.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM json_parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`json_parquet_t0`) AS gen_subquery_0) AS json_parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/data_source_orc_parquet_t0.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/data_source_orc_parquet_t0.sql b/sql/hive/src/test/resources/sqlgen/data_source_orc_parquet_t0.sql
new file mode 100644
index 0000000..214dbcf
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/data_source_orc_parquet_t0.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM orc_parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`orc_parquet_t0`) AS gen_subquery_0) AS orc_parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/data_source_parquet_parquet_t0.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/data_source_parquet_parquet_t0.sql b/sql/hive/src/test/resources/sqlgen/data_source_parquet_parquet_t0.sql
new file mode 100644
index 0000000..eccf03e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/data_source_parquet_parquet_t0.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM parquet_parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_parquet_t0`) AS gen_subquery_0) AS parquet_parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/distinct_aggregation.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/distinct_aggregation.sql b/sql/hive/src/test/resources/sqlgen/distinct_aggregation.sql
new file mode 100644
index 0000000..0fa21ad
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/distinct_aggregation.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT COUNT(DISTINCT id) FROM parquet_t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `count(DISTINCT id)` FROM (SELECT count(DISTINCT `gen_attr`) AS `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/distribute_by.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/distribute_by.sql b/sql/hive/src/test/resources/sqlgen/distribute_by.sql
new file mode 100644
index 0000000..75a1a2a
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/distribute_by.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM parquet_t0 DISTRIBUTE BY id
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0 DISTRIBUTE BY `gen_attr`) AS parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/distribute_by_with_sort_by.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/distribute_by_with_sort_by.sql b/sql/hive/src/test/resources/sqlgen/distribute_by_with_sort_by.sql
new file mode 100644
index 0000000..a8e766e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/distribute_by_with_sort_by.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM parquet_t0 DISTRIBUTE BY id SORT BY id
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0 CLUSTER BY `gen_attr`) AS parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/except.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/except.sql b/sql/hive/src/test/resources/sqlgen/except.sql
new file mode 100644
index 0000000..b1c6428
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/except.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT * FROM t0 EXCEPT SELECT * FROM t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM ((SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 ) EXCEPT ( SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_1)) AS t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/filter_after_subquery.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/filter_after_subquery.sql b/sql/hive/src/test/resources/sqlgen/filter_after_subquery.sql
new file mode 100644
index 0000000..0156dff
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/filter_after_subquery.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a FROM (SELECT key + 1 AS a FROM parquet_t1) t WHERE a > 5
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a` FROM (SELECT `gen_attr` FROM (SELECT (`gen_attr` + CAST(1 AS BIGINT)) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t WHERE (`gen_attr` > CAST(5 AS BIGINT))) AS t

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generate_with_other_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generate_with_other_1.sql b/sql/hive/src/test/resources/sqlgen/generate_with_other_1.sql
new file mode 100644
index 0000000..15d23c6
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generate_with_other_1.sql
@@ -0,0 +1,8 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(arr) AS val, id
+FROM parquet_t3
+WHERE id > 2
+ORDER BY val, id
+LIMIT 5
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT gen_subquery_0.`gen_attr`, gen_subquery_0.`gen_attr`, gen_subquery_0.`gen_attr`, gen_subquery_0.`gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 WHERE (`gen_attr` > CAST(2 AS BIGINT))) AS gen_subquery_1 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr` ORDER BY `gen_attr` ASC, `gen_attr` ASC LIMIT 5) AS parquet_t3

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generate_with_other_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generate_with_other_2.sql b/sql/hive/src/test/resources/sqlgen/generate_with_other_2.sql
new file mode 100644
index 0000000..e2b94ce
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generate_with_other_2.sql
@@ -0,0 +1,10 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT val, id
+FROM parquet_t3
+LATERAL VIEW EXPLODE(arr2) exp1 AS nested_array
+LATERAL VIEW EXPLODE(nested_array) exp1 AS val
+WHERE val > 2
+ORDER BY val, id
+LIMIT 5
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr` LATERAL VIEW explode(`gen_attr`) gen_subquery_3 AS `gen_attr` WHERE (`gen_attr` > CAST(2 AS BIGINT)) ORDER BY `gen_attr` ASC, `gen_attr` ASC LIMIT 5) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_1.sql b/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_1.sql
new file mode 100644
index 0000000..c62b895
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT val, id FROM parquet_t3 LATERAL VIEW EXPLODE(arr) exp AS val
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_2.sql b/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_2.sql
new file mode 100644
index 0000000..4c68eef
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_in_lateral_view_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT val, id FROM parquet_t3 LATERAL VIEW OUTER EXPLODE(arr) exp AS val
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW OUTER explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_1.sql b/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_1.sql
new file mode 100644
index 0000000..059c45e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(ARRAY(1,2,3)) FROM t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `col` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 LATERAL VIEW explode(array(1, 2, 3)) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_2.sql b/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_2.sql
new file mode 100644
index 0000000..8f03ded
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_non_referenced_table_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(ARRAY(1,2,3)) AS val FROM t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 LATERAL VIEW explode(array(1, 2, 3)) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_non_udtf_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_non_udtf_1.sql b/sql/hive/src/test/resources/sqlgen/generator_non_udtf_1.sql
new file mode 100644
index 0000000..0bfe380
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_non_udtf_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(arr), id FROM parquet_t3
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `col`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_1 AS `gen_attr`) AS parquet_t3

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_non_udtf_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_non_udtf_2.sql b/sql/hive/src/test/resources/sqlgen/generator_non_udtf_2.sql
new file mode 100644
index 0000000..e4edb68
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_non_udtf_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(arr) AS val, id as a FROM parquet_t3
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `a` FROM (SELECT `gen_attr`, `gen_attr` AS `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_referenced_table_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_referenced_table_1.sql b/sql/hive/src/test/resources/sqlgen/generator_referenced_table_1.sql
new file mode 100644
index 0000000..5cf57f8
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_referenced_table_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(arr) FROM parquet_t3
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `col` FROM (SELECT `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_referenced_table_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_referenced_table_2.sql b/sql/hive/src/test/resources/sqlgen/generator_referenced_table_2.sql
new file mode 100644
index 0000000..ed42894
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_referenced_table_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(arr) AS val FROM parquet_t3
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val` FROM (SELECT `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_1.sql b/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_1.sql
new file mode 100644
index 0000000..5a4aec9
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_1.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT exp.id, parquet_t3.id
+FROM parquet_t3
+LATERAL VIEW EXPLODE(arr) exp AS id
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_2.sql b/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_2.sql
new file mode 100644
index 0000000..3c3e858
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_with_ambiguous_names_2.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT exp.id, parquet_t3.id
+FROM parquet_t3
+LATERAL VIEW OUTER EXPLODE(arr) exp AS id
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW OUTER explode(`gen_attr`) gen_subquery_2 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_without_from_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_without_from_1.sql b/sql/hive/src/test/resources/sqlgen/generator_without_from_1.sql
new file mode 100644
index 0000000..d56e89c
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_without_from_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(ARRAY(1,2,3))
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `col` FROM (SELECT `gen_attr` FROM (SELECT 1) gen_subquery_1 LATERAL VIEW explode(array(1, 2, 3)) gen_subquery_2 AS `gen_attr`) AS gen_subquery_0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/generator_without_from_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/generator_without_from_2.sql b/sql/hive/src/test/resources/sqlgen/generator_without_from_2.sql
new file mode 100644
index 0000000..d7acb69
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/generator_without_from_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT EXPLODE(ARRAY(1,2,3)) AS val
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val` FROM (SELECT `gen_attr` FROM (SELECT 1) gen_subquery_1 LATERAL VIEW explode(array(1, 2, 3)) gen_subquery_2 AS `gen_attr`) AS gen_subquery_0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_1.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_1.sql
new file mode 100644
index 0000000..72e429f
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_1.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) AS cnt, key % 5 AS k1, key - 5 AS k2, grouping_id() AS k3
+FROM (SELECT key, key % 2, key - 5 FROM parquet_t1) t GROUP BY key % 5, key - 5
+GROUPING SETS (key % 5, key - 5)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `k3` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `gen_attr`, (`gen_attr` % CAST(2 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t GROUP BY (`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT))), ((`gen_attr` - CAST(5 AS BIGINT))))) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_2_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_2_1.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_1.sql
new file mode 100644
index 0000000..25e86e7
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY a, b GROUPING SETS (a, b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`), (`gen_attr`)) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_2_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_2_2.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_2.sql
new file mode 100644
index 0000000..24bf020
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY a, b GROUPING SETS (a) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`)) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_2_3.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_2_3.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_3.sql
new file mode 100644
index 0000000..f72bc8a
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_3.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY a, b GROUPING SETS (b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`)) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_2_4.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_2_4.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_4.sql
new file mode 100644
index 0000000..2fac7f6
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_4.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY a, b GROUPING SETS (()) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS(()) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/grouping_sets_2_5.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/grouping_sets_2_5.sql b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_5.sql
new file mode 100644
index 0000000..2e60c9c
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/grouping_sets_2_5.sql
@@ -0,0 +1,5 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY a, b
+GROUPING SETS ((), (a), (a, b)) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((), (`gen_attr`), (`gen_attr`, `gen_attr`)) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/in.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/in.sql b/sql/hive/src/test/resources/sqlgen/in.sql
new file mode 100644
index 0000000..1e0251e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/in.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM parquet_t0 WHERE id IN (1, 2, 3)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`parquet_t0`) AS gen_subquery_0 WHERE (CAST(`gen_attr` AS BIGINT) IN (CAST(1 AS BIGINT), CAST(2 AS BIGINT), CAST(3 AS BIGINT)))) AS parquet_t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/intersect.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/intersect.sql b/sql/hive/src/test/resources/sqlgen/intersect.sql
new file mode 100644
index 0000000..608fa59
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/intersect.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT * FROM t0 INTERSECT SELECT * FROM t0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM ((SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 ) INTERSECT ( SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_1)) AS t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/join_2_tables.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/join_2_tables.sql b/sql/hive/src/test/resources/sqlgen/join_2_tables.sql
new file mode 100644
index 0000000..bb99797
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/join_2_tables.sql
@@ -0,0 +1,7 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT COUNT(a.value), b.KEY, a.KEY
+FROM parquet_t1 a, parquet_t1 b
+GROUP BY a.KEY, b.KEY
+HAVING MAX(a.KEY) > 0
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `count(value)`, `gen_attr` AS `KEY`, `gen_attr` AS `KEY` FROM (SELECT `gen_attr`, `gen_attr`, `gen_attr` FROM (SELECT count(`gen_attr`) AS `gen_attr`, `gen_attr`, `gen_attr`, max(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 INNER JOIN (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_1 GROUP BY `gen_attr`, `gen_attr` HAVING (`gen_attr` > CAST(0 AS BIGINT))) AS gen_subquery_2) AS gen_subquery_3

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/json_tuple_generator_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/json_tuple_generator_1.sql b/sql/hive/src/test/resources/sqlgen/json_tuple_generator_1.sql
new file mode 100644
index 0000000..9e5fe11
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/json_tuple_generator_1.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT c0, c1, c2
+FROM parquet_t3
+LATERAL VIEW JSON_TUPLE(json, 'f1', 'f2', 'f3') jt
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `c0`, `gen_attr` AS `c1`, `gen_attr` AS `c2` FROM (SELECT `gen_attr`, `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW json_tuple(`gen_attr`, "f1", "f2", "f3") gen_subquery_1 AS `gen_attr`, `gen_attr`, `gen_attr`) AS jt

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/json_tuple_generator_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/json_tuple_generator_2.sql b/sql/hive/src/test/resources/sqlgen/json_tuple_generator_2.sql
new file mode 100644
index 0000000..55dd491
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/json_tuple_generator_2.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, c
+FROM parquet_t3
+LATERAL VIEW JSON_TUPLE(json, 'f1', 'f2', 'f3') jt AS a, b, c
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `c` FROM (SELECT `gen_attr`, `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW json_tuple(`gen_attr`, "f1", "f2", "f3") gen_subquery_1 AS `gen_attr`, `gen_attr`, `gen_attr`) AS jt

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/multi_distinct.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/multi_distinct.sql b/sql/hive/src/test/resources/sqlgen/multi_distinct.sql
new file mode 100644
index 0000000..b5c7cf0
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/multi_distinct.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, COUNT(DISTINCT b), COUNT(DISTINCT c), SUM(d) FROM parquet_t2 GROUP BY a
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `count(DISTINCT b)`, `gen_attr` AS `count(DISTINCT c)`, `gen_attr` AS `sum(d)` FROM (SELECT `gen_attr`, count(DISTINCT `gen_attr`) AS `gen_attr`, count(DISTINCT `gen_attr`) AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`) AS parquet_t2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_1.sql b/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_1.sql
new file mode 100644
index 0000000..3d79f95
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_1.sql
@@ -0,0 +1,7 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT val, id
+FROM parquet_t3
+LATERAL VIEW EXPLODE(arr2) exp1 AS nested_array
+LATERAL VIEW EXPLODE(nested_array) exp1 AS val
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr` LATERAL VIEW explode(`gen_attr`) gen_subquery_3 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_2.sql b/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_2.sql
new file mode 100644
index 0000000..18b29a7
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/nested_generator_in_lateral_view_2.sql
@@ -0,0 +1,7 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT val, id
+FROM parquet_t3
+LATERAL VIEW EXPLODE(arr2) exp1 AS nested_array
+LATERAL VIEW OUTER EXPLODE(nested_array) exp1 AS val
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `val`, `gen_attr` AS `id` FROM (SELECT `gen_attr`, `gen_attr` FROM (SELECT `arr` AS `gen_attr`, `arr2` AS `gen_attr`, `json` AS `gen_attr`, `id` AS `gen_attr` FROM `default`.`parquet_t3`) AS gen_subquery_0 LATERAL VIEW explode(`gen_attr`) gen_subquery_2 AS `gen_attr` LATERAL VIEW OUTER explode(`gen_attr`) gen_subquery_3 AS `gen_attr`) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/not_in.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/not_in.sql b/sql/hive/src/test/resources/sqlgen/not_in.sql
new file mode 100644
index 0000000..a50ee28
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/not_in.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM t0 WHERE id NOT IN (1, 2, 3)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 WHERE (NOT (CAST(`gen_attr` AS BIGINT) IN (CAST(1 AS BIGINT), CAST(2 AS BIGINT), CAST(3 AS BIGINT))))) AS t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/not_like.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/not_like.sql b/sql/hive/src/test/resources/sqlgen/not_like.sql
new file mode 100644
index 0000000..2f66695
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/not_like.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT id FROM t0 WHERE id + 5 NOT LIKE '1%'
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `id` FROM (SELECT `gen_attr` FROM (SELECT `id` AS `gen_attr` FROM `default`.`t0`) AS gen_subquery_0 WHERE (NOT CAST((`gen_attr` + CAST(5 AS BIGINT)) AS STRING) LIKE "1%")) AS t0

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/regular_expressions_and_window.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/regular_expressions_and_window.sql b/sql/hive/src/test/resources/sqlgen/regular_expressions_and_window.sql
new file mode 100644
index 0000000..7d837d4
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/regular_expressions_and_window.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT MAX(key) OVER (PARTITION BY key % 3) + key FROM parquet_t1
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(max(key) OVER (PARTITION BY (key % CAST(3 AS BIGINT))  ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) + key)` FROM (SELECT (`gen_attr` + `gen_attr`) AS `gen_attr` FROM (SELECT gen_subquery_1.`gen_attr`, gen_subquery_1.`gen_attr`, max(`gen_attr`) OVER (PARTITION BY `gen_attr`  ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS `gen_attr` FROM (SELECT `gen_attr`, (`gen_attr` % CAST(3 AS BIGINT)) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS gen_subquery_1) AS gen_subquery_2) AS gen_subquery_3

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_1_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_1_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_1_1.sql
new file mode 100644
index 0000000..4b2c78e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_1_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) as cnt, key%5, grouping_id() FROM parquet_t1 GROUP BY key % 5 WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `(key % CAST(5 AS BIGINT))`, `gen_attr` AS `grouping_id()` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY (`gen_attr` % CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_1_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_1_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_1_2.sql
new file mode 100644
index 0000000..62cf1bb
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_1_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) as cnt, key%5, grouping_id() FROM parquet_t1 GROUP BY key % 5 WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `(key % CAST(5 AS BIGINT))`, `gen_attr` AS `grouping_id()` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY (`gen_attr` % CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_2_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_2_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_2_1.sql
new file mode 100644
index 0000000..d58910a
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_2_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT key, value, count(value) FROM parquet_t1 GROUP BY key, value WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `value`, `gen_attr` AS `count(value)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, count(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_2_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_2_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_2_2.sql
new file mode 100644
index 0000000..9a58c15
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_2_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT key, value, count(value) FROM parquet_t1 GROUP BY key, value WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `value`, `gen_attr` AS `count(value)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, count(`gen_attr`) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_3_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_3_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_3_1.sql
new file mode 100644
index 0000000..cd4d428
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_3_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT key, count(value), grouping_id() FROM parquet_t1 GROUP BY key, value WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `count(value)`, `gen_attr` AS `grouping_id()` FROM (SELECT `gen_attr` AS `gen_attr`, count(`gen_attr`) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_3_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_3_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_3_2.sql
new file mode 100644
index 0000000..4f42d7e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_3_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT key, count(value), grouping_id() FROM parquet_t1 GROUP BY key, value WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `count(value)`, `gen_attr` AS `grouping_id()` FROM (SELECT `gen_attr` AS `gen_attr`, count(`gen_attr`) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_4_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_4_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_4_1.sql
new file mode 100644
index 0000000..be4908e
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_4_1.sql
@@ -0,0 +1,5 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) as cnt, key % 5 as k1, key - 5 as k2, grouping_id() FROM parquet_t1
+GROUP BY key % 5, key - 5 WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `grouping_id()` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY (`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT))), ((`gen_attr` % CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_4_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_4_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_4_2.sql
new file mode 100644
index 0000000..eebef6a
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_4_2.sql
@@ -0,0 +1,5 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) as cnt, key % 5 as k1, key - 5 as k2, grouping_id() FROM parquet_t1
+GROUP BY key % 5, key - 5 WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `grouping_id()` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 GROUP BY (`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT))), ((`gen_attr` % CAST(5 AS BIGINT))), ((`gen_attr` - CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_5_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_5_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_5_1.sql
new file mode 100644
index 0000000..9474233
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_5_1.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) AS cnt, key % 5 AS k1, key - 5 AS k2, grouping_id(key % 5, key - 5) AS k3
+FROM (SELECT key, key%2, key - 5 FROM parquet_t1) t GROUP BY key%5, key-5
+WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `k3` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `gen_attr`, (`gen_attr` % CAST(2 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t GROUP BY (`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT))), ((`gen_attr` % CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_5_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_5_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_5_2.sql
new file mode 100644
index 0000000..d36f43d
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_5_2.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT count(*) AS cnt, key % 5 AS k1, key - 5 AS k2, grouping_id(key % 5, key - 5) AS k3
+FROM (SELECT key, key % 2, key - 5 FROM parquet_t1) t GROUP BY key % 5, key - 5
+WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `cnt`, `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `k3` FROM (SELECT count(1) AS `gen_attr`, (`gen_attr` % CAST(5 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `gen_attr`, (`gen_attr` % CAST(2 AS BIGINT)) AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t GROUP BY (`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS(((`gen_attr` % CAST(5 AS BIGINT)), (`gen_attr` - CAST(5 AS BIGINT))), ((`gen_attr` % CAST(5 AS BIGINT))), ((`gen_attr` - CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_1.sql
new file mode 100644
index 0000000..de98078
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY ROLLUP(a, b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), ()) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_2.sql
new file mode 100644
index 0000000..8956ac4
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(c) FROM parquet_t2 GROUP BY CUBE(a, b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(c)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ()) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_3.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_3.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_3.sql
new file mode 100644
index 0000000..b9cef62
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_3.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(a) FROM parquet_t2 GROUP BY ROLLUP(a, b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(a)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), ()) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_4.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_4.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_4.sql
new file mode 100644
index 0000000..ba6457a
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_4.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, sum(a) FROM parquet_t2 GROUP BY CUBE(a, b) ORDER BY a, b
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `sum(a)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ()) ORDER BY `gen_attr` ASC, `gen_attr` ASC) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_5.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_5.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_5.sql
new file mode 100644
index 0000000..763fecd
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_5.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a + b, b, sum(a - b) FROM parquet_t2 GROUP BY a + b, b WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(a + b)`, `gen_attr` AS `b`, `gen_attr` AS `sum((a - b))` FROM (SELECT (`gen_attr` + `gen_attr`) AS `gen_attr`, `gen_attr` AS `gen_attr`, sum((`gen_attr` - `gen_attr`)) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY (`gen_attr` + `gen_attr`), `gen_attr` GROUPING SETS(((`gen_attr` + `gen_attr`), `gen_attr`), ((`gen_attr` + `gen_attr`)), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_6_6.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_6_6.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_6.sql
new file mode 100644
index 0000000..00ecbf6
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_6_6.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a + b, b, sum(a - b) FROM parquet_t2 GROUP BY a + b, b WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(a + b)`, `gen_attr` AS `b`, `gen_attr` AS `sum((a - b))` FROM (SELECT (`gen_attr` + `gen_attr`) AS `gen_attr`, `gen_attr` AS `gen_attr`, sum((`gen_attr` - `gen_attr`)) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY (`gen_attr` + `gen_attr`), `gen_attr` GROUPING SETS(((`gen_attr` + `gen_attr`), `gen_attr`), ((`gen_attr` + `gen_attr`)), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_7_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_7_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_1.sql
new file mode 100644
index 0000000..6f57130
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, grouping_id(a, b) FROM parquet_t2 GROUP BY cube(a, b)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `grouping_id(a, b)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, grouping_id() AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_7_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_7_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_2.sql
new file mode 100644
index 0000000..dab7852
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, grouping(b) FROM parquet_t2 GROUP BY cube(a, b)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `grouping(b)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, grouping(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_7_3.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_7_3.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_3.sql
new file mode 100644
index 0000000..50964e5
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_7_3.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT a, b, grouping(a) FROM parquet_t2 GROUP BY cube(a, b)
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `a`, `gen_attr` AS `b`, `gen_attr` AS `grouping(a)` FROM (SELECT `gen_attr` AS `gen_attr`, `gen_attr` AS `gen_attr`, grouping(`gen_attr`) AS `gen_attr` FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0 GROUP BY `gen_attr`, `gen_attr` GROUPING SETS((`gen_attr`, `gen_attr`), (`gen_attr`), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_8_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_8_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_8_1.sql
new file mode 100644
index 0000000..84af580
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_8_1.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT hkey AS k1, value - 5 AS k2, hash(grouping_id()) AS hgid
+FROM (SELECT hash(key) as hkey, key as value FROM parquet_t1) t GROUP BY hkey, value-5
+WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `hgid` FROM (SELECT `gen_attr` AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, hash(grouping_id()) AS `gen_attr` FROM (SELECT hash(`gen_attr`) AS `gen_attr`, `gen_attr` AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t GROUP BY `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS((`gen_attr`, (`gen_attr` - CAST(5 AS BIGINT))), (`gen_attr`), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_8_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_8_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_8_2.sql
new file mode 100644
index 0000000..b0f65b7
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_8_2.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT hkey AS k1, value - 5 AS k2, hash(grouping_id()) AS hgid
+FROM (SELECT hash(key) as hkey, key as value FROM parquet_t1) t GROUP BY hkey, value-5
+WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `k1`, `gen_attr` AS `k2`, `gen_attr` AS `hgid` FROM (SELECT `gen_attr` AS `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, hash(grouping_id()) AS `gen_attr` FROM (SELECT hash(`gen_attr`) AS `gen_attr`, `gen_attr` AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t GROUP BY `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS((`gen_attr`, (`gen_attr` - CAST(5 AS BIGINT))), (`gen_attr`), ((`gen_attr` - CAST(5 AS BIGINT))), ())) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_9_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_9_1.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_9_1.sql
new file mode 100644
index 0000000..171400d
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_9_1.sql
@@ -0,0 +1,8 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT t.key - 5, cnt, SUM(cnt)
+FROM (SELECT x.key, COUNT(*) as cnt
+FROM parquet_t1 x JOIN parquet_t1 y ON x.key = y.key GROUP BY x.key) t
+GROUP BY cnt, t.key - 5
+WITH ROLLUP
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(key - CAST(5 AS BIGINT))`, `gen_attr` AS `cnt`, `gen_attr` AS `sum(cnt)` FROM (SELECT (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `gen_attr`, count(1) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 INNER JOIN (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_1 ON (`gen_attr` = `gen_attr`) GROUP BY `gen_attr`) AS t GROUP BY `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS((`gen_attr`, (`gen_attr` - CAST(5 AS BIGINT))), (`gen_attr`), ())) AS gen_subquery_2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/rollup_cube_9_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/rollup_cube_9_2.sql b/sql/hive/src/test/resources/sqlgen/rollup_cube_9_2.sql
new file mode 100644
index 0000000..fe98b6c
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/rollup_cube_9_2.sql
@@ -0,0 +1,8 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT t.key - 5, cnt, SUM(cnt)
+FROM (SELECT x.key, COUNT(*) as cnt
+FROM parquet_t1 x JOIN parquet_t1 y ON x.key = y.key GROUP BY x.key) t
+GROUP BY cnt, t.key - 5
+WITH CUBE
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(key - CAST(5 AS BIGINT))`, `gen_attr` AS `cnt`, `gen_attr` AS `sum(cnt)` FROM (SELECT (`gen_attr` - CAST(5 AS BIGINT)) AS `gen_attr`, `gen_attr` AS `gen_attr`, sum(`gen_attr`) AS `gen_attr` FROM (SELECT `gen_attr`, count(1) AS `gen_attr` FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0 INNER JOIN (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_1 ON (`gen_attr` = `gen_attr`) GROUP BY `gen_attr`) AS t GROUP BY `gen_attr`, (`gen_attr` - CAST(5 AS BIGINT)) GROUPING SETS((`gen_attr`, (`gen_attr` - CAST(5 AS BIGINT))), (`gen_attr`), ((`gen_attr` - CAST(5 AS BIGINT))), ())) AS gen_subquery_2

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/script_transformation_1.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/script_transformation_1.sql b/sql/hive/src/test/resources/sqlgen/script_transformation_1.sql
new file mode 100644
index 0000000..75e43d0
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/script_transformation_1.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT TRANSFORM (a, b, c, d) USING 'cat' FROM parquet_t2
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `value` FROM (SELECT TRANSFORM (`gen_attr`, `gen_attr`, `gen_attr`, `gen_attr`) USING 'cat' AS (`gen_attr` string, `gen_attr` string) FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/script_transformation_2.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/script_transformation_2.sql b/sql/hive/src/test/resources/sqlgen/script_transformation_2.sql
new file mode 100644
index 0000000..6a68edc
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/script_transformation_2.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT TRANSFORM (*) USING 'cat' FROM parquet_t2
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `key`, `gen_attr` AS `value` FROM (SELECT TRANSFORM (`gen_attr`, `gen_attr`, `gen_attr`, `gen_attr`) USING 'cat' AS (`gen_attr` string, `gen_attr` string) FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list.sql b/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list.sql
new file mode 100644
index 0000000..111df4b
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list.sql
@@ -0,0 +1,4 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT TRANSFORM (a, b, c, d) USING 'cat' AS (d1, d2, d3, d4) FROM parquet_t2
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `d1`, `gen_attr` AS `d2`, `gen_attr` AS `d3`, `gen_attr` AS `d4` FROM (SELECT TRANSFORM (`gen_attr`, `gen_attr`, `gen_attr`, `gen_attr`) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES('field.delim' = '	') USING 'cat' AS (`gen_attr` string, `gen_attr` string, `gen_attr` string, `gen_attr` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES('field.delim' = '	') FROM (SELECT `a` AS `gen_attr`, `b` AS `gen_attr`, `c` AS `gen_attr`, `d` AS `gen_attr` FROM `default`.`parquet_t2`) AS gen_subquery_0) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list_with_type.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list_with_type.sql b/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list_with_type.sql
new file mode 100644
index 0000000..4ab412c
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/script_transformation_alias_list_with_type.sql
@@ -0,0 +1,6 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+FROM
+(FROM parquet_t1 SELECT TRANSFORM(key, value) USING 'cat' AS (thing1 int, thing2 string)) t
+SELECT thing1 + 1
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `(thing1 + 1)` FROM (SELECT (`gen_attr` + 1) AS `gen_attr` FROM (SELECT TRANSFORM (`gen_attr`, `gen_attr`) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES('field.delim' = '	') USING 'cat' AS (`gen_attr` int, `gen_attr` string) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES('field.delim' = '	') FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS t) AS gen_subquery_1

http://git-wip-us.apache.org/repos/asf/spark/blob/ea78edb8/sql/hive/src/test/resources/sqlgen/script_transformation_row_format_multiple.sql
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/sqlgen/script_transformation_row_format_multiple.sql b/sql/hive/src/test/resources/sqlgen/script_transformation_row_format_multiple.sql
new file mode 100644
index 0000000..1e30e45
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/script_transformation_row_format_multiple.sql
@@ -0,0 +1,8 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+SELECT TRANSFORM (key)
+ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\t'
+USING 'cat' AS (tKey)
+ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\t'
+FROM parquet_t1
+--------------------------------------------------------------------------------
+SELECT `gen_attr` AS `tKey` FROM (SELECT TRANSFORM (`gen_attr`) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\t' USING 'cat' AS (`gen_attr` string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\t' FROM (SELECT `key` AS `gen_attr`, `value` AS `gen_attr` FROM `default`.`parquet_t1`) AS gen_subquery_0) AS gen_subquery_1


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message