spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [2/3] spark git commit: [SPARK-15078] [SQL] Add all TPCDS 1.4 benchmark queries for SparkSQL
Date Fri, 20 May 2016 22:19:38 GMT
http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q49.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q49.sql b/sql/core/src/test/resources/tpcds/q49.sql
new file mode 100755
index 0000000..9568d8b
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q49.sql
@@ -0,0 +1,126 @@
+SELECT
+  'web' AS channel,
+  web.item,
+  web.return_ratio,
+  web.return_rank,
+  web.currency_rank
+FROM (
+       SELECT
+         item,
+         return_ratio,
+         currency_ratio,
+         rank()
+         OVER (
+           ORDER BY return_ratio) AS return_rank,
+         rank()
+         OVER (
+           ORDER BY currency_ratio) AS currency_rank
+       FROM
+         (SELECT
+           ws.ws_item_sk AS item,
+           (cast(sum(coalesce(wr.wr_return_quantity, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(ws.ws_quantity, 0)) AS DECIMAL(15, 4))) AS return_ratio,
+           (cast(sum(coalesce(wr.wr_return_amt, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(ws.ws_net_paid, 0)) AS DECIMAL(15, 4))) AS currency_ratio
+         FROM
+           web_sales ws LEFT OUTER JOIN web_returns wr
+             ON (ws.ws_order_number = wr.wr_order_number AND
+             ws.ws_item_sk = wr.wr_item_sk)
+           , date_dim
+         WHERE
+           wr.wr_return_amt > 10000
+             AND ws.ws_net_profit > 1
+             AND ws.ws_net_paid > 0
+             AND ws.ws_quantity > 0
+             AND ws_sold_date_sk = d_date_sk
+             AND d_year = 2001
+             AND d_moy = 12
+         GROUP BY ws.ws_item_sk
+         ) in_web
+     ) web
+WHERE (web.return_rank <= 10 OR web.currency_rank <= 10)
+UNION
+SELECT
+  'catalog' AS channel,
+  catalog.item,
+  catalog.return_ratio,
+  catalog.return_rank,
+  catalog.currency_rank
+FROM (
+       SELECT
+         item,
+         return_ratio,
+         currency_ratio,
+         rank()
+         OVER (
+           ORDER BY return_ratio) AS return_rank,
+         rank()
+         OVER (
+           ORDER BY currency_ratio) AS currency_rank
+       FROM
+         (SELECT
+           cs.cs_item_sk AS item,
+           (cast(sum(coalesce(cr.cr_return_quantity, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(cs.cs_quantity, 0)) AS DECIMAL(15, 4))) AS return_ratio,
+           (cast(sum(coalesce(cr.cr_return_amount, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(cs.cs_net_paid, 0)) AS DECIMAL(15, 4))) AS currency_ratio
+         FROM
+           catalog_sales cs LEFT OUTER JOIN catalog_returns cr
+             ON (cs.cs_order_number = cr.cr_order_number AND
+             cs.cs_item_sk = cr.cr_item_sk)
+           , date_dim
+         WHERE
+           cr.cr_return_amount > 10000
+             AND cs.cs_net_profit > 1
+             AND cs.cs_net_paid > 0
+             AND cs.cs_quantity > 0
+             AND cs_sold_date_sk = d_date_sk
+             AND d_year = 2001
+             AND d_moy = 12
+         GROUP BY cs.cs_item_sk
+         ) in_cat
+     ) catalog
+WHERE (catalog.return_rank <= 10 OR catalog.currency_rank <= 10)
+UNION
+SELECT
+  'store' AS channel,
+  store.item,
+  store.return_ratio,
+  store.return_rank,
+  store.currency_rank
+FROM (
+       SELECT
+         item,
+         return_ratio,
+         currency_ratio,
+         rank()
+         OVER (
+           ORDER BY return_ratio) AS return_rank,
+         rank()
+         OVER (
+           ORDER BY currency_ratio) AS currency_rank
+       FROM
+         (SELECT
+           sts.ss_item_sk AS item,
+           (cast(sum(coalesce(sr.sr_return_quantity, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(sts.ss_quantity, 0)) AS DECIMAL(15, 4))) AS return_ratio,
+           (cast(sum(coalesce(sr.sr_return_amt, 0)) AS DECIMAL(15, 4)) /
+             cast(sum(coalesce(sts.ss_net_paid, 0)) AS DECIMAL(15, 4))) AS currency_ratio
+         FROM
+           store_sales sts LEFT OUTER JOIN store_returns sr
+             ON (sts.ss_ticket_number = sr.sr_ticket_number AND sts.ss_item_sk = sr.sr_item_sk)
+           , date_dim
+         WHERE
+           sr.sr_return_amt > 10000
+             AND sts.ss_net_profit > 1
+             AND sts.ss_net_paid > 0
+             AND sts.ss_quantity > 0
+             AND ss_sold_date_sk = d_date_sk
+             AND d_year = 2001
+             AND d_moy = 12
+         GROUP BY sts.ss_item_sk
+         ) in_store
+     ) store
+WHERE (store.return_rank <= 10 OR store.currency_rank <= 10)
+ORDER BY 1, 4, 5
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q5.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q5.sql b/sql/core/src/test/resources/tpcds/q5.sql
new file mode 100755
index 0000000..b87cf3a
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q5.sql
@@ -0,0 +1,131 @@
+WITH ssr AS
+( SELECT
+    s_store_id,
+    sum(sales_price) AS sales,
+    sum(profit) AS profit,
+    sum(return_amt) AS RETURNS,
+    sum(net_loss) AS profit_loss
+  FROM
+    (SELECT
+       ss_store_sk AS store_sk,
+       ss_sold_date_sk AS date_sk,
+       ss_ext_sales_price AS sales_price,
+       ss_net_profit AS profit,
+       cast(0 AS DECIMAL(7, 2)) AS return_amt,
+       cast(0 AS DECIMAL(7, 2)) AS net_loss
+     FROM store_sales
+     UNION ALL
+     SELECT
+       sr_store_sk AS store_sk,
+       sr_returned_date_sk AS date_sk,
+       cast(0 AS DECIMAL(7, 2)) AS sales_price,
+       cast(0 AS DECIMAL(7, 2)) AS profit,
+       sr_return_amt AS return_amt,
+       sr_net_loss AS net_loss
+     FROM store_returns)
+    salesreturns, date_dim, store
+  WHERE date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND ((cast('2000-08-23' AS DATE) + INTERVAL 14 days))
+    AND store_sk = s_store_sk
+  GROUP BY s_store_id),
+    csr AS
+  ( SELECT
+    cp_catalog_page_id,
+    sum(sales_price) AS sales,
+    sum(profit) AS profit,
+    sum(return_amt) AS RETURNS,
+    sum(net_loss) AS profit_loss
+  FROM
+    (SELECT
+       cs_catalog_page_sk AS page_sk,
+       cs_sold_date_sk AS date_sk,
+       cs_ext_sales_price AS sales_price,
+       cs_net_profit AS profit,
+       cast(0 AS DECIMAL(7, 2)) AS return_amt,
+       cast(0 AS DECIMAL(7, 2)) AS net_loss
+     FROM catalog_sales
+     UNION ALL
+     SELECT
+       cr_catalog_page_sk AS page_sk,
+       cr_returned_date_sk AS date_sk,
+       cast(0 AS DECIMAL(7, 2)) AS sales_price,
+       cast(0 AS DECIMAL(7, 2)) AS profit,
+       cr_return_amount AS return_amt,
+       cr_net_loss AS net_loss
+     FROM catalog_returns
+    ) salesreturns, date_dim, catalog_page
+  WHERE date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND ((cast('2000-08-23' AS DATE) + INTERVAL 14 days))
+    AND page_sk = cp_catalog_page_sk
+  GROUP BY cp_catalog_page_id)
+  ,
+    wsr AS
+  ( SELECT
+    web_site_id,
+    sum(sales_price) AS sales,
+    sum(profit) AS profit,
+    sum(return_amt) AS RETURNS,
+    sum(net_loss) AS profit_loss
+  FROM
+    (SELECT
+       ws_web_site_sk AS wsr_web_site_sk,
+       ws_sold_date_sk AS date_sk,
+       ws_ext_sales_price AS sales_price,
+       ws_net_profit AS profit,
+       cast(0 AS DECIMAL(7, 2)) AS return_amt,
+       cast(0 AS DECIMAL(7, 2)) AS net_loss
+     FROM web_sales
+     UNION ALL
+     SELECT
+       ws_web_site_sk AS wsr_web_site_sk,
+       wr_returned_date_sk AS date_sk,
+       cast(0 AS DECIMAL(7, 2)) AS sales_price,
+       cast(0 AS DECIMAL(7, 2)) AS profit,
+       wr_return_amt AS return_amt,
+       wr_net_loss AS net_loss
+     FROM web_returns
+       LEFT OUTER JOIN web_sales ON
+                                   (wr_item_sk = ws_item_sk
+                                     AND wr_order_number = ws_order_number)
+    ) salesreturns, date_dim, web_site
+  WHERE date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND ((cast('2000-08-23' AS DATE) + INTERVAL 14 days))
+    AND wsr_web_site_sk = web_site_sk
+  GROUP BY web_site_id)
+SELECT
+  channel,
+  id,
+  sum(sales) AS sales,
+  sum(returns) AS returns,
+  sum(profit) AS profit
+FROM
+  (SELECT
+     'store channel' AS channel,
+     concat('store', s_store_id) AS id,
+     sales,
+     returns,
+     (profit - profit_loss) AS profit
+   FROM ssr
+   UNION ALL
+   SELECT
+     'catalog channel' AS channel,
+     concat('catalog_page', cp_catalog_page_id) AS id,
+     sales,
+     returns,
+     (profit - profit_loss) AS profit
+   FROM csr
+   UNION ALL
+   SELECT
+     'web channel' AS channel,
+     concat('web_site', web_site_id) AS id,
+     sales,
+     returns,
+     (profit - profit_loss) AS profit
+   FROM wsr
+  ) x
+GROUP BY ROLLUP (channel, id)
+ORDER BY channel, id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q50.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q50.sql b/sql/core/src/test/resources/tpcds/q50.sql
new file mode 100755
index 0000000..f1d4b15
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q50.sql
@@ -0,0 +1,47 @@
+SELECT
+  s_store_name,
+  s_company_id,
+  s_street_number,
+  s_street_name,
+  s_street_type,
+  s_suite_number,
+  s_city,
+  s_county,
+  s_state,
+  s_zip,
+  sum(CASE WHEN (sr_returned_date_sk - ss_sold_date_sk <= 30)
+    THEN 1
+      ELSE 0 END)  AS `30 days `,
+  sum(CASE WHEN (sr_returned_date_sk - ss_sold_date_sk > 30) AND
+    (sr_returned_date_sk - ss_sold_date_sk <= 60)
+    THEN 1
+      ELSE 0 END)  AS `31 - 60 days `,
+  sum(CASE WHEN (sr_returned_date_sk - ss_sold_date_sk > 60) AND
+    (sr_returned_date_sk - ss_sold_date_sk <= 90)
+    THEN 1
+      ELSE 0 END)  AS `61 - 90 days `,
+  sum(CASE WHEN (sr_returned_date_sk - ss_sold_date_sk > 90) AND
+    (sr_returned_date_sk - ss_sold_date_sk <= 120)
+    THEN 1
+      ELSE 0 END)  AS `91 - 120 days `,
+  sum(CASE WHEN (sr_returned_date_sk - ss_sold_date_sk > 120)
+    THEN 1
+      ELSE 0 END)  AS `>120 days `
+FROM
+  store_sales, store_returns, store, date_dim d1, date_dim d2
+WHERE
+  d2.d_year = 2001
+    AND d2.d_moy = 8
+    AND ss_ticket_number = sr_ticket_number
+    AND ss_item_sk = sr_item_sk
+    AND ss_sold_date_sk = d1.d_date_sk
+    AND sr_returned_date_sk = d2.d_date_sk
+    AND ss_customer_sk = sr_customer_sk
+    AND ss_store_sk = s_store_sk
+GROUP BY
+  s_store_name, s_company_id, s_street_number, s_street_name, s_street_type,
+  s_suite_number, s_city, s_county, s_state, s_zip
+ORDER BY
+  s_store_name, s_company_id, s_street_number, s_street_name, s_street_type,
+  s_suite_number, s_city, s_county, s_state, s_zip
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q51.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q51.sql b/sql/core/src/test/resources/tpcds/q51.sql
new file mode 100755
index 0000000..62b003e
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q51.sql
@@ -0,0 +1,55 @@
+WITH web_v1 AS (
+  SELECT
+    ws_item_sk item_sk,
+    d_date,
+    sum(sum(ws_sales_price))
+    OVER (PARTITION BY ws_item_sk
+      ORDER BY d_date
+      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cume_sales
+  FROM web_sales, date_dim
+  WHERE ws_sold_date_sk = d_date_sk
+    AND d_month_seq BETWEEN 1200 AND 1200 + 11
+    AND ws_item_sk IS NOT NULL
+  GROUP BY ws_item_sk, d_date),
+    store_v1 AS (
+    SELECT
+      ss_item_sk item_sk,
+      d_date,
+      sum(sum(ss_sales_price))
+      OVER (PARTITION BY ss_item_sk
+        ORDER BY d_date
+        ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cume_sales
+    FROM store_sales, date_dim
+    WHERE ss_sold_date_sk = d_date_sk
+      AND d_month_seq BETWEEN 1200 AND 1200 + 11
+      AND ss_item_sk IS NOT NULL
+    GROUP BY ss_item_sk, d_date)
+SELECT *
+FROM (SELECT
+  item_sk,
+  d_date,
+  web_sales,
+  store_sales,
+  max(web_sales)
+  OVER (PARTITION BY item_sk
+    ORDER BY d_date
+    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) web_cumulative,
+  max(store_sales)
+  OVER (PARTITION BY item_sk
+    ORDER BY d_date
+    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) store_cumulative
+FROM (SELECT
+  CASE WHEN web.item_sk IS NOT NULL
+    THEN web.item_sk
+  ELSE store.item_sk END item_sk,
+  CASE WHEN web.d_date IS NOT NULL
+    THEN web.d_date
+  ELSE store.d_date END d_date,
+  web.cume_sales web_sales,
+  store.cume_sales store_sales
+FROM web_v1 web FULL OUTER JOIN store_v1 store ON (web.item_sk = store.item_sk
+  AND web.d_date = store.d_date)
+     ) x) y
+WHERE web_cumulative > store_cumulative
+ORDER BY item_sk, d_date
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q52.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q52.sql b/sql/core/src/test/resources/tpcds/q52.sql
new file mode 100755
index 0000000..467d1ae
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q52.sql
@@ -0,0 +1,14 @@
+SELECT
+  dt.d_year,
+  item.i_brand_id brand_id,
+  item.i_brand brand,
+  sum(ss_ext_sales_price) ext_price
+FROM date_dim dt, store_sales, item
+WHERE dt.d_date_sk = store_sales.ss_sold_date_sk
+  AND store_sales.ss_item_sk = item.i_item_sk
+  AND item.i_manager_id = 1
+  AND dt.d_moy = 11
+  AND dt.d_year = 2000
+GROUP BY dt.d_year, item.i_brand, item.i_brand_id
+ORDER BY dt.d_year, ext_price DESC, brand_id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q53.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q53.sql b/sql/core/src/test/resources/tpcds/q53.sql
new file mode 100755
index 0000000..b42c68d
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q53.sql
@@ -0,0 +1,30 @@
+SELECT *
+FROM
+  (SELECT
+    i_manufact_id,
+    sum(ss_sales_price) sum_sales,
+    avg(sum(ss_sales_price))
+    OVER (PARTITION BY i_manufact_id) avg_quarterly_sales
+  FROM item, store_sales, date_dim, store
+  WHERE ss_item_sk = i_item_sk AND
+    ss_sold_date_sk = d_date_sk AND
+    ss_store_sk = s_store_sk AND
+    d_month_seq IN (1200, 1200 + 1, 1200 + 2, 1200 + 3, 1200 + 4, 1200 + 5, 1200 + 6,
+                          1200 + 7, 1200 + 8, 1200 + 9, 1200 + 10, 1200 + 11) AND
+    ((i_category IN ('Books', 'Children', 'Electronics') AND
+      i_class IN ('personal', 'portable', 'reference', 'self-help') AND
+      i_brand IN ('scholaramalgamalg #14', 'scholaramalgamalg #7',
+                  'exportiunivamalg #9', 'scholaramalgamalg #9'))
+      OR
+      (i_category IN ('Women', 'Music', 'Men') AND
+        i_class IN ('accessories', 'classical', 'fragrances', 'pants') AND
+        i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1',
+                    'importoamalg #1')))
+  GROUP BY i_manufact_id, d_qoy) tmp1
+WHERE CASE WHEN avg_quarterly_sales > 0
+  THEN abs(sum_sales - avg_quarterly_sales) / avg_quarterly_sales
+      ELSE NULL END > 0.1
+ORDER BY avg_quarterly_sales,
+  sum_sales,
+  i_manufact_id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q54.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q54.sql b/sql/core/src/test/resources/tpcds/q54.sql
new file mode 100755
index 0000000..897237f
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q54.sql
@@ -0,0 +1,61 @@
+WITH my_customers AS (
+  SELECT DISTINCT
+    c_customer_sk,
+    c_current_addr_sk
+  FROM
+    (SELECT
+       cs_sold_date_sk sold_date_sk,
+       cs_bill_customer_sk customer_sk,
+       cs_item_sk item_sk
+     FROM catalog_sales
+     UNION ALL
+     SELECT
+       ws_sold_date_sk sold_date_sk,
+       ws_bill_customer_sk customer_sk,
+       ws_item_sk item_sk
+     FROM web_sales
+    ) cs_or_ws_sales,
+    item,
+    date_dim,
+    customer
+  WHERE sold_date_sk = d_date_sk
+    AND item_sk = i_item_sk
+    AND i_category = 'Women'
+    AND i_class = 'maternity'
+    AND c_customer_sk = cs_or_ws_sales.customer_sk
+    AND d_moy = 12
+    AND d_year = 1998
+)
+  , my_revenue AS (
+  SELECT
+    c_customer_sk,
+    sum(ss_ext_sales_price) AS revenue
+  FROM my_customers,
+    store_sales,
+    customer_address,
+    store,
+    date_dim
+  WHERE c_current_addr_sk = ca_address_sk
+    AND ca_county = s_county
+    AND ca_state = s_state
+    AND ss_sold_date_sk = d_date_sk
+    AND c_customer_sk = ss_customer_sk
+    AND d_month_seq BETWEEN (SELECT DISTINCT d_month_seq + 1
+  FROM date_dim
+  WHERE d_year = 1998 AND d_moy = 12)
+  AND (SELECT DISTINCT d_month_seq + 3
+  FROM date_dim
+  WHERE d_year = 1998 AND d_moy = 12)
+  GROUP BY c_customer_sk
+)
+  , segments AS
+(SELECT cast((revenue / 50) AS INT) AS segment
+  FROM my_revenue)
+SELECT
+  segment,
+  count(*) AS num_customers,
+  segment * 50 AS segment_base
+FROM segments
+GROUP BY segment
+ORDER BY segment, num_customers
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q55.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q55.sql b/sql/core/src/test/resources/tpcds/q55.sql
new file mode 100755
index 0000000..bc5d888
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q55.sql
@@ -0,0 +1,13 @@
+SELECT
+  i_brand_id brand_id,
+  i_brand brand,
+  sum(ss_ext_sales_price) ext_price
+FROM date_dim, store_sales, item
+WHERE d_date_sk = ss_sold_date_sk
+  AND ss_item_sk = i_item_sk
+  AND i_manager_id = 28
+  AND d_moy = 11
+  AND d_year = 1999
+GROUP BY i_brand, i_brand_id
+ORDER BY ext_price DESC, brand_id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q56.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q56.sql b/sql/core/src/test/resources/tpcds/q56.sql
new file mode 100755
index 0000000..2fa1738
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q56.sql
@@ -0,0 +1,65 @@
+WITH ss AS (
+  SELECT
+    i_item_id,
+    sum(ss_ext_sales_price) total_sales
+  FROM
+    store_sales, date_dim, customer_address, item
+  WHERE
+    i_item_id IN (SELECT i_item_id
+    FROM item
+    WHERE i_color IN ('slate', 'blanched', 'burnished'))
+      AND ss_item_sk = i_item_sk
+      AND ss_sold_date_sk = d_date_sk
+      AND d_year = 2001
+      AND d_moy = 2
+      AND ss_addr_sk = ca_address_sk
+      AND ca_gmt_offset = -5
+  GROUP BY i_item_id),
+    cs AS (
+    SELECT
+      i_item_id,
+      sum(cs_ext_sales_price) total_sales
+    FROM
+      catalog_sales, date_dim, customer_address, item
+    WHERE
+      i_item_id IN (SELECT i_item_id
+      FROM item
+      WHERE i_color IN ('slate', 'blanched', 'burnished'))
+        AND cs_item_sk = i_item_sk
+        AND cs_sold_date_sk = d_date_sk
+        AND d_year = 2001
+        AND d_moy = 2
+        AND cs_bill_addr_sk = ca_address_sk
+        AND ca_gmt_offset = -5
+    GROUP BY i_item_id),
+    ws AS (
+    SELECT
+      i_item_id,
+      sum(ws_ext_sales_price) total_sales
+    FROM
+      web_sales, date_dim, customer_address, item
+    WHERE
+      i_item_id IN (SELECT i_item_id
+      FROM item
+      WHERE i_color IN ('slate', 'blanched', 'burnished'))
+        AND ws_item_sk = i_item_sk
+        AND ws_sold_date_sk = d_date_sk
+        AND d_year = 2001
+        AND d_moy = 2
+        AND ws_bill_addr_sk = ca_address_sk
+        AND ca_gmt_offset = -5
+    GROUP BY i_item_id)
+SELECT
+  i_item_id,
+  sum(total_sales) total_sales
+FROM (SELECT *
+      FROM ss
+      UNION ALL
+      SELECT *
+      FROM cs
+      UNION ALL
+      SELECT *
+      FROM ws) tmp1
+GROUP BY i_item_id
+ORDER BY total_sales
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q57.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q57.sql b/sql/core/src/test/resources/tpcds/q57.sql
new file mode 100755
index 0000000..cf70d4b
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q57.sql
@@ -0,0 +1,56 @@
+WITH v1 AS (
+  SELECT
+    i_category,
+    i_brand,
+    cc_name,
+    d_year,
+    d_moy,
+    sum(cs_sales_price) sum_sales,
+    avg(sum(cs_sales_price))
+    OVER
+    (PARTITION BY i_category, i_brand, cc_name, d_year)
+    avg_monthly_sales,
+    rank()
+    OVER
+    (PARTITION BY i_category, i_brand, cc_name
+      ORDER BY d_year, d_moy) rn
+  FROM item, catalog_sales, date_dim, call_center
+  WHERE cs_item_sk = i_item_sk AND
+    cs_sold_date_sk = d_date_sk AND
+    cc_call_center_sk = cs_call_center_sk AND
+    (
+      d_year = 1999 OR
+        (d_year = 1999 - 1 AND d_moy = 12) OR
+        (d_year = 1999 + 1 AND d_moy = 1)
+    )
+  GROUP BY i_category, i_brand,
+    cc_name, d_year, d_moy),
+    v2 AS (
+    SELECT
+      v1.i_category,
+      v1.i_brand,
+      v1.cc_name,
+      v1.d_year,
+      v1.d_moy,
+      v1.avg_monthly_sales,
+      v1.sum_sales,
+      v1_lag.sum_sales psum,
+      v1_lead.sum_sales nsum
+    FROM v1, v1 v1_lag, v1 v1_lead
+    WHERE v1.i_category = v1_lag.i_category AND
+      v1.i_category = v1_lead.i_category AND
+      v1.i_brand = v1_lag.i_brand AND
+      v1.i_brand = v1_lead.i_brand AND
+      v1.cc_name = v1_lag.cc_name AND
+      v1.cc_name = v1_lead.cc_name AND
+      v1.rn = v1_lag.rn + 1 AND
+      v1.rn = v1_lead.rn - 1)
+SELECT *
+FROM v2
+WHERE d_year = 1999 AND
+  avg_monthly_sales > 0 AND
+  CASE WHEN avg_monthly_sales > 0
+    THEN abs(sum_sales - avg_monthly_sales) / avg_monthly_sales
+  ELSE NULL END > 0.1
+ORDER BY sum_sales - avg_monthly_sales, 3
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q58.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q58.sql b/sql/core/src/test/resources/tpcds/q58.sql
new file mode 100755
index 0000000..5f63f33
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q58.sql
@@ -0,0 +1,59 @@
+WITH ss_items AS
+(SELECT
+    i_item_id item_id,
+    sum(ss_ext_sales_price) ss_item_rev
+  FROM store_sales, item, date_dim
+  WHERE ss_item_sk = i_item_sk
+    AND d_date IN (SELECT d_date
+  FROM date_dim
+  WHERE d_week_seq = (SELECT d_week_seq
+  FROM date_dim
+  WHERE d_date = '2000-01-03'))
+    AND ss_sold_date_sk = d_date_sk
+  GROUP BY i_item_id),
+    cs_items AS
+  (SELECT
+    i_item_id item_id,
+    sum(cs_ext_sales_price) cs_item_rev
+  FROM catalog_sales, item, date_dim
+  WHERE cs_item_sk = i_item_sk
+    AND d_date IN (SELECT d_date
+  FROM date_dim
+  WHERE d_week_seq = (SELECT d_week_seq
+  FROM date_dim
+  WHERE d_date = '2000-01-03'))
+    AND cs_sold_date_sk = d_date_sk
+  GROUP BY i_item_id),
+    ws_items AS
+  (SELECT
+    i_item_id item_id,
+    sum(ws_ext_sales_price) ws_item_rev
+  FROM web_sales, item, date_dim
+  WHERE ws_item_sk = i_item_sk
+    AND d_date IN (SELECT d_date
+  FROM date_dim
+  WHERE d_week_seq = (SELECT d_week_seq
+  FROM date_dim
+  WHERE d_date = '2000-01-03'))
+    AND ws_sold_date_sk = d_date_sk
+  GROUP BY i_item_id)
+SELECT
+  ss_items.item_id,
+  ss_item_rev,
+  ss_item_rev / (ss_item_rev + cs_item_rev + ws_item_rev) / 3 * 100 ss_dev,
+  cs_item_rev,
+  cs_item_rev / (ss_item_rev + cs_item_rev + ws_item_rev) / 3 * 100 cs_dev,
+  ws_item_rev,
+  ws_item_rev / (ss_item_rev + cs_item_rev + ws_item_rev) / 3 * 100 ws_dev,
+  (ss_item_rev + cs_item_rev + ws_item_rev) / 3 average
+FROM ss_items, cs_items, ws_items
+WHERE ss_items.item_id = cs_items.item_id
+  AND ss_items.item_id = ws_items.item_id
+  AND ss_item_rev BETWEEN 0.9 * cs_item_rev AND 1.1 * cs_item_rev
+  AND ss_item_rev BETWEEN 0.9 * ws_item_rev AND 1.1 * ws_item_rev
+  AND cs_item_rev BETWEEN 0.9 * ss_item_rev AND 1.1 * ss_item_rev
+  AND cs_item_rev BETWEEN 0.9 * ws_item_rev AND 1.1 * ws_item_rev
+  AND ws_item_rev BETWEEN 0.9 * ss_item_rev AND 1.1 * ss_item_rev
+  AND ws_item_rev BETWEEN 0.9 * cs_item_rev AND 1.1 * cs_item_rev
+ORDER BY item_id, ss_item_rev
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q59.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q59.sql b/sql/core/src/test/resources/tpcds/q59.sql
new file mode 100755
index 0000000..3cef202
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q59.sql
@@ -0,0 +1,75 @@
+WITH wss AS
+(SELECT
+    d_week_seq,
+    ss_store_sk,
+    sum(CASE WHEN (d_day_name = 'Sunday')
+      THEN ss_sales_price
+        ELSE NULL END) sun_sales,
+    sum(CASE WHEN (d_day_name = 'Monday')
+      THEN ss_sales_price
+        ELSE NULL END) mon_sales,
+    sum(CASE WHEN (d_day_name = 'Tuesday')
+      THEN ss_sales_price
+        ELSE NULL END) tue_sales,
+    sum(CASE WHEN (d_day_name = 'Wednesday')
+      THEN ss_sales_price
+        ELSE NULL END) wed_sales,
+    sum(CASE WHEN (d_day_name = 'Thursday')
+      THEN ss_sales_price
+        ELSE NULL END) thu_sales,
+    sum(CASE WHEN (d_day_name = 'Friday')
+      THEN ss_sales_price
+        ELSE NULL END) fri_sales,
+    sum(CASE WHEN (d_day_name = 'Saturday')
+      THEN ss_sales_price
+        ELSE NULL END) sat_sales
+  FROM store_sales, date_dim
+  WHERE d_date_sk = ss_sold_date_sk
+  GROUP BY d_week_seq, ss_store_sk
+)
+SELECT
+  s_store_name1,
+  s_store_id1,
+  d_week_seq1,
+  sun_sales1 / sun_sales2,
+  mon_sales1 / mon_sales2,
+  tue_sales1 / tue_sales2,
+  wed_sales1 / wed_sales2,
+  thu_sales1 / thu_sales2,
+  fri_sales1 / fri_sales2,
+  sat_sales1 / sat_sales2
+FROM
+  (SELECT
+    s_store_name s_store_name1,
+    wss.d_week_seq d_week_seq1,
+    s_store_id s_store_id1,
+    sun_sales sun_sales1,
+    mon_sales mon_sales1,
+    tue_sales tue_sales1,
+    wed_sales wed_sales1,
+    thu_sales thu_sales1,
+    fri_sales fri_sales1,
+    sat_sales sat_sales1
+  FROM wss, store, date_dim d
+  WHERE d.d_week_seq = wss.d_week_seq AND
+    ss_store_sk = s_store_sk AND
+    d_month_seq BETWEEN 1212 AND 1212 + 11) y,
+  (SELECT
+    s_store_name s_store_name2,
+    wss.d_week_seq d_week_seq2,
+    s_store_id s_store_id2,
+    sun_sales sun_sales2,
+    mon_sales mon_sales2,
+    tue_sales tue_sales2,
+    wed_sales wed_sales2,
+    thu_sales thu_sales2,
+    fri_sales fri_sales2,
+    sat_sales sat_sales2
+  FROM wss, store, date_dim d
+  WHERE d.d_week_seq = wss.d_week_seq AND
+    ss_store_sk = s_store_sk AND
+    d_month_seq BETWEEN 1212 + 12 AND 1212 + 23) x
+WHERE s_store_id1 = s_store_id2
+  AND d_week_seq1 = d_week_seq2 - 52
+ORDER BY s_store_name1, s_store_id1, d_week_seq1
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q6.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q6.sql b/sql/core/src/test/resources/tpcds/q6.sql
new file mode 100755
index 0000000..f0f5cf0
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q6.sql
@@ -0,0 +1,21 @@
+SELECT
+  a.ca_state state,
+  count(*) cnt
+FROM
+  customer_address a, customer c, store_sales s, date_dim d, item i
+WHERE a.ca_address_sk = c.c_current_addr_sk
+  AND c.c_customer_sk = s.ss_customer_sk
+  AND s.ss_sold_date_sk = d.d_date_sk
+  AND s.ss_item_sk = i.i_item_sk
+  AND d.d_month_seq =
+  (SELECT DISTINCT (d_month_seq)
+  FROM date_dim
+  WHERE d_year = 2000 AND d_moy = 1)
+  AND i.i_current_price > 1.2 *
+  (SELECT avg(j.i_current_price)
+  FROM item j
+  WHERE j.i_category = i.i_category)
+GROUP BY a.ca_state
+HAVING count(*) >= 10
+ORDER BY cnt
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q60.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q60.sql b/sql/core/src/test/resources/tpcds/q60.sql
new file mode 100755
index 0000000..41b963f
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q60.sql
@@ -0,0 +1,62 @@
+WITH ss AS (
+  SELECT
+    i_item_id,
+    sum(ss_ext_sales_price) total_sales
+  FROM store_sales, date_dim, customer_address, item
+  WHERE
+    i_item_id IN (SELECT i_item_id
+    FROM item
+    WHERE i_category IN ('Music'))
+      AND ss_item_sk = i_item_sk
+      AND ss_sold_date_sk = d_date_sk
+      AND d_year = 1998
+      AND d_moy = 9
+      AND ss_addr_sk = ca_address_sk
+      AND ca_gmt_offset = -5
+  GROUP BY i_item_id),
+    cs AS (
+    SELECT
+      i_item_id,
+      sum(cs_ext_sales_price) total_sales
+    FROM catalog_sales, date_dim, customer_address, item
+    WHERE
+      i_item_id IN (SELECT i_item_id
+      FROM item
+      WHERE i_category IN ('Music'))
+        AND cs_item_sk = i_item_sk
+        AND cs_sold_date_sk = d_date_sk
+        AND d_year = 1998
+        AND d_moy = 9
+        AND cs_bill_addr_sk = ca_address_sk
+        AND ca_gmt_offset = -5
+    GROUP BY i_item_id),
+    ws AS (
+    SELECT
+      i_item_id,
+      sum(ws_ext_sales_price) total_sales
+    FROM web_sales, date_dim, customer_address, item
+    WHERE
+      i_item_id IN (SELECT i_item_id
+      FROM item
+      WHERE i_category IN ('Music'))
+        AND ws_item_sk = i_item_sk
+        AND ws_sold_date_sk = d_date_sk
+        AND d_year = 1998
+        AND d_moy = 9
+        AND ws_bill_addr_sk = ca_address_sk
+        AND ca_gmt_offset = -5
+    GROUP BY i_item_id)
+SELECT
+  i_item_id,
+  sum(total_sales) total_sales
+FROM (SELECT *
+      FROM ss
+      UNION ALL
+      SELECT *
+      FROM cs
+      UNION ALL
+      SELECT *
+      FROM ws) tmp1
+GROUP BY i_item_id
+ORDER BY i_item_id, total_sales
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q61.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q61.sql b/sql/core/src/test/resources/tpcds/q61.sql
new file mode 100755
index 0000000..b0a872b
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q61.sql
@@ -0,0 +1,33 @@
+SELECT
+  promotions,
+  total,
+  cast(promotions AS DECIMAL(15, 4)) / cast(total AS DECIMAL(15, 4)) * 100
+FROM
+  (SELECT sum(ss_ext_sales_price) promotions
+  FROM store_sales, store, promotion, date_dim, customer, customer_address, item
+  WHERE ss_sold_date_sk = d_date_sk
+    AND ss_store_sk = s_store_sk
+    AND ss_promo_sk = p_promo_sk
+    AND ss_customer_sk = c_customer_sk
+    AND ca_address_sk = c_current_addr_sk
+    AND ss_item_sk = i_item_sk
+    AND ca_gmt_offset = -5
+    AND i_category = 'Jewelry'
+    AND (p_channel_dmail = 'Y' OR p_channel_email = 'Y' OR p_channel_tv = 'Y')
+    AND s_gmt_offset = -5
+    AND d_year = 1998
+    AND d_moy = 11) promotional_sales,
+  (SELECT sum(ss_ext_sales_price) total
+  FROM store_sales, store, date_dim, customer, customer_address, item
+  WHERE ss_sold_date_sk = d_date_sk
+    AND ss_store_sk = s_store_sk
+    AND ss_customer_sk = c_customer_sk
+    AND ca_address_sk = c_current_addr_sk
+    AND ss_item_sk = i_item_sk
+    AND ca_gmt_offset = -5
+    AND i_category = 'Jewelry'
+    AND s_gmt_offset = -5
+    AND d_year = 1998
+    AND d_moy = 11) all_sales
+ORDER BY promotions, total
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q62.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q62.sql b/sql/core/src/test/resources/tpcds/q62.sql
new file mode 100755
index 0000000..8a414f1
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q62.sql
@@ -0,0 +1,35 @@
+SELECT
+  substr(w_warehouse_name, 1, 20),
+  sm_type,
+  web_name,
+  sum(CASE WHEN (ws_ship_date_sk - ws_sold_date_sk <= 30)
+    THEN 1
+      ELSE 0 END)  AS `30 days `,
+  sum(CASE WHEN (ws_ship_date_sk - ws_sold_date_sk > 30) AND
+    (ws_ship_date_sk - ws_sold_date_sk <= 60)
+    THEN 1
+      ELSE 0 END)  AS `31 - 60 days `,
+  sum(CASE WHEN (ws_ship_date_sk - ws_sold_date_sk > 60) AND
+    (ws_ship_date_sk - ws_sold_date_sk <= 90)
+    THEN 1
+      ELSE 0 END)  AS `61 - 90 days `,
+  sum(CASE WHEN (ws_ship_date_sk - ws_sold_date_sk > 90) AND
+    (ws_ship_date_sk - ws_sold_date_sk <= 120)
+    THEN 1
+      ELSE 0 END)  AS `91 - 120 days `,
+  sum(CASE WHEN (ws_ship_date_sk - ws_sold_date_sk > 120)
+    THEN 1
+      ELSE 0 END)  AS `>120 days `
+FROM
+  web_sales, warehouse, ship_mode, web_site, date_dim
+WHERE
+  d_month_seq BETWEEN 1200 AND 1200 + 11
+    AND ws_ship_date_sk = d_date_sk
+    AND ws_warehouse_sk = w_warehouse_sk
+    AND ws_ship_mode_sk = sm_ship_mode_sk
+    AND ws_web_site_sk = web_site_sk
+GROUP BY
+  substr(w_warehouse_name, 1, 20), sm_type, web_name
+ORDER BY
+  substr(w_warehouse_name, 1, 20), sm_type, web_name
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q63.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q63.sql b/sql/core/src/test/resources/tpcds/q63.sql
new file mode 100755
index 0000000..ef6867e
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q63.sql
@@ -0,0 +1,31 @@
+SELECT *
+FROM (SELECT
+  i_manager_id,
+  sum(ss_sales_price) sum_sales,
+  avg(sum(ss_sales_price))
+  OVER (PARTITION BY i_manager_id) avg_monthly_sales
+FROM item
+  , store_sales
+  , date_dim
+  , store
+WHERE ss_item_sk = i_item_sk
+  AND ss_sold_date_sk = d_date_sk
+  AND ss_store_sk = s_store_sk
+  AND d_month_seq IN (1200, 1200 + 1, 1200 + 2, 1200 + 3, 1200 + 4, 1200 + 5, 1200 + 6, 1200 + 7,
+                            1200 + 8, 1200 + 9, 1200 + 10, 1200 + 11)
+  AND ((i_category IN ('Books', 'Children', 'Electronics')
+  AND i_class IN ('personal', 'portable', 'refernece', 'self-help')
+  AND i_brand IN ('scholaramalgamalg #14', 'scholaramalgamalg #7',
+                  'exportiunivamalg #9', 'scholaramalgamalg #9'))
+  OR (i_category IN ('Women', 'Music', 'Men')
+  AND i_class IN ('accessories', 'classical', 'fragrances', 'pants')
+  AND i_brand IN ('amalgimporto #1', 'edu packscholar #1', 'exportiimporto #1',
+                  'importoamalg #1')))
+GROUP BY i_manager_id, d_moy) tmp1
+WHERE CASE WHEN avg_monthly_sales > 0
+  THEN abs(sum_sales - avg_monthly_sales) / avg_monthly_sales
+      ELSE NULL END > 0.1
+ORDER BY i_manager_id
+  , avg_monthly_sales
+  , sum_sales
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q64.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q64.sql b/sql/core/src/test/resources/tpcds/q64.sql
new file mode 100755
index 0000000..8ec1d31
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q64.sql
@@ -0,0 +1,92 @@
+WITH cs_ui AS
+(SELECT
+    cs_item_sk,
+    sum(cs_ext_list_price) AS sale,
+    sum(cr_refunded_cash + cr_reversed_charge + cr_store_credit) AS refund
+  FROM catalog_sales
+    , catalog_returns
+  WHERE cs_item_sk = cr_item_sk
+    AND cs_order_number = cr_order_number
+  GROUP BY cs_item_sk
+  HAVING sum(cs_ext_list_price) > 2 * sum(cr_refunded_cash + cr_reversed_charge + cr_store_credit)),
+    cross_sales AS
+  (SELECT
+    i_product_name product_name,
+    i_item_sk item_sk,
+    s_store_name store_name,
+    s_zip store_zip,
+    ad1.ca_street_number b_street_number,
+    ad1.ca_street_name b_streen_name,
+    ad1.ca_city b_city,
+    ad1.ca_zip b_zip,
+    ad2.ca_street_number c_street_number,
+    ad2.ca_street_name c_street_name,
+    ad2.ca_city c_city,
+    ad2.ca_zip c_zip,
+    d1.d_year AS syear,
+    d2.d_year AS fsyear,
+    d3.d_year s2year,
+    count(*) cnt,
+    sum(ss_wholesale_cost) s1,
+    sum(ss_list_price) s2,
+    sum(ss_coupon_amt) s3
+  FROM store_sales, store_returns, cs_ui, date_dim d1, date_dim d2, date_dim d3,
+    store, customer, customer_demographics cd1, customer_demographics cd2,
+    promotion, household_demographics hd1, household_demographics hd2,
+    customer_address ad1, customer_address ad2, income_band ib1, income_band ib2, item
+  WHERE ss_store_sk = s_store_sk AND
+    ss_sold_date_sk = d1.d_date_sk AND
+    ss_customer_sk = c_customer_sk AND
+    ss_cdemo_sk = cd1.cd_demo_sk AND
+    ss_hdemo_sk = hd1.hd_demo_sk AND
+    ss_addr_sk = ad1.ca_address_sk AND
+    ss_item_sk = i_item_sk AND
+    ss_item_sk = sr_item_sk AND
+    ss_ticket_number = sr_ticket_number AND
+    ss_item_sk = cs_ui.cs_item_sk AND
+    c_current_cdemo_sk = cd2.cd_demo_sk AND
+    c_current_hdemo_sk = hd2.hd_demo_sk AND
+    c_current_addr_sk = ad2.ca_address_sk AND
+    c_first_sales_date_sk = d2.d_date_sk AND
+    c_first_shipto_date_sk = d3.d_date_sk AND
+    ss_promo_sk = p_promo_sk AND
+    hd1.hd_income_band_sk = ib1.ib_income_band_sk AND
+    hd2.hd_income_band_sk = ib2.ib_income_band_sk AND
+    cd1.cd_marital_status <> cd2.cd_marital_status AND
+    i_color IN ('purple', 'burlywood', 'indian', 'spring', 'floral', 'medium') AND
+    i_current_price BETWEEN 64 AND 64 + 10 AND
+    i_current_price BETWEEN 64 + 1 AND 64 + 15
+  GROUP BY i_product_name, i_item_sk, s_store_name, s_zip, ad1.ca_street_number,
+    ad1.ca_street_name, ad1.ca_city, ad1.ca_zip, ad2.ca_street_number,
+    ad2.ca_street_name, ad2.ca_city, ad2.ca_zip, d1.d_year, d2.d_year, d3.d_year
+  )
+SELECT
+  cs1.product_name,
+  cs1.store_name,
+  cs1.store_zip,
+  cs1.b_street_number,
+  cs1.b_streen_name,
+  cs1.b_city,
+  cs1.b_zip,
+  cs1.c_street_number,
+  cs1.c_street_name,
+  cs1.c_city,
+  cs1.c_zip,
+  cs1.syear,
+  cs1.cnt,
+  cs1.s1,
+  cs1.s2,
+  cs1.s3,
+  cs2.s1,
+  cs2.s2,
+  cs2.s3,
+  cs2.syear,
+  cs2.cnt
+FROM cross_sales cs1, cross_sales cs2
+WHERE cs1.item_sk = cs2.item_sk AND
+  cs1.syear = 1999 AND
+  cs2.syear = 1999 + 1 AND
+  cs2.cnt <= cs1.cnt AND
+  cs1.store_name = cs2.store_name AND
+  cs1.store_zip = cs2.store_zip
+ORDER BY cs1.product_name, cs1.store_name, cs2.cnt

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q65.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q65.sql b/sql/core/src/test/resources/tpcds/q65.sql
new file mode 100755
index 0000000..aad04be
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q65.sql
@@ -0,0 +1,33 @@
+SELECT
+  s_store_name,
+  i_item_desc,
+  sc.revenue,
+  i_current_price,
+  i_wholesale_cost,
+  i_brand
+FROM store, item,
+  (SELECT
+    ss_store_sk,
+    avg(revenue) AS ave
+  FROM
+    (SELECT
+      ss_store_sk,
+      ss_item_sk,
+      sum(ss_sales_price) AS revenue
+    FROM store_sales, date_dim
+    WHERE ss_sold_date_sk = d_date_sk AND d_month_seq BETWEEN 1176 AND 1176 + 11
+    GROUP BY ss_store_sk, ss_item_sk) sa
+  GROUP BY ss_store_sk) sb,
+  (SELECT
+    ss_store_sk,
+    ss_item_sk,
+    sum(ss_sales_price) AS revenue
+  FROM store_sales, date_dim
+  WHERE ss_sold_date_sk = d_date_sk AND d_month_seq BETWEEN 1176 AND 1176 + 11
+  GROUP BY ss_store_sk, ss_item_sk) sc
+WHERE sb.ss_store_sk = sc.ss_store_sk AND
+  sc.revenue <= 0.1 * sb.ave AND
+  s_store_sk = sc.ss_store_sk AND
+  i_item_sk = sc.ss_item_sk
+ORDER BY s_store_name, i_item_desc
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q66.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q66.sql b/sql/core/src/test/resources/tpcds/q66.sql
new file mode 100755
index 0000000..f826b41
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q66.sql
@@ -0,0 +1,240 @@
+SELECT
+  w_warehouse_name,
+  w_warehouse_sq_ft,
+  w_city,
+  w_county,
+  w_state,
+  w_country,
+  ship_carriers,
+  year,
+  sum(jan_sales) AS jan_sales,
+  sum(feb_sales) AS feb_sales,
+  sum(mar_sales) AS mar_sales,
+  sum(apr_sales) AS apr_sales,
+  sum(may_sales) AS may_sales,
+  sum(jun_sales) AS jun_sales,
+  sum(jul_sales) AS jul_sales,
+  sum(aug_sales) AS aug_sales,
+  sum(sep_sales) AS sep_sales,
+  sum(oct_sales) AS oct_sales,
+  sum(nov_sales) AS nov_sales,
+  sum(dec_sales) AS dec_sales,
+  sum(jan_sales / w_warehouse_sq_ft) AS jan_sales_per_sq_foot,
+  sum(feb_sales / w_warehouse_sq_ft) AS feb_sales_per_sq_foot,
+  sum(mar_sales / w_warehouse_sq_ft) AS mar_sales_per_sq_foot,
+  sum(apr_sales / w_warehouse_sq_ft) AS apr_sales_per_sq_foot,
+  sum(may_sales / w_warehouse_sq_ft) AS may_sales_per_sq_foot,
+  sum(jun_sales / w_warehouse_sq_ft) AS jun_sales_per_sq_foot,
+  sum(jul_sales / w_warehouse_sq_ft) AS jul_sales_per_sq_foot,
+  sum(aug_sales / w_warehouse_sq_ft) AS aug_sales_per_sq_foot,
+  sum(sep_sales / w_warehouse_sq_ft) AS sep_sales_per_sq_foot,
+  sum(oct_sales / w_warehouse_sq_ft) AS oct_sales_per_sq_foot,
+  sum(nov_sales / w_warehouse_sq_ft) AS nov_sales_per_sq_foot,
+  sum(dec_sales / w_warehouse_sq_ft) AS dec_sales_per_sq_foot,
+  sum(jan_net) AS jan_net,
+  sum(feb_net) AS feb_net,
+  sum(mar_net) AS mar_net,
+  sum(apr_net) AS apr_net,
+  sum(may_net) AS may_net,
+  sum(jun_net) AS jun_net,
+  sum(jul_net) AS jul_net,
+  sum(aug_net) AS aug_net,
+  sum(sep_net) AS sep_net,
+  sum(oct_net) AS oct_net,
+  sum(nov_net) AS nov_net,
+  sum(dec_net) AS dec_net
+FROM (
+       (SELECT
+         w_warehouse_name,
+         w_warehouse_sq_ft,
+         w_city,
+         w_county,
+         w_state,
+         w_country,
+         concat('DHL', ',', 'BARIAN') AS ship_carriers,
+         d_year AS year,
+         sum(CASE WHEN d_moy = 1
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS jan_sales,
+         sum(CASE WHEN d_moy = 2
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS feb_sales,
+         sum(CASE WHEN d_moy = 3
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS mar_sales,
+         sum(CASE WHEN d_moy = 4
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS apr_sales,
+         sum(CASE WHEN d_moy = 5
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS may_sales,
+         sum(CASE WHEN d_moy = 6
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS jun_sales,
+         sum(CASE WHEN d_moy = 7
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS jul_sales,
+         sum(CASE WHEN d_moy = 8
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS aug_sales,
+         sum(CASE WHEN d_moy = 9
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS sep_sales,
+         sum(CASE WHEN d_moy = 10
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS oct_sales,
+         sum(CASE WHEN d_moy = 11
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS nov_sales,
+         sum(CASE WHEN d_moy = 12
+           THEN ws_ext_sales_price * ws_quantity
+             ELSE 0 END) AS dec_sales,
+         sum(CASE WHEN d_moy = 1
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS jan_net,
+         sum(CASE WHEN d_moy = 2
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS feb_net,
+         sum(CASE WHEN d_moy = 3
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS mar_net,
+         sum(CASE WHEN d_moy = 4
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS apr_net,
+         sum(CASE WHEN d_moy = 5
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS may_net,
+         sum(CASE WHEN d_moy = 6
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS jun_net,
+         sum(CASE WHEN d_moy = 7
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS jul_net,
+         sum(CASE WHEN d_moy = 8
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS aug_net,
+         sum(CASE WHEN d_moy = 9
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS sep_net,
+         sum(CASE WHEN d_moy = 10
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS oct_net,
+         sum(CASE WHEN d_moy = 11
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS nov_net,
+         sum(CASE WHEN d_moy = 12
+           THEN ws_net_paid * ws_quantity
+             ELSE 0 END) AS dec_net
+       FROM
+         web_sales, warehouse, date_dim, time_dim, ship_mode
+       WHERE
+         ws_warehouse_sk = w_warehouse_sk
+           AND ws_sold_date_sk = d_date_sk
+           AND ws_sold_time_sk = t_time_sk
+           AND ws_ship_mode_sk = sm_ship_mode_sk
+           AND d_year = 2001
+           AND t_time BETWEEN 30838 AND 30838 + 28800
+           AND sm_carrier IN ('DHL', 'BARIAN')
+       GROUP BY
+         w_warehouse_name, w_warehouse_sq_ft, w_city, w_county, w_state, w_country, d_year)
+       UNION ALL
+       (SELECT
+         w_warehouse_name,
+         w_warehouse_sq_ft,
+         w_city,
+         w_county,
+         w_state,
+         w_country,
+         concat('DHL', ',', 'BARIAN') AS ship_carriers,
+         d_year AS year,
+         sum(CASE WHEN d_moy = 1
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS jan_sales,
+         sum(CASE WHEN d_moy = 2
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS feb_sales,
+         sum(CASE WHEN d_moy = 3
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS mar_sales,
+         sum(CASE WHEN d_moy = 4
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS apr_sales,
+         sum(CASE WHEN d_moy = 5
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS may_sales,
+         sum(CASE WHEN d_moy = 6
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS jun_sales,
+         sum(CASE WHEN d_moy = 7
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS jul_sales,
+         sum(CASE WHEN d_moy = 8
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS aug_sales,
+         sum(CASE WHEN d_moy = 9
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS sep_sales,
+         sum(CASE WHEN d_moy = 10
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS oct_sales,
+         sum(CASE WHEN d_moy = 11
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS nov_sales,
+         sum(CASE WHEN d_moy = 12
+           THEN cs_sales_price * cs_quantity
+             ELSE 0 END) AS dec_sales,
+         sum(CASE WHEN d_moy = 1
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS jan_net,
+         sum(CASE WHEN d_moy = 2
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS feb_net,
+         sum(CASE WHEN d_moy = 3
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS mar_net,
+         sum(CASE WHEN d_moy = 4
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS apr_net,
+         sum(CASE WHEN d_moy = 5
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS may_net,
+         sum(CASE WHEN d_moy = 6
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS jun_net,
+         sum(CASE WHEN d_moy = 7
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS jul_net,
+         sum(CASE WHEN d_moy = 8
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS aug_net,
+         sum(CASE WHEN d_moy = 9
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS sep_net,
+         sum(CASE WHEN d_moy = 10
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS oct_net,
+         sum(CASE WHEN d_moy = 11
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS nov_net,
+         sum(CASE WHEN d_moy = 12
+           THEN cs_net_paid_inc_tax * cs_quantity
+             ELSE 0 END) AS dec_net
+       FROM
+         catalog_sales, warehouse, date_dim, time_dim, ship_mode
+       WHERE
+         cs_warehouse_sk = w_warehouse_sk
+           AND cs_sold_date_sk = d_date_sk
+           AND cs_sold_time_sk = t_time_sk
+           AND cs_ship_mode_sk = sm_ship_mode_sk
+           AND d_year = 2001
+           AND t_time BETWEEN 30838 AND 30838 + 28800
+           AND sm_carrier IN ('DHL', 'BARIAN')
+       GROUP BY
+         w_warehouse_name, w_warehouse_sq_ft, w_city, w_county, w_state, w_country, d_year
+       )
+     ) x
+GROUP BY
+  w_warehouse_name, w_warehouse_sq_ft, w_city, w_county, w_state, w_country,
+  ship_carriers, year
+ORDER BY w_warehouse_name
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q67.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q67.sql b/sql/core/src/test/resources/tpcds/q67.sql
new file mode 100755
index 0000000..f66e225
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q67.sql
@@ -0,0 +1,38 @@
+SELECT *
+FROM
+  (SELECT
+    i_category,
+    i_class,
+    i_brand,
+    i_product_name,
+    d_year,
+    d_qoy,
+    d_moy,
+    s_store_id,
+    sumsales,
+    rank()
+    OVER (PARTITION BY i_category
+      ORDER BY sumsales DESC) rk
+  FROM
+    (SELECT
+      i_category,
+      i_class,
+      i_brand,
+      i_product_name,
+      d_year,
+      d_qoy,
+      d_moy,
+      s_store_id,
+      sum(coalesce(ss_sales_price * ss_quantity, 0)) sumsales
+    FROM store_sales, date_dim, store, item
+    WHERE ss_sold_date_sk = d_date_sk
+      AND ss_item_sk = i_item_sk
+      AND ss_store_sk = s_store_sk
+      AND d_month_seq BETWEEN 1200 AND 1200 + 11
+    GROUP BY ROLLUP (i_category, i_class, i_brand, i_product_name, d_year, d_qoy,
+      d_moy, s_store_id)) dw1) dw2
+WHERE rk <= 100
+ORDER BY
+  i_category, i_class, i_brand, i_product_name, d_year,
+  d_qoy, d_moy, s_store_id, sumsales, rk
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q68.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q68.sql b/sql/core/src/test/resources/tpcds/q68.sql
new file mode 100755
index 0000000..adb8a71
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q68.sql
@@ -0,0 +1,34 @@
+SELECT
+  c_last_name,
+  c_first_name,
+  ca_city,
+  bought_city,
+  ss_ticket_number,
+  extended_price,
+  extended_tax,
+  list_price
+FROM (SELECT
+  ss_ticket_number,
+  ss_customer_sk,
+  ca_city bought_city,
+  sum(ss_ext_sales_price) extended_price,
+  sum(ss_ext_list_price) list_price,
+  sum(ss_ext_tax) extended_tax
+FROM store_sales, date_dim, store, household_demographics, customer_address
+WHERE store_sales.ss_sold_date_sk = date_dim.d_date_sk
+  AND store_sales.ss_store_sk = store.s_store_sk
+  AND store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+  AND store_sales.ss_addr_sk = customer_address.ca_address_sk
+  AND date_dim.d_dom BETWEEN 1 AND 2
+  AND (household_demographics.hd_dep_count = 4 OR
+  household_demographics.hd_vehicle_count = 3)
+  AND date_dim.d_year IN (1999, 1999 + 1, 1999 + 2)
+  AND store.s_city IN ('Midway', 'Fairview')
+GROUP BY ss_ticket_number, ss_customer_sk, ss_addr_sk, ca_city) dn,
+  customer,
+  customer_address current_addr
+WHERE ss_customer_sk = c_customer_sk
+  AND customer.c_current_addr_sk = current_addr.ca_address_sk
+  AND current_addr.ca_city <> bought_city
+ORDER BY c_last_name, ss_ticket_number
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q69.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q69.sql b/sql/core/src/test/resources/tpcds/q69.sql
new file mode 100755
index 0000000..1f0ee64
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q69.sql
@@ -0,0 +1,38 @@
+SELECT
+  cd_gender,
+  cd_marital_status,
+  cd_education_status,
+  count(*) cnt1,
+  cd_purchase_estimate,
+  count(*) cnt2,
+  cd_credit_rating,
+  count(*) cnt3
+FROM
+  customer c, customer_address ca, customer_demographics
+WHERE
+  c.c_current_addr_sk = ca.ca_address_sk AND
+    ca_state IN ('KY', 'GA', 'NM') AND
+    cd_demo_sk = c.c_current_cdemo_sk AND
+    exists(SELECT *
+           FROM store_sales, date_dim
+           WHERE c.c_customer_sk = ss_customer_sk AND
+             ss_sold_date_sk = d_date_sk AND
+             d_year = 2001 AND
+             d_moy BETWEEN 4 AND 4 + 2) AND
+    (NOT exists(SELECT *
+                FROM web_sales, date_dim
+                WHERE c.c_customer_sk = ws_bill_customer_sk AND
+                  ws_sold_date_sk = d_date_sk AND
+                  d_year = 2001 AND
+                  d_moy BETWEEN 4 AND 4 + 2) AND
+      NOT exists(SELECT *
+                 FROM catalog_sales, date_dim
+                 WHERE c.c_customer_sk = cs_ship_customer_sk AND
+                   cs_sold_date_sk = d_date_sk AND
+                   d_year = 2001 AND
+                   d_moy BETWEEN 4 AND 4 + 2))
+GROUP BY cd_gender, cd_marital_status, cd_education_status,
+  cd_purchase_estimate, cd_credit_rating
+ORDER BY cd_gender, cd_marital_status, cd_education_status,
+  cd_purchase_estimate, cd_credit_rating
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q7.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q7.sql b/sql/core/src/test/resources/tpcds/q7.sql
new file mode 100755
index 0000000..6630a00
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q7.sql
@@ -0,0 +1,19 @@
+SELECT
+  i_item_id,
+  avg(ss_quantity) agg1,
+  avg(ss_list_price) agg2,
+  avg(ss_coupon_amt) agg3,
+  avg(ss_sales_price) agg4
+FROM store_sales, customer_demographics, date_dim, item, promotion
+WHERE ss_sold_date_sk = d_date_sk AND
+  ss_item_sk = i_item_sk AND
+  ss_cdemo_sk = cd_demo_sk AND
+  ss_promo_sk = p_promo_sk AND
+  cd_gender = 'M' AND
+  cd_marital_status = 'S' AND
+  cd_education_status = 'College' AND
+  (p_channel_email = 'N' OR p_channel_event = 'N') AND
+  d_year = 2000
+GROUP BY i_item_id
+ORDER BY i_item_id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q70.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q70.sql b/sql/core/src/test/resources/tpcds/q70.sql
new file mode 100755
index 0000000..625011b
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q70.sql
@@ -0,0 +1,38 @@
+SELECT
+  sum(ss_net_profit) AS total_sum,
+  s_state,
+  s_county,
+  grouping(s_state) + grouping(s_county) AS lochierarchy,
+  rank()
+  OVER (
+    PARTITION BY grouping(s_state) + grouping(s_county),
+      CASE WHEN grouping(s_county) = 0
+        THEN s_state END
+    ORDER BY sum(ss_net_profit) DESC) AS rank_within_parent
+FROM
+  store_sales, date_dim d1, store
+WHERE
+  d1.d_month_seq BETWEEN 1200 AND 1200 + 11
+    AND d1.d_date_sk = ss_sold_date_sk
+    AND s_store_sk = ss_store_sk
+    AND s_state IN
+    (SELECT s_state
+    FROM
+      (SELECT
+        s_state AS s_state,
+        rank()
+        OVER (PARTITION BY s_state
+          ORDER BY sum(ss_net_profit) DESC) AS ranking
+      FROM store_sales, store, date_dim
+      WHERE d_month_seq BETWEEN 1200 AND 1200 + 11
+        AND d_date_sk = ss_sold_date_sk
+        AND s_store_sk = ss_store_sk
+      GROUP BY s_state) tmp1
+    WHERE ranking <= 5)
+GROUP BY ROLLUP (s_state, s_county)
+ORDER BY
+  lochierarchy DESC
+  , CASE WHEN lochierarchy = 0
+  THEN s_state END
+  , rank_within_parent
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q71.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q71.sql b/sql/core/src/test/resources/tpcds/q71.sql
new file mode 100755
index 0000000..8d724b9
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q71.sql
@@ -0,0 +1,44 @@
+SELECT
+  i_brand_id brand_id,
+  i_brand brand,
+  t_hour,
+  t_minute,
+  sum(ext_price) ext_price
+FROM item,
+  (SELECT
+     ws_ext_sales_price AS ext_price,
+     ws_sold_date_sk AS sold_date_sk,
+     ws_item_sk AS sold_item_sk,
+     ws_sold_time_sk AS time_sk
+   FROM web_sales, date_dim
+   WHERE d_date_sk = ws_sold_date_sk
+     AND d_moy = 11
+     AND d_year = 1999
+   UNION ALL
+   SELECT
+     cs_ext_sales_price AS ext_price,
+     cs_sold_date_sk AS sold_date_sk,
+     cs_item_sk AS sold_item_sk,
+     cs_sold_time_sk AS time_sk
+   FROM catalog_sales, date_dim
+   WHERE d_date_sk = cs_sold_date_sk
+     AND d_moy = 11
+     AND d_year = 1999
+   UNION ALL
+   SELECT
+     ss_ext_sales_price AS ext_price,
+     ss_sold_date_sk AS sold_date_sk,
+     ss_item_sk AS sold_item_sk,
+     ss_sold_time_sk AS time_sk
+   FROM store_sales, date_dim
+   WHERE d_date_sk = ss_sold_date_sk
+     AND d_moy = 11
+     AND d_year = 1999
+  ) AS tmp, time_dim
+WHERE
+  sold_item_sk = i_item_sk
+    AND i_manager_id = 1
+    AND time_sk = t_time_sk
+    AND (t_meal_time = 'breakfast' OR t_meal_time = 'dinner')
+GROUP BY i_brand, i_brand_id, t_hour, t_minute
+ORDER BY ext_price DESC, brand_id

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q72.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q72.sql b/sql/core/src/test/resources/tpcds/q72.sql
new file mode 100755
index 0000000..99b3eee
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q72.sql
@@ -0,0 +1,33 @@
+SELECT
+  i_item_desc,
+  w_warehouse_name,
+  d1.d_week_seq,
+  count(CASE WHEN p_promo_sk IS NULL
+    THEN 1
+        ELSE 0 END) no_promo,
+  count(CASE WHEN p_promo_sk IS NOT NULL
+    THEN 1
+        ELSE 0 END) promo,
+  count(*) total_cnt
+FROM catalog_sales
+  JOIN inventory ON (cs_item_sk = inv_item_sk)
+  JOIN warehouse ON (w_warehouse_sk = inv_warehouse_sk)
+  JOIN item ON (i_item_sk = cs_item_sk)
+  JOIN customer_demographics ON (cs_bill_cdemo_sk = cd_demo_sk)
+  JOIN household_demographics ON (cs_bill_hdemo_sk = hd_demo_sk)
+  JOIN date_dim d1 ON (cs_sold_date_sk = d1.d_date_sk)
+  JOIN date_dim d2 ON (inv_date_sk = d2.d_date_sk)
+  JOIN date_dim d3 ON (cs_ship_date_sk = d3.d_date_sk)
+  LEFT OUTER JOIN promotion ON (cs_promo_sk = p_promo_sk)
+  LEFT OUTER JOIN catalog_returns ON (cr_item_sk = cs_item_sk AND cr_order_number = cs_order_number)
+WHERE d1.d_week_seq = d2.d_week_seq
+  AND inv_quantity_on_hand < cs_quantity
+  AND d3.d_date > (cast(d1.d_date AS DATE) + interval 5 days)
+  AND hd_buy_potential = '>10000'
+  AND d1.d_year = 1999
+  AND hd_buy_potential = '>10000'
+  AND cd_marital_status = 'D'
+  AND d1.d_year = 1999
+GROUP BY i_item_desc, w_warehouse_name, d1.d_week_seq
+ORDER BY total_cnt DESC, i_item_desc, w_warehouse_name, d_week_seq
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q73.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q73.sql b/sql/core/src/test/resources/tpcds/q73.sql
new file mode 100755
index 0000000..881be2e
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q73.sql
@@ -0,0 +1,30 @@
+SELECT
+  c_last_name,
+  c_first_name,
+  c_salutation,
+  c_preferred_cust_flag,
+  ss_ticket_number,
+  cnt
+FROM
+  (SELECT
+    ss_ticket_number,
+    ss_customer_sk,
+    count(*) cnt
+  FROM store_sales, date_dim, store, household_demographics
+  WHERE store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    AND store_sales.ss_store_sk = store.s_store_sk
+    AND store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    AND date_dim.d_dom BETWEEN 1 AND 2
+    AND (household_demographics.hd_buy_potential = '>10000' OR
+    household_demographics.hd_buy_potential = 'unknown')
+    AND household_demographics.hd_vehicle_count > 0
+    AND CASE WHEN household_demographics.hd_vehicle_count > 0
+    THEN
+      household_demographics.hd_dep_count / household_demographics.hd_vehicle_count
+        ELSE NULL END > 1
+    AND date_dim.d_year IN (1999, 1999 + 1, 1999 + 2)
+    AND store.s_county IN ('Williamson County', 'Franklin Parish', 'Bronx County', 'Orange County')
+  GROUP BY ss_ticket_number, ss_customer_sk) dj, customer
+WHERE ss_customer_sk = c_customer_sk
+  AND cnt BETWEEN 1 AND 5
+ORDER BY cnt DESC

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q74.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q74.sql b/sql/core/src/test/resources/tpcds/q74.sql
new file mode 100755
index 0000000..154b26d
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q74.sql
@@ -0,0 +1,58 @@
+WITH year_total AS (
+  SELECT
+    c_customer_id customer_id,
+    c_first_name customer_first_name,
+    c_last_name customer_last_name,
+    d_year AS year,
+    sum(ss_net_paid) year_total,
+    's' sale_type
+  FROM
+    customer, store_sales, date_dim
+  WHERE c_customer_sk = ss_customer_sk
+    AND ss_sold_date_sk = d_date_sk
+    AND d_year IN (2001, 2001 + 1)
+  GROUP BY
+    c_customer_id, c_first_name, c_last_name, d_year
+  UNION ALL
+  SELECT
+    c_customer_id customer_id,
+    c_first_name customer_first_name,
+    c_last_name customer_last_name,
+    d_year AS year,
+    sum(ws_net_paid) year_total,
+    'w' sale_type
+  FROM
+    customer, web_sales, date_dim
+  WHERE c_customer_sk = ws_bill_customer_sk
+    AND ws_sold_date_sk = d_date_sk
+    AND d_year IN (2001, 2001 + 1)
+  GROUP BY
+    c_customer_id, c_first_name, c_last_name, d_year)
+SELECT
+  t_s_secyear.customer_id,
+  t_s_secyear.customer_first_name,
+  t_s_secyear.customer_last_name
+FROM
+  year_total t_s_firstyear, year_total t_s_secyear,
+  year_total t_w_firstyear, year_total t_w_secyear
+WHERE t_s_secyear.customer_id = t_s_firstyear.customer_id
+  AND t_s_firstyear.customer_id = t_w_secyear.customer_id
+  AND t_s_firstyear.customer_id = t_w_firstyear.customer_id
+  AND t_s_firstyear.sale_type = 's'
+  AND t_w_firstyear.sale_type = 'w'
+  AND t_s_secyear.sale_type = 's'
+  AND t_w_secyear.sale_type = 'w'
+  AND t_s_firstyear.year = 2001
+  AND t_s_secyear.year = 2001 + 1
+  AND t_w_firstyear.year = 2001
+  AND t_w_secyear.year = 2001 + 1
+  AND t_s_firstyear.year_total > 0
+  AND t_w_firstyear.year_total > 0
+  AND CASE WHEN t_w_firstyear.year_total > 0
+  THEN t_w_secyear.year_total / t_w_firstyear.year_total
+      ELSE NULL END
+  > CASE WHEN t_s_firstyear.year_total > 0
+  THEN t_s_secyear.year_total / t_s_firstyear.year_total
+    ELSE NULL END
+ORDER BY 1, 1, 1
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q75.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q75.sql b/sql/core/src/test/resources/tpcds/q75.sql
new file mode 100755
index 0000000..2a14323
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q75.sql
@@ -0,0 +1,76 @@
+WITH all_sales AS (
+  SELECT
+    d_year,
+    i_brand_id,
+    i_class_id,
+    i_category_id,
+    i_manufact_id,
+    SUM(sales_cnt) AS sales_cnt,
+    SUM(sales_amt) AS sales_amt
+  FROM (
+         SELECT
+           d_year,
+           i_brand_id,
+           i_class_id,
+           i_category_id,
+           i_manufact_id,
+           cs_quantity - COALESCE(cr_return_quantity, 0) AS sales_cnt,
+           cs_ext_sales_price - COALESCE(cr_return_amount, 0.0) AS sales_amt
+         FROM catalog_sales
+           JOIN item ON i_item_sk = cs_item_sk
+           JOIN date_dim ON d_date_sk = cs_sold_date_sk
+           LEFT JOIN catalog_returns ON (cs_order_number = cr_order_number
+             AND cs_item_sk = cr_item_sk)
+         WHERE i_category = 'Books'
+         UNION
+         SELECT
+           d_year,
+           i_brand_id,
+           i_class_id,
+           i_category_id,
+           i_manufact_id,
+           ss_quantity - COALESCE(sr_return_quantity, 0) AS sales_cnt,
+           ss_ext_sales_price - COALESCE(sr_return_amt, 0.0) AS sales_amt
+         FROM store_sales
+           JOIN item ON i_item_sk = ss_item_sk
+           JOIN date_dim ON d_date_sk = ss_sold_date_sk
+           LEFT JOIN store_returns ON (ss_ticket_number = sr_ticket_number
+             AND ss_item_sk = sr_item_sk)
+         WHERE i_category = 'Books'
+         UNION
+         SELECT
+           d_year,
+           i_brand_id,
+           i_class_id,
+           i_category_id,
+           i_manufact_id,
+           ws_quantity - COALESCE(wr_return_quantity, 0) AS sales_cnt,
+           ws_ext_sales_price - COALESCE(wr_return_amt, 0.0) AS sales_amt
+         FROM web_sales
+           JOIN item ON i_item_sk = ws_item_sk
+           JOIN date_dim ON d_date_sk = ws_sold_date_sk
+           LEFT JOIN web_returns ON (ws_order_number = wr_order_number
+             AND ws_item_sk = wr_item_sk)
+         WHERE i_category = 'Books') sales_detail
+  GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id)
+SELECT
+  prev_yr.d_year AS prev_year,
+  curr_yr.d_year AS year,
+  curr_yr.i_brand_id,
+  curr_yr.i_class_id,
+  curr_yr.i_category_id,
+  curr_yr.i_manufact_id,
+  prev_yr.sales_cnt AS prev_yr_cnt,
+  curr_yr.sales_cnt AS curr_yr_cnt,
+  curr_yr.sales_cnt - prev_yr.sales_cnt AS sales_cnt_diff,
+  curr_yr.sales_amt - prev_yr.sales_amt AS sales_amt_diff
+FROM all_sales curr_yr, all_sales prev_yr
+WHERE curr_yr.i_brand_id = prev_yr.i_brand_id
+  AND curr_yr.i_class_id = prev_yr.i_class_id
+  AND curr_yr.i_category_id = prev_yr.i_category_id
+  AND curr_yr.i_manufact_id = prev_yr.i_manufact_id
+  AND curr_yr.d_year = 2002
+  AND prev_yr.d_year = 2002 - 1
+  AND CAST(curr_yr.sales_cnt AS DECIMAL(17, 2)) / CAST(prev_yr.sales_cnt AS DECIMAL(17, 2)) < 0.9
+ORDER BY sales_cnt_diff
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q76.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q76.sql b/sql/core/src/test/resources/tpcds/q76.sql
new file mode 100755
index 0000000..815fa92
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q76.sql
@@ -0,0 +1,47 @@
+SELECT
+  channel,
+  col_name,
+  d_year,
+  d_qoy,
+  i_category,
+  COUNT(*) sales_cnt,
+  SUM(ext_sales_price) sales_amt
+FROM (
+       SELECT
+         'store' AS channel,
+         ss_store_sk col_name,
+         d_year,
+         d_qoy,
+         i_category,
+         ss_ext_sales_price ext_sales_price
+       FROM store_sales, item, date_dim
+       WHERE ss_store_sk IS NULL
+         AND ss_sold_date_sk = d_date_sk
+         AND ss_item_sk = i_item_sk
+       UNION ALL
+       SELECT
+         'web' AS channel,
+         ws_ship_customer_sk col_name,
+         d_year,
+         d_qoy,
+         i_category,
+         ws_ext_sales_price ext_sales_price
+       FROM web_sales, item, date_dim
+       WHERE ws_ship_customer_sk IS NULL
+         AND ws_sold_date_sk = d_date_sk
+         AND ws_item_sk = i_item_sk
+       UNION ALL
+       SELECT
+         'catalog' AS channel,
+         cs_ship_addr_sk col_name,
+         d_year,
+         d_qoy,
+         i_category,
+         cs_ext_sales_price ext_sales_price
+       FROM catalog_sales, item, date_dim
+       WHERE cs_ship_addr_sk IS NULL
+         AND cs_sold_date_sk = d_date_sk
+         AND cs_item_sk = i_item_sk) foo
+GROUP BY channel, col_name, d_year, d_qoy, i_category
+ORDER BY channel, col_name, d_year, d_qoy, i_category
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q77.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q77.sql b/sql/core/src/test/resources/tpcds/q77.sql
new file mode 100755
index 0000000..7830f96
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q77.sql
@@ -0,0 +1,100 @@
+WITH ss AS
+(SELECT
+    s_store_sk,
+    sum(ss_ext_sales_price) AS sales,
+    sum(ss_net_profit) AS profit
+  FROM store_sales, date_dim, store
+  WHERE ss_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)
+    AND ss_store_sk = s_store_sk
+  GROUP BY s_store_sk),
+    sr AS
+  (SELECT
+    s_store_sk,
+    sum(sr_return_amt) AS returns,
+    sum(sr_net_loss) AS profit_loss
+  FROM store_returns, date_dim, store
+  WHERE sr_returned_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)
+    AND sr_store_sk = s_store_sk
+  GROUP BY s_store_sk),
+    cs AS
+  (SELECT
+    cs_call_center_sk,
+    sum(cs_ext_sales_price) AS sales,
+    sum(cs_net_profit) AS profit
+  FROM catalog_sales, date_dim
+  WHERE cs_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)
+  GROUP BY cs_call_center_sk),
+    cr AS
+  (SELECT
+    sum(cr_return_amount) AS returns,
+    sum(cr_net_loss) AS profit_loss
+  FROM catalog_returns, date_dim
+  WHERE cr_returned_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03]' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)),
+    ws AS
+  (SELECT
+    wp_web_page_sk,
+    sum(ws_ext_sales_price) AS sales,
+    sum(ws_net_profit) AS profit
+  FROM web_sales, date_dim, web_page
+  WHERE ws_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)
+    AND ws_web_page_sk = wp_web_page_sk
+  GROUP BY wp_web_page_sk),
+    wr AS
+  (SELECT
+    wp_web_page_sk,
+    sum(wr_return_amt) AS returns,
+    sum(wr_net_loss) AS profit_loss
+  FROM web_returns, date_dim, web_page
+  WHERE wr_returned_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-03' AS DATE) AND
+  (cast('2000-08-03' AS DATE) + INTERVAL 30 days)
+    AND wr_web_page_sk = wp_web_page_sk
+  GROUP BY wp_web_page_sk)
+SELECT
+  channel,
+  id,
+  sum(sales) AS sales,
+  sum(returns) AS returns,
+  sum(profit) AS profit
+FROM
+  (SELECT
+     'store channel' AS channel,
+     ss.s_store_sk AS id,
+     sales,
+     coalesce(returns, 0) AS returns,
+     (profit - coalesce(profit_loss, 0)) AS profit
+   FROM ss
+     LEFT JOIN sr
+       ON ss.s_store_sk = sr.s_store_sk
+   UNION ALL
+   SELECT
+     'catalog channel' AS channel,
+     cs_call_center_sk AS id,
+     sales,
+     returns,
+     (profit - profit_loss) AS profit
+   FROM cs, cr
+   UNION ALL
+   SELECT
+     'web channel' AS channel,
+     ws.wp_web_page_sk AS id,
+     sales,
+     coalesce(returns, 0) returns,
+     (profit - coalesce(profit_loss, 0)) AS profit
+   FROM ws
+     LEFT JOIN wr
+       ON ws.wp_web_page_sk = wr.wp_web_page_sk
+  ) x
+GROUP BY ROLLUP (channel, id)
+ORDER BY channel, id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q78.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q78.sql b/sql/core/src/test/resources/tpcds/q78.sql
new file mode 100755
index 0000000..07b0940
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q78.sql
@@ -0,0 +1,64 @@
+WITH ws AS
+(SELECT
+    d_year AS ws_sold_year,
+    ws_item_sk,
+    ws_bill_customer_sk ws_customer_sk,
+    sum(ws_quantity) ws_qty,
+    sum(ws_wholesale_cost) ws_wc,
+    sum(ws_sales_price) ws_sp
+  FROM web_sales
+    LEFT JOIN web_returns ON wr_order_number = ws_order_number AND ws_item_sk = wr_item_sk
+    JOIN date_dim ON ws_sold_date_sk = d_date_sk
+  WHERE wr_order_number IS NULL
+  GROUP BY d_year, ws_item_sk, ws_bill_customer_sk
+),
+    cs AS
+  (SELECT
+    d_year AS cs_sold_year,
+    cs_item_sk,
+    cs_bill_customer_sk cs_customer_sk,
+    sum(cs_quantity) cs_qty,
+    sum(cs_wholesale_cost) cs_wc,
+    sum(cs_sales_price) cs_sp
+  FROM catalog_sales
+    LEFT JOIN catalog_returns ON cr_order_number = cs_order_number AND cs_item_sk = cr_item_sk
+    JOIN date_dim ON cs_sold_date_sk = d_date_sk
+  WHERE cr_order_number IS NULL
+  GROUP BY d_year, cs_item_sk, cs_bill_customer_sk
+  ),
+    ss AS
+  (SELECT
+    d_year AS ss_sold_year,
+    ss_item_sk,
+    ss_customer_sk,
+    sum(ss_quantity) ss_qty,
+    sum(ss_wholesale_cost) ss_wc,
+    sum(ss_sales_price) ss_sp
+  FROM store_sales
+    LEFT JOIN store_returns ON sr_ticket_number = ss_ticket_number AND ss_item_sk = sr_item_sk
+    JOIN date_dim ON ss_sold_date_sk = d_date_sk
+  WHERE sr_ticket_number IS NULL
+  GROUP BY d_year, ss_item_sk, ss_customer_sk
+  )
+SELECT
+  round(ss_qty / (coalesce(ws_qty + cs_qty, 1)), 2) ratio,
+  ss_qty store_qty,
+  ss_wc store_wholesale_cost,
+  ss_sp store_sales_price,
+  coalesce(ws_qty, 0) + coalesce(cs_qty, 0) other_chan_qty,
+  coalesce(ws_wc, 0) + coalesce(cs_wc, 0) other_chan_wholesale_cost,
+  coalesce(ws_sp, 0) + coalesce(cs_sp, 0) other_chan_sales_price
+FROM ss
+  LEFT JOIN ws
+    ON (ws_sold_year = ss_sold_year AND ws_item_sk = ss_item_sk AND ws_customer_sk = ss_customer_sk)
+  LEFT JOIN cs
+    ON (cs_sold_year = ss_sold_year AND cs_item_sk = ss_item_sk AND cs_customer_sk = ss_customer_sk)
+WHERE coalesce(ws_qty, 0) > 0 AND coalesce(cs_qty, 0) > 0 AND ss_sold_year = 2000
+ORDER BY
+  ratio,
+  ss_qty DESC, ss_wc DESC, ss_sp DESC,
+  other_chan_qty,
+  other_chan_wholesale_cost,
+  other_chan_sales_price,
+  round(ss_qty / (coalesce(ws_qty + cs_qty, 1)), 2)
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q79.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q79.sql b/sql/core/src/test/resources/tpcds/q79.sql
new file mode 100755
index 0000000..08f86dc
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q79.sql
@@ -0,0 +1,27 @@
+SELECT
+  c_last_name,
+  c_first_name,
+  substr(s_city, 1, 30),
+  ss_ticket_number,
+  amt,
+  profit
+FROM
+  (SELECT
+    ss_ticket_number,
+    ss_customer_sk,
+    store.s_city,
+    sum(ss_coupon_amt) amt,
+    sum(ss_net_profit) profit
+  FROM store_sales, date_dim, store, household_demographics
+  WHERE store_sales.ss_sold_date_sk = date_dim.d_date_sk
+    AND store_sales.ss_store_sk = store.s_store_sk
+    AND store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
+    AND (household_demographics.hd_dep_count = 6 OR
+    household_demographics.hd_vehicle_count > 2)
+    AND date_dim.d_dow = 1
+    AND date_dim.d_year IN (1999, 1999 + 1, 1999 + 2)
+    AND store.s_number_employees BETWEEN 200 AND 295
+  GROUP BY ss_ticket_number, ss_customer_sk, ss_addr_sk, store.s_city) ms, customer
+WHERE ss_customer_sk = c_customer_sk
+ORDER BY c_last_name, c_first_name, substr(s_city, 1, 30), profit
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q8.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q8.sql b/sql/core/src/test/resources/tpcds/q8.sql
new file mode 100755
index 0000000..4977251
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q8.sql
@@ -0,0 +1,87 @@
+SELECT
+  s_store_name,
+  sum(ss_net_profit)
+FROM store_sales, date_dim, store,
+  (SELECT ca_zip
+  FROM (
+         (SELECT substr(ca_zip, 1, 5) ca_zip
+         FROM customer_address
+         WHERE substr(ca_zip, 1, 5) IN (
+               '24128','76232','65084','87816','83926','77556','20548',
+               '26231','43848','15126','91137','61265','98294','25782',
+               '17920','18426','98235','40081','84093','28577','55565',
+               '17183','54601','67897','22752','86284','18376','38607',
+               '45200','21756','29741','96765','23932','89360','29839',
+               '25989','28898','91068','72550','10390','18845','47770',
+               '82636','41367','76638','86198','81312','37126','39192',
+               '88424','72175','81426','53672','10445','42666','66864',
+               '66708','41248','48583','82276','18842','78890','49448',
+               '14089','38122','34425','79077','19849','43285','39861',
+               '66162','77610','13695','99543','83444','83041','12305',
+               '57665','68341','25003','57834','62878','49130','81096',
+               '18840','27700','23470','50412','21195','16021','76107',
+               '71954','68309','18119','98359','64544','10336','86379',
+               '27068','39736','98569','28915','24206','56529','57647',
+               '54917','42961','91110','63981','14922','36420','23006',
+               '67467','32754','30903','20260','31671','51798','72325',
+               '85816','68621','13955','36446','41766','68806','16725',
+               '15146','22744','35850','88086','51649','18270','52867',
+               '39972','96976','63792','11376','94898','13595','10516',
+               '90225','58943','39371','94945','28587','96576','57855',
+               '28488','26105','83933','25858','34322','44438','73171',
+               '30122','34102','22685','71256','78451','54364','13354',
+               '45375','40558','56458','28286','45266','47305','69399',
+               '83921','26233','11101','15371','69913','35942','15882',
+               '25631','24610','44165','99076','33786','70738','26653',
+               '14328','72305','62496','22152','10144','64147','48425',
+               '14663','21076','18799','30450','63089','81019','68893',
+               '24996','51200','51211','45692','92712','70466','79994',
+               '22437','25280','38935','71791','73134','56571','14060',
+               '19505','72425','56575','74351','68786','51650','20004',
+               '18383','76614','11634','18906','15765','41368','73241',
+               '76698','78567','97189','28545','76231','75691','22246',
+               '51061','90578','56691','68014','51103','94167','57047',
+               '14867','73520','15734','63435','25733','35474','24676',
+               '94627','53535','17879','15559','53268','59166','11928',
+               '59402','33282','45721','43933','68101','33515','36634',
+               '71286','19736','58058','55253','67473','41918','19515',
+               '36495','19430','22351','77191','91393','49156','50298',
+               '87501','18652','53179','18767','63193','23968','65164',
+               '68880','21286','72823','58470','67301','13394','31016',
+               '70372','67030','40604','24317','45748','39127','26065',
+               '77721','31029','31880','60576','24671','45549','13376',
+               '50016','33123','19769','22927','97789','46081','72151',
+               '15723','46136','51949','68100','96888','64528','14171',
+               '79777','28709','11489','25103','32213','78668','22245',
+               '15798','27156','37930','62971','21337','51622','67853',
+               '10567','38415','15455','58263','42029','60279','37125',
+               '56240','88190','50308','26859','64457','89091','82136',
+               '62377','36233','63837','58078','17043','30010','60099',
+               '28810','98025','29178','87343','73273','30469','64034',
+               '39516','86057','21309','90257','67875','40162','11356',
+               '73650','61810','72013','30431','22461','19512','13375',
+               '55307','30625','83849','68908','26689','96451','38193',
+               '46820','88885','84935','69035','83144','47537','56616',
+               '94983','48033','69952','25486','61547','27385','61860',
+               '58048','56910','16807','17871','35258','31387','35458',
+               '35576'))
+         INTERSECT
+         (SELECT ca_zip
+         FROM
+           (SELECT
+             substr(ca_zip, 1, 5) ca_zip,
+             count(*) cnt
+           FROM customer_address, customer
+           WHERE ca_address_sk = c_current_addr_sk AND
+             c_preferred_cust_flag = 'Y'
+           GROUP BY ca_zip
+           HAVING count(*) > 10) A1)
+       ) A2
+  ) V1
+WHERE ss_store_sk = s_store_sk
+  AND ss_sold_date_sk = d_date_sk
+  AND d_qoy = 2 AND d_year = 1998
+  AND (substr(s_zip, 1, 2) = substr(V1.ca_zip, 1, 2))
+GROUP BY s_store_name
+ORDER BY s_store_name
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q80.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q80.sql b/sql/core/src/test/resources/tpcds/q80.sql
new file mode 100755
index 0000000..433db87
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q80.sql
@@ -0,0 +1,94 @@
+WITH ssr AS
+(SELECT
+    s_store_id AS store_id,
+    sum(ss_ext_sales_price) AS sales,
+    sum(coalesce(sr_return_amt, 0)) AS returns,
+    sum(ss_net_profit - coalesce(sr_net_loss, 0)) AS profit
+  FROM store_sales
+    LEFT OUTER JOIN store_returns ON
+                                    (ss_item_sk = sr_item_sk AND
+                                      ss_ticket_number = sr_ticket_number)
+    ,
+    date_dim, store, item, promotion
+  WHERE ss_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND (cast('2000-08-23' AS DATE) + INTERVAL 30 days)
+    AND ss_store_sk = s_store_sk
+    AND ss_item_sk = i_item_sk
+    AND i_current_price > 50
+    AND ss_promo_sk = p_promo_sk
+    AND p_channel_tv = 'N'
+  GROUP BY s_store_id),
+    csr AS
+  (SELECT
+    cp_catalog_page_id AS catalog_page_id,
+    sum(cs_ext_sales_price) AS sales,
+    sum(coalesce(cr_return_amount, 0)) AS returns,
+    sum(cs_net_profit - coalesce(cr_net_loss, 0)) AS profit
+  FROM catalog_sales
+    LEFT OUTER JOIN catalog_returns ON
+                                      (cs_item_sk = cr_item_sk AND
+                                        cs_order_number = cr_order_number)
+    ,
+    date_dim, catalog_page, item, promotion
+  WHERE cs_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND (cast('2000-08-23' AS DATE) + INTERVAL 30 days)
+    AND cs_catalog_page_sk = cp_catalog_page_sk
+    AND cs_item_sk = i_item_sk
+    AND i_current_price > 50
+    AND cs_promo_sk = p_promo_sk
+    AND p_channel_tv = 'N'
+  GROUP BY cp_catalog_page_id),
+    wsr AS
+  (SELECT
+    web_site_id,
+    sum(ws_ext_sales_price) AS sales,
+    sum(coalesce(wr_return_amt, 0)) AS returns,
+    sum(ws_net_profit - coalesce(wr_net_loss, 0)) AS profit
+  FROM web_sales
+    LEFT OUTER JOIN web_returns ON
+                                  (ws_item_sk = wr_item_sk AND ws_order_number = wr_order_number)
+    ,
+    date_dim, web_site, item, promotion
+  WHERE ws_sold_date_sk = d_date_sk
+    AND d_date BETWEEN cast('2000-08-23' AS DATE)
+  AND (cast('2000-08-23' AS DATE) + INTERVAL 30 days)
+    AND ws_web_site_sk = web_site_sk
+    AND ws_item_sk = i_item_sk
+    AND i_current_price > 50
+    AND ws_promo_sk = p_promo_sk
+    AND p_channel_tv = 'N'
+  GROUP BY web_site_id)
+SELECT
+  channel,
+  id,
+  sum(sales) AS sales,
+  sum(returns) AS returns,
+  sum(profit) AS profit
+FROM (SELECT
+        'store channel' AS channel,
+        concat('store', store_id) AS id,
+        sales,
+        returns,
+        profit
+      FROM ssr
+      UNION ALL
+      SELECT
+        'catalog channel' AS channel,
+        concat('catalog_page', catalog_page_id) AS id,
+        sales,
+        returns,
+        profit
+      FROM csr
+      UNION ALL
+      SELECT
+        'web channel' AS channel,
+        concat('web_site', web_site_id) AS id,
+        sales,
+        returns,
+        profit
+      FROM wsr) x
+GROUP BY ROLLUP (channel, id)
+ORDER BY channel, id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q81.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q81.sql b/sql/core/src/test/resources/tpcds/q81.sql
new file mode 100755
index 0000000..18f0ffa
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q81.sql
@@ -0,0 +1,38 @@
+WITH customer_total_return AS
+(SELECT
+    cr_returning_customer_sk AS ctr_customer_sk,
+    ca_state AS ctr_state,
+    sum(cr_return_amt_inc_tax) AS ctr_total_return
+  FROM catalog_returns, date_dim, customer_address
+  WHERE cr_returned_date_sk = d_date_sk
+    AND d_year = 2000
+    AND cr_returning_addr_sk = ca_address_sk
+  GROUP BY cr_returning_customer_sk, ca_state )
+SELECT
+  c_customer_id,
+  c_salutation,
+  c_first_name,
+  c_last_name,
+  ca_street_number,
+  ca_street_name,
+  ca_street_type,
+  ca_suite_number,
+  ca_city,
+  ca_county,
+  ca_state,
+  ca_zip,
+  ca_country,
+  ca_gmt_offset,
+  ca_location_type,
+  ctr_total_return
+FROM customer_total_return ctr1, customer_address, customer
+WHERE ctr1.ctr_total_return > (SELECT avg(ctr_total_return) * 1.2
+FROM customer_total_return ctr2
+WHERE ctr1.ctr_state = ctr2.ctr_state)
+  AND ca_address_sk = c_current_addr_sk
+  AND ca_state = 'GA'
+  AND ctr1.ctr_customer_sk = c_customer_sk
+ORDER BY c_customer_id, c_salutation, c_first_name, c_last_name, ca_street_number, ca_street_name
+  , ca_street_type, ca_suite_number, ca_city, ca_county, ca_state, ca_zip, ca_country, ca_gmt_offset
+  , ca_location_type, ctr_total_return
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q82.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q82.sql b/sql/core/src/test/resources/tpcds/q82.sql
new file mode 100755
index 0000000..20942cf
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q82.sql
@@ -0,0 +1,15 @@
+SELECT
+  i_item_id,
+  i_item_desc,
+  i_current_price
+FROM item, inventory, date_dim, store_sales
+WHERE i_current_price BETWEEN 62 AND 62 + 30
+  AND inv_item_sk = i_item_sk
+  AND d_date_sk = inv_date_sk
+  AND d_date BETWEEN cast('2000-05-25' AS DATE) AND (cast('2000-05-25' AS DATE) + INTERVAL 60 days)
+  AND i_manufact_id IN (129, 270, 821, 423)
+  AND inv_quantity_on_hand BETWEEN 100 AND 500
+  AND ss_item_sk = i_item_sk
+GROUP BY i_item_id, i_item_desc, i_current_price
+ORDER BY i_item_id
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q83.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q83.sql b/sql/core/src/test/resources/tpcds/q83.sql
new file mode 100755
index 0000000..53c10c7
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q83.sql
@@ -0,0 +1,56 @@
+WITH sr_items AS
+(SELECT
+    i_item_id item_id,
+    sum(sr_return_quantity) sr_item_qty
+  FROM store_returns, item, date_dim
+  WHERE sr_item_sk = i_item_sk
+    AND d_date IN (SELECT d_date
+  FROM date_dim
+  WHERE d_week_seq IN
+    (SELECT d_week_seq
+    FROM date_dim
+    WHERE d_date IN ('2000-06-30', '2000-09-27', '2000-11-17')))
+    AND sr_returned_date_sk = d_date_sk
+  GROUP BY i_item_id),
+    cr_items AS
+  (SELECT
+    i_item_id item_id,
+    sum(cr_return_quantity) cr_item_qty
+  FROM catalog_returns, item, date_dim
+  WHERE cr_item_sk = i_item_sk
+    AND d_date IN (SELECT d_date
+  FROM date_dim
+  WHERE d_week_seq IN
+    (SELECT d_week_seq
+    FROM date_dim
+    WHERE d_date IN ('2000-06-30', '2000-09-27', '2000-11-17')))
+    AND cr_returned_date_sk = d_date_sk
+  GROUP BY i_item_id),
+    wr_items AS
+  (SELECT
+    i_item_id item_id,
+    sum(wr_return_quantity) wr_item_qty
+  FROM web_returns, item, date_dim
+  WHERE wr_item_sk = i_item_sk AND d_date IN
+    (SELECT d_date
+    FROM date_dim
+    WHERE d_week_seq IN
+      (SELECT d_week_seq
+      FROM date_dim
+      WHERE d_date IN ('2000-06-30', '2000-09-27', '2000-11-17')))
+    AND wr_returned_date_sk = d_date_sk
+  GROUP BY i_item_id)
+SELECT
+  sr_items.item_id,
+  sr_item_qty,
+  sr_item_qty / (sr_item_qty + cr_item_qty + wr_item_qty) / 3.0 * 100 sr_dev,
+  cr_item_qty,
+  cr_item_qty / (sr_item_qty + cr_item_qty + wr_item_qty) / 3.0 * 100 cr_dev,
+  wr_item_qty,
+  wr_item_qty / (sr_item_qty + cr_item_qty + wr_item_qty) / 3.0 * 100 wr_dev,
+  (sr_item_qty + cr_item_qty + wr_item_qty) / 3.0 average
+FROM sr_items, cr_items, wr_items
+WHERE sr_items.item_id = cr_items.item_id
+  AND sr_items.item_id = wr_items.item_id
+ORDER BY sr_items.item_id, sr_item_qty
+LIMIT 100

http://git-wip-us.apache.org/repos/asf/spark/blob/a78d6ce3/sql/core/src/test/resources/tpcds/q84.sql
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/tpcds/q84.sql b/sql/core/src/test/resources/tpcds/q84.sql
new file mode 100755
index 0000000..a1076b5
--- /dev/null
+++ b/sql/core/src/test/resources/tpcds/q84.sql
@@ -0,0 +1,19 @@
+SELECT
+  c_customer_id AS customer_id,
+  concat(c_last_name, ', ', c_first_name) AS customername
+FROM customer
+  , customer_address
+  , customer_demographics
+  , household_demographics
+  , income_band
+  , store_returns
+WHERE ca_city = 'Edgewood'
+  AND c_current_addr_sk = ca_address_sk
+  AND ib_lower_bound >= 38128
+  AND ib_upper_bound <= 38128 + 50000
+  AND ib_income_band_sk = hd_income_band_sk
+  AND cd_demo_sk = c_current_cdemo_sk
+  AND hd_demo_sk = c_current_hdemo_sk
+  AND sr_cdemo_sk = cd_demo_sk
+ORDER BY c_customer_id
+LIMIT 100


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


Mime
View raw message