Statistics: Tests to verify simple query plans (#558)

diff --git a/framework/resources/Datasources/table_stats/analyze_tables.sql b/framework/resources/Datasources/table_stats/analyze_tables.sql
index 9cc3700..8559e23 100755
--- a/framework/resources/Datasources/table_stats/analyze_tables.sql
+++ b/framework/resources/Datasources/table_stats/analyze_tables.sql
@@ -16,4 +16,8 @@
 analyze table `table_stats/hive_alltypes` compute statistics (c1,c2,c3,c4,c9,c10,c11,c12,n);
 --analyze table `table_stats/data_with_0` compute statistics (non_exist_col,bigint_col,bigint_col,int_col,bigint_col);
 analyze table `table_stats/data_with_0` compute statistics (int_col,bigint_col);
+analyze table `table_stats/nested_scalar_cols` compute statistics(glossary.title,glossary.GlossDiv.title,glossary.GlossDiv.GlossList.GlossEntry.Acronym,glossary.GlossDiv.GlossList.GlossEntry.GlossDef.GlossSeeAlso[0]);
+analyze table `table_stats/Tpch0.01/parquet/customer` compute statistics;
+analyze table `table_stats/Tpch0.01/parquet/part` compute statistics;
+analyze table `table_stats/Tpch0.01/parquet/partsupp` compute statistics;
 reset `store.parquet.reader.int96_as_timestamp`;
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/customer/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/customer/.stats.drill/0_0.json
deleted file mode 100644
index 40faa01..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/customer/.stats.drill/0_0.json
+++ /dev/null
@@ -1,63 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:16:21.703-08:00",
-    "columns" : [ {
-      "column" : "c_custkey",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1500,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "c_name",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1500,
-      "avgwidth" : 18.0
-    }, {
-      "column" : "c_address",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1500,
-      "avgwidth" : 24.726666666666667
-    }, {
-      "column" : "c_nationkey",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 25,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "c_phone",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1500,
-      "avgwidth" : 15.0
-    }, {
-      "column" : "c_acctbal",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1499,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "c_mktsegment",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 5,
-      "avgwidth" : 8.976666666666667
-    }, {
-      "column" : "c_comment",
-      "schema" : 1.0,
-      "statcount" : 1500.0,
-      "nonnullstatcount" : 1500.0,
-      "ndv" : 1500,
-      "avgwidth" : 73.2
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/lineitem/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/lineitem/.stats.drill/0_0.json
deleted file mode 100644
index 9da0f90..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/lineitem/.stats.drill/0_0.json
+++ /dev/null
@@ -1,119 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:16:35.305-08:00",
-    "columns" : [ {
-      "column" : "l_orderkey",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 14991,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_partkey",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 2000,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_suppkey",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 100,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_linenumber",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 7,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_quantity",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 50,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "l_extendedprice",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 35879,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "l_discount",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 11,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "l_tax",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 9,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "l_returnflag",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 3,
-      "avgwidth" : 1.0
-    }, {
-      "column" : "l_linestatus",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 2,
-      "avgwidth" : 1.0
-    }, {
-      "column" : "l_shipdate",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 2518,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_commitdate",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 2460,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_receiptdate",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 2529,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "l_shipinstruct",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 4,
-      "avgwidth" : 12.001046946406316
-    }, {
-      "column" : "l_shipmode",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 7,
-      "avgwidth" : 4.289588699626091
-    }, {
-      "column" : "l_comment",
-      "schema" : 1.0,
-      "statcount" : 60175.0,
-      "nonnullstatcount" : 60175.0,
-      "ndv" : 58641,
-      "avgwidth" : 26.562044038221853
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/nation/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/nation/.stats.drill/0_0.json
deleted file mode 100644
index 91bdff1..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/nation/.stats.drill/0_0.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:20.855-08:00",
-    "columns" : [ {
-      "column" : "n_nationkey",
-      "schema" : 1.0,
-      "statcount" : 25.0,
-      "nonnullstatcount" : 25.0,
-      "ndv" : 25,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "n_name",
-      "schema" : 1.0,
-      "statcount" : 25.0,
-      "nonnullstatcount" : 25.0,
-      "ndv" : 25,
-      "avgwidth" : 7.08
-    }, {
-      "column" : "n_regionkey",
-      "schema" : 1.0,
-      "statcount" : 25.0,
-      "nonnullstatcount" : 25.0,
-      "ndv" : 5,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "n_comment",
-      "schema" : 1.0,
-      "statcount" : 25.0,
-      "nonnullstatcount" : 25.0,
-      "ndv" : 25,
-      "avgwidth" : 74.28
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/orders/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/orders/.stats.drill/0_0.json
deleted file mode 100644
index 806e696..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/orders/.stats.drill/0_0.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:27.395-08:00",
-    "columns" : [ {
-      "column" : "o_orderkey",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 14991,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "o_custkey",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 999,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "o_orderstatus",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 3,
-      "avgwidth" : 1.0
-    }, {
-      "column" : "o_totalprice",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 14996,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "o_orderdate",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 2401,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "o_orderpriority",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 5,
-      "avgwidth" : 8.412533333333334
-    }, {
-      "column" : "o_clerk",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 1000,
-      "avgwidth" : 15.0
-    }, {
-      "column" : "o_shippriority",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 1,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "o_comment",
-      "schema" : 1.0,
-      "statcount" : 15000.0,
-      "nonnullstatcount" : 15000.0,
-      "ndv" : 14996,
-      "avgwidth" : 48.49093333333333
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/part/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/part/.stats.drill/0_0.json
deleted file mode 100644
index c3c0b4d..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/part/.stats.drill/0_0.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:33.209-08:00",
-    "columns" : [ {
-      "column" : "p_partkey",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 2000,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "p_name",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 2001,
-      "avgwidth" : 33.127
-    }, {
-      "column" : "p_mfgr",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 5,
-      "avgwidth" : 14.0
-    }, {
-      "column" : "p_brand",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 25,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "p_type",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 150,
-      "avgwidth" : 20.551
-    }, {
-      "column" : "p_size",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 50,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "p_container",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 40,
-      "avgwidth" : 7.6105
-    }, {
-      "column" : "p_retailprice",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 1100,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "p_comment",
-      "schema" : 1.0,
-      "statcount" : 2000.0,
-      "nonnullstatcount" : 2000.0,
-      "ndv" : 1960,
-      "avgwidth" : 13.5865
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/partsupp/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/partsupp/.stats.drill/0_0.json
deleted file mode 100644
index 0eeb932..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/partsupp/.stats.drill/0_0.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:39.004-08:00",
-    "columns" : [ {
-      "column" : "ps_partkey",
-      "schema" : 1.0,
-      "statcount" : 8000.0,
-      "nonnullstatcount" : 8000.0,
-      "ndv" : 2000,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "ps_suppkey",
-      "schema" : 1.0,
-      "statcount" : 8000.0,
-      "nonnullstatcount" : 8000.0,
-      "ndv" : 100,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "ps_availqty",
-      "schema" : 1.0,
-      "statcount" : 8000.0,
-      "nonnullstatcount" : 8000.0,
-      "ndv" : 5494,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "ps_supplycost",
-      "schema" : 1.0,
-      "statcount" : 8000.0,
-      "nonnullstatcount" : 8000.0,
-      "ndv" : 7661,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "ps_comment",
-      "schema" : 1.0,
-      "statcount" : 8000.0,
-      "nonnullstatcount" : 8000.0,
-      "ndv" : 7994,
-      "avgwidth" : 124.06625
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/region/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/region/.stats.drill/0_0.json
deleted file mode 100644
index 5902e6b..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/region/.stats.drill/0_0.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:45.113-08:00",
-    "columns" : [ {
-      "column" : "r_regionkey",
-      "schema" : 1.0,
-      "statcount" : 5.0,
-      "nonnullstatcount" : 5.0,
-      "ndv" : 5,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "r_name",
-      "schema" : 1.0,
-      "statcount" : 5.0,
-      "nonnullstatcount" : 5.0,
-      "ndv" : 5,
-      "avgwidth" : 6.8
-    }, {
-      "column" : "r_comment",
-      "schema" : 1.0,
-      "statcount" : 5.0,
-      "nonnullstatcount" : 5.0,
-      "ndv" : 5,
-      "avgwidth" : 66.0
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/supplier/.stats.drill/0_0.json b/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/supplier/.stats.drill/0_0.json
deleted file mode 100644
index 9fbfe95..0000000
--- a/framework/resources/Datasources/table_stats/tables/Tpch0.01/parquet/supplier/.stats.drill/0_0.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
-  "statistics_version" : "v1",
-  "directories" : [ {
-    "computed" : "2017-02-23T22:17:53.227-08:00",
-    "columns" : [ {
-      "column" : "s_suppkey",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "s_name",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 18.0
-    }, {
-      "column" : "s_address",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 25.37
-    }, {
-      "column" : "s_nationkey",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 25,
-      "avgwidth" : 4.0
-    }, {
-      "column" : "s_phone",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 15.0
-    }, {
-      "column" : "s_acctbal",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 8.0
-    }, {
-      "column" : "s_comment",
-      "schema" : 1.0,
-      "statcount" : 100.0,
-      "nonnullstatcount" : 100.0,
-      "ndv" : 100,
-      "avgwidth" : 61.15
-    } ]
-  } ]
-}
\ No newline at end of file
diff --git a/framework/resources/Datasources/table_stats/tables/nested_scalar_cols/0_0_0.parquet b/framework/resources/Datasources/table_stats/tables/nested_scalar_cols/0_0_0.parquet
new file mode 100644
index 0000000..306007b
--- /dev/null
+++ b/framework/resources/Datasources/table_stats/tables/nested_scalar_cols/0_0_0.parquet
Binary files differ
diff --git a/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.plan b/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.plan
new file mode 100644
index 0000000..abc9da2
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.plan
@@ -0,0 +1 @@
+[{"computed":.*,"columns":[{"column":"`\\`glossary\\`.\\`title\\``","majortype":{"type":"VARCHAR","mode":"OPTIONAL"},"schema":1.0,"rowcount":5.0,"nonnullrowcount":5.0,"ndv":5,"avgwidth":18.0},{"column":"`\\`glossary\\`.\\`GlossDiv\\`.\\`title\\``","majortype":{"type":"VARCHAR","mode":"OPTIONAL"},"schema":1.0,"rowcount":5.0,"nonnullrowcount":5.0,"ndv":2,"avgwidth":1.0},{"column":"`\\`glossary\\`.\\`GlossDiv\\`.\\`GlossList\\`.\\`GlossEntry\\`.\\`Acronym\\``","majortype":{"type":"VARCHAR","mode":"OPTIONAL"},"schema":1.0,"rowcount":5.0,"nonnullrowcount":5.0,"ndv":4,"avgwidth":4.4},{"column":"`\\`glossary\\`.\\`GlossDiv\\`.\\`GlossList\\`.\\`GlossEntry\\`.\\`GlossDef\\`.\\`GlossSeeAlso\\`[0]`","majortype":{"type":"VARCHAR","mode":"OPTIONAL"},"schema":1.0,"rowcount":5.0,"nonnullrowcount":5.0,"ndv":4,"avgwidth":3.2}]}]
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.sql b/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.sql
new file mode 100644
index 0000000..d710faa
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/positive/nested_scalar_cols.sql
@@ -0,0 +1 @@
+select directories from `table_stats/nested_scalar_cols/.stats.drill`;
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/positive/stats.json b/framework/resources/Functional/table_stats/stats/positive/stats.json
index 060fd78..d928066 100644
--- a/framework/resources/Functional/table_stats/stats/positive/stats.json
+++ b/framework/resources/Functional/table_stats/stats/positive/stats.json
@@ -1,5 +1,5 @@
 {
-    "testId": "Table_Stats_Query",
+    "testId": "Stats_positive_tests",
     "type": "group",
     "description": "Test queries using stats",
     "categories": [
diff --git a/framework/resources/Functional/table_stats/stats/query/groupby_1.plan b/framework/resources/Functional/table_stats/stats/query/groupby_1.plan
new file mode 100644
index 0000000..c346a83
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/groupby_1.plan
@@ -0,0 +1,3 @@
+.*Screen.*rowcount = 1500.0
+.*HashAgg.*rowcount = 1500.0
+.*Scan.*rowcount = 1500.0
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/groupby_1.sql b/framework/resources/Functional/table_stats/stats/query/groupby_1.sql
new file mode 100644
index 0000000..9f797f1
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/groupby_1.sql
@@ -0,0 +1,4 @@
+-- This group by is on a groupby key where all the values are distinct
+set `planner.statistics.use` = true;
+explain plan including all attributes for select c_custkey from `table_stats/Tpch0.01/parquet/customer` group by c_custkey;
+reset `planner.statistics.use`;
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/groupby_2.plan b/framework/resources/Functional/table_stats/stats/query/groupby_2.plan
new file mode 100644
index 0000000..18d09dc
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/groupby_2.plan
@@ -0,0 +1,3 @@
+.*Screen.*rowcount = 4.9999999999999485
+.*HashAgg.*rowcount = 4.9999999999999485
+.*Scan.*rowcount = 1500.0
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/groupby_2.sql b/framework/resources/Functional/table_stats/stats/query/groupby_2.sql
new file mode 100644
index 0000000..fdcec13
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/groupby_2.sql
@@ -0,0 +1,4 @@
+-- This group by is on a groupby key where there are many duplicates
+set `planner.statistics.use` = true;
+explain plan including all attributes for select c_mktsegment,count(*) from `table_stats/Tpch0.01/parquet/customer` group by c_mktsegment;
+reset `planner.statistics.use`;
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/inner_join1.plan b/framework/resources/Functional/table_stats/stats/query/inner_join1.plan
new file mode 100644
index 0000000..312a47f
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/inner_join1.plan
@@ -0,0 +1,4 @@
+.*Screen.*rowcount = 8000.0
+.*HashJoin.*rowcount = 8000.0
+.*Scan.*rowcount = 8000.0
+.*Scan.*rowcount = 2000.0
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/inner_join1.sql b/framework/resources/Functional/table_stats/stats/query/inner_join1.sql
new file mode 100644
index 0000000..17d8bd6
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/inner_join1.sql
@@ -0,0 +1,3 @@
+set `planner.statistics.use` = true;
+explain plan including all attributes for select p.p_partkey from `table_stats/Tpch0.01/parquet/part` p, `table_stats/Tpch0.01/parquet/partsupp` ps where p.p_partkey = ps.ps_partkey;
+reset `planner.statistics.use`;
\ No newline at end of file
diff --git a/framework/resources/Functional/table_stats/stats/query/query.json b/framework/resources/Functional/table_stats/stats/query/query.json
new file mode 100644
index 0000000..eb27973
--- /dev/null
+++ b/framework/resources/Functional/table_stats/stats/query/query.json
@@ -0,0 +1,31 @@
+{
+  "testId": "Table_Stats_Query",
+  "type": "group",
+  "description": "Test queries using stats",
+  "categories": [
+    "functional"
+  ],
+  "matrices": [
+    {
+      "query-file": ".*.sql",
+      "schema": "dfs.drillTestDir",
+      "output-format": "tsv",
+      "expected-file": ".*.plan",
+      "verification-type": [
+        "regex"
+      ]
+    }
+  ],
+  "datasources": [
+    {
+      "mode": "cp",
+      "src": "Datasources/table_stats/tables",
+      "dest": "table_stats"
+    },
+    {
+      "mode": "gen",
+      "src": "Datasources/table_stats/table_stats.sh",
+      "dest": ""
+    }
+  ]
+}