diff --git a/scripts/jmeterscripts/LocalHost.jmx b/scripts/jmeterscripts/LocalHost.jmx new file mode 100644 index 0000000..1360e2e --- /dev/null +++ b/scripts/jmeterscripts/LocalHost.jmx @@ -0,0 +1,575 @@ + + + + + + false + false + + + + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select sum(c_acctbal) as bal from orderLineItemPartSupplier group by + (substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000') + AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by bal + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select o_orderdate, + (substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000Z') + AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) x, + sum(c_acctbal) as bal from orderLineItemPartSupplier group by + o_orderdate, (substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), + 'T00:00:00.000Z') AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by o_orderdate, x, bal + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select o_orderdate, + (DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) as x + from orderLineItemPartSupplier group by o_orderdate, + cast('2015-07-21 10:10:10 PST' as date), + (DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) + order by o_orderdate, x + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select (Date_add(cast(o_orderdate as date), 360+3)) as x + from orderLineItemPartSupplier group by + (Date_add(cast(o_orderdate as date), 360+3)) order by x + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select (Date_sub(cast(o_orderdate as date), 360+3)) as x + from orderLineItemPartSupplier group by + (Date_sub(cast(o_orderdate as date), 360+3)) order by x + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select o_orderdate, (weekofyear(Date_Add(cast(o_orderdate as date), 1))) as x + from orderLineItemPartSupplier group by o_orderdate, + (weekofyear(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) as x + from orderLineItemPartSupplier group by o_orderdate, + (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate, x + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT o_orderdate, Cast(Concat(Year(Cast(o_orderdate AS TIMESTAMP)), + (CASE WHEN Month(Cast(o_orderdate AS TIMESTAMP))<4 + THEN '-01' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<7 + THEN '-04' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<10 + THEN '-07' ELSE '-10' END), '-01 00:00:00') + AS TIMESTAMP) AS x + FROM (SELECT * FROM orderLineItemPartSupplier) m + GROUP BY o_orderdate, cast(concat(year(cast(o_orderdate AS timestamp)), + (CASE WHEN month(cast(o_orderdate AS timestamp))<4 THEN '-01' + WHEN month(cast(o_orderdate AS timestamp))<7 THEN '-04' + WHEN month(cast(o_orderdate AS timestamp))<10 + THEN '-07' ELSE '-10' END), '-01 00:00:00') AS timestamp) + order by o_orderdate, x + + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + select o_orderdate as x + from orderLineItemPartSupplier group by + o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) + order by o_orderdate, x + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://localhost:10000/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT) + AS `qr_row_hr_ok`, YEAR(CAST(o_orderdate AS TIMESTAMP)) AS `yr_row_hr_ok` + FROM ( select * from orderLineItemPartSupplier) custom_sql_query + GROUP BY + CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT), + YEAR(CAST(o_orderdate AS TIMESTAMP)) order by qr_row_hr_ok, yr_row_hr_ok + + + + + + + Store as String + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + + + + + diff --git a/scripts/jmeterscripts/RemoteVPNPortTest.jmx b/scripts/jmeterscripts/RemoteVPNPortTest.jmx new file mode 100644 index 0000000..157aed2 --- /dev/null +++ b/scripts/jmeterscripts/RemoteVPNPortTest.jmx @@ -0,0 +1,660 @@ + + + + + + false + false + + + + + + + + continue + + false + 10 + + 3 + 1 + 1465592749000 + 1465592749000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`datasource` AS `datasource` FROM ( select * from viewability_5 ) v GROUP BY `v`.`datasource` ORDER BY `datasource` ASC + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593095000 + 1465593095000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`advertiser_name` AS `advertiser_name`, `v`.`campaign_name` AS `campaign_name`, `v`.`creative_name` AS `creative_name`, `v`.`line_name` AS `line_name`, SUM(`v`.`clicks`) AS `sum_clicks_ok`, SUM(`v`.`conversions`) AS `sum_conversions_ok` FROM ( select * from viewability_5 ) v WHERE ((((`v`.`advertiser_name` >= '#Cunard#UK') AND (`v`.`advertiser_name` <= '#Jeep#UK')) OR ((`v`.`advertiser_name` >= '#Reiss#UK') AND (`v`.`advertiser_name` <= 'musicMagpie_UK'))) AND (((`v`.`datasource` IN ('Other', 'PubMatic-RTB')) OR ((`v`.`datasource` >= 'ADAP_TV') AND (`v`.`datasource` <= 'AdX-RTB')) OR ((`v`.`datasource` >= 'DMX') AND (`v`.`datasource` <= 'OPERA')) OR ((`v`.`datasource` >= 'Rubicon-RTB') AND (`v`.`datasource` <= 'source_placement'))) AND ((CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) >= CAST('2016-03-01 16:00:00' AS TIMESTAMP)) AND (CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) <= CAST('2016-04-28 17:00:00' AS TIMESTAMP))) AND ((`v`.`line_name` >= '0114025_P&O_Glasgow City Spring_TRVL_UK_MAR16_Display_') AND (`v`.`line_name` <= 'xxxxx_Call Me_Call Me_TECH_DK_MAR16_Display_')))) GROUP BY `v`.`advertiser_name`, `v`.`campaign_name`, `v`.`creative_name`, `v`.`line_name` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593099000 + 1465593099000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT MIN(`t0`.`sum_impressions_qk`) AS `temp_sum_impressions_qk_lower__290714814__0_`, MAX(`t0`.`sum_impressions_qk`) AS `temp_sum_impressions_qk_upper__290714814__0_`, COUNT(1) AS `x__alias__0` FROM ( SELECT CAST(CONCAT(TO_DATE(CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP) AS `tdy_date_string_qk`, SUM(`v`.`impressions`) AS `sum_impressions_qk` FROM ( select * from viewability_5 ) v WHERE (((CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) >= CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(-89 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP)) AND (CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) < CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(1 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP))) AND (`v`.`country` = 'United States')) GROUP BY CAST(CONCAT(TO_DATE(CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP) ) t0 HAVING (COUNT(1) > 0) + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593101000 + 1465593101000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT SUM(`v`.`dv_measurable_impression`) AS `temp_viewability_percentage_comscore__copy___168678397__0_`, SUM(`v`.`dv_viewable_impression`) AS `temp_viewability_percentage_comscore__copy___2409572032__0_`, CAST(CONCAT(TO_DATE(CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP) AS `tdy_date_string_ok`, SUM(`v`.`impressions`) AS `x_measure__0`, SUM(`v`.`impressions`) AS `x_measure__1`, SUM(`v`.`dv_viewable_impression`) AS `x_measure__2`, SUM(`v`.`dv_measurable_impression`) AS `x_measure__3` FROM ( select * from viewability_5 ) v WHERE (((CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) >= CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(-89 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP)) AND (CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) < CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(1 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP))) AND (`v`.`country` = 'United States')) GROUP BY CAST(CONCAT(TO_DATE(CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP) HAVING (((SUM(`v`.`impressions`) >= 13453383) AND (SUM(`v`.`impressions`) <= 55984343)) AND (NOT ((CASE WHEN SUM(`v`.`dv_measurable_impression`) = 0 THEN NULL ELSE CAST(SUM(`v`.`dv_viewable_impression`) AS DOUBLE) / SUM(`v`.`dv_measurable_impression`) END) IS NULL))) + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593104000 + 1465593104000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT SUM(`v`.`comscore_measurable`) AS `temp_calculation_3253076685997178880__1019512392__0_`, SUM(`v`.`comscore_viewable`) AS `temp_calculation_3253076685997178880__4085906920__0_`, SUM(`v`.`dv_measurable_impression`) AS `temp_viewability_percentage_comscore__copy___168678397__0_`, SUM(`v`.`dv_viewable_impression`) AS `temp_viewability_percentage_comscore__copy___2409572032__0_`, `v`.`creative_size` AS `creative_size` FROM ( select * from viewability_5 ) v WHERE (((`v`.`browser` >= 'Non-Safari') AND (`v`.`browser` <= 'Safari')) AND (`v`.`country` = 'United States')) GROUP BY `v`.`creative_size` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593106000 + 1465593106000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT SUM(`v`.`comscore_measurable`) AS `temp_calculation_3253076685997178880__1019512392__0_`, SUM(`v`.`comscore_viewable`) AS `temp_calculation_3253076685997178880__4085906920__0_`, `v`.`os` AS `os`, SUM(`v`.`impressions`) AS `x_measure__0`, SUM(`v`.`impressions`) AS `x_measure__1` FROM ( select * from viewability_5 ) v WHERE (`v`.`country` = 'United States') GROUP BY `v`.`os` HAVING ((SUM(`v`.`impressions`) >= 1) AND (SUM(`v`.`impressions`) <= 454240033)) + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593109000 + 1465593109000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`browser` AS `browser` FROM ( select * from viewability_5 ) v GROUP BY `v`.`browser` ORDER BY `browser` ASC + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593117000 + 1465593117000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`strategy_type` AS `strategy_type` FROM ( select * from viewability_5 ) v WHERE ((`v`.`strategy_type` >= '+1CITIES') AND (`v`.`strategy_type` <= 'WIDE SCAN PROSPECTING')) GROUP BY `v`.`strategy_type` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593121000 + 1465593121000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT SUM(`v`.`comscore_measurable`) AS `temp_calculation_3253076685997178880__1019512392__0_`, SUM(`v`.`comscore_viewable`) AS `temp_calculation_3253076685997178880__4085906920__0_`, `v`.`campaign_name` AS `campaign_name`, SUM(`v`.`clicks`) AS `sum_clicks_ok`, SUM(`v`.`conversions`) AS `sum_conversions_ok`, SUM(`v`.`impressions`) AS `sum_impressions_ok` FROM ( select * from viewability_5 ) v WHERE (((`v`.`datasource` >= 'ADAP_TV') AND (`v`.`datasource` <= 'source_placement')) AND ((`v`.`strategy_type` >= '+1CITIES') AND (`v`.`strategy_type` <= 'WIDE SCAN PROSPECTING'))) GROUP BY `v`.`campaign_name` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593123000 + 1465593123000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`advertiser_name` AS `advertiser_name`, `v`.`datasource` AS `datasource`, SUM(`v`.`impressions`) AS `sum_impressions_ok`, SUM(`v`.`int_viewable`) AS `sum_int_viewable_ok` FROM ( select * from viewability_5 ) v WHERE (((`v`.`country` IN ('Anguilla')) OR ((`v`.`country` >= 'Afghanistan') AND (`v`.`country` <= 'Andorra')) OR ((`v`.`country` >= 'Antigua and Barbuda') AND (`v`.`country` <= 'Belgium')) OR ((`v`.`country` >= 'Benin') AND (`v`.`country` <= 'Jersey')) OR ((`v`.`country` >= 'Kazakhstan') AND (`v`.`country` <= 'Zimbabwe'))) AND ((`v`.`creative_size` >= '1000x300') AND (`v`.`creative_size` <= '980x120'))) GROUP BY `v`.`advertiser_name`, `v`.`datasource` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593123000 + 1465593123000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`country` AS `country` FROM ( select * from viewability_5 ) v WHERE ((`v`.`creative_size` >= '1000x300') AND (`v`.`creative_size` <= '980x120')) GROUP BY `v`.`country` ORDER BY `country` ASC + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593123000 + 1465593123000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`creative_size` AS `creative_size`, `v`.`strategy_type` AS `strategy_type`, SUM(`v`.`clicks`) AS `sum_clicks_ok` FROM ( select * from viewability_5 ) v WHERE ((CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) >= CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(-89 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP)) AND (CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) < CAST(CONCAT(DATE_ADD(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), CAST(1 AS INT)), SUBSTR(CAST(CONCAT(TO_DATE(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), ' 00:00:00') AS TIMESTAMP), 11)) AS TIMESTAMP))) GROUP BY `v`.`creative_size`, `v`.`strategy_type` + + + + + + Store as String + + + + + continue + + false + 10 + + 3 + 1 + 1465593123000 + 1465593123000 + false + + + + + + true + Select 1 + 5000 + local + jdbc:hive2://10.101.148.46:10001/default + org.apache.hive.jdbc.HiveDriver + true + + 100 + 1000000 + DEFAULT + 6000000 + + + + + local + Select Statement + SELECT `v`.`campaign_name` AS `campaign_name`, (((YEAR(CAST(`v`.`date_string` AS TIMESTAMP)) * 10000) + (MONTH(CAST(`v`.`date_string` AS TIMESTAMP)) * 100)) + DAY(CAST(`v`.`date_string` AS TIMESTAMP))) AS `md_date_string_ok`, SUM(`v`.`clicks`) AS `sum_clicks_ok` FROM ( select * from viewability_5 ) v WHERE (((`v`.`creative_size` IN ('468x60')) OR ((`v`.`creative_size` >= '1000x300') AND (`v`.`creative_size` <= '1800x1000')) OR ((`v`.`creative_size` >= '300x250') AND (`v`.`creative_size` <= '320x250')) OR ((`v`.`creative_size` >= '320x480') AND (`v`.`creative_size` <= '336x280')) OR ((`v`.`creative_size` >= '480x60') AND (`v`.`creative_size` <= '728x90')) OR ((`v`.`creative_size` >= '930x180') AND (`v`.`creative_size` <= '980x120'))) AND ((CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) >= CAST(CONCAT(YEAR(CAST(CONCAT(YEAR(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), '-01-01 00:00:00') AS TIMESTAMP))+-2, SUBSTR(CAST(CONCAT(YEAR(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), '-01-01 00:00:00') AS TIMESTAMP), 5)) AS TIMESTAMP)) AND (CAST(CAST(`v`.`date_string` AS TIMESTAMP) AS TIMESTAMP) < CAST(CONCAT(YEAR(CAST(CONCAT(YEAR(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), '-01-01 00:00:00') AS TIMESTAMP))+1, SUBSTR(CAST(CONCAT(YEAR(CAST(FROM_UNIXTIME(UNIX_TIMESTAMP()) AS TIMESTAMP)), '-01-01 00:00:00') AS TIMESTAMP), 5)) AS TIMESTAMP)))) GROUP BY `v`.`campaign_name`, (((YEAR(CAST(`v`.`date_string` AS TIMESTAMP)) * 10000) + (MONTH(CAST(`v`.`date_string` AS TIMESTAMP)) * 100)) + DAY(CAST(`v`.`date_string` AS TIMESTAMP))) + + + + + + Store as String + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + + + + + diff --git a/src/test/scala/org/sparklinedata/druid/client/BaseTest.scala b/src/test/scala/org/sparklinedata/druid/client/BaseTest.scala index 7a07c3d..a52f0b3 100644 --- a/src/test/scala/org/sparklinedata/druid/client/BaseTest.scala +++ b/src/test/scala/org/sparklinedata/druid/client/BaseTest.scala @@ -211,7 +211,7 @@ abstract class BaseTest extends fixture.FunSuite with df1 : DataFrame, df2 : DataFrame ) : Unit = { - assert(result(df1) == result(df2)) + assert(result(df1) == result(df2)) } def test(nm : String, sql : String, @@ -233,6 +233,25 @@ abstract class BaseTest extends fixture.FunSuite with } } + + def cTest(nm : String, + dsql: String, + bsql : String, + debugTransforms : Boolean = false) : Unit = { + test(nm) {td => + try { + println("modifiefff") + if (debugTransforms) turnOnTransformDebugging + val df1 = sqlAndLog(nm, dsql) + val df2 = sqlAndLog(nm, bsql) + assert(isTwoDataFrameEqual(df1, df2)) + } finally { + turnOffTransformDebugging + + } + } + } + def sqlAndLog(nm : String, sqlStr : String) : DataFrame = { logInfo(s"\n$nm SQL:\n" + sqlStr) sql(sqlStr) @@ -263,5 +282,100 @@ abstract class BaseTest extends fixture.FunSuite with TestHive.setConf(DruidPlanner.DEBUG_TRANSFORMATIONS.key, "false") } + + def isTwoDataFrameEqual(df1 : DataFrame, + df2 : DataFrame, + Sorted : Boolean = false, + chooseRounding : Boolean = true): Boolean = { + val df1_count = df1.count() + val df2_count = df2.count() + if(df1_count != df2_count){ + println(df1_count + "\t" + df2_count) + println("The row count is not equal") + return false + } + + val df1_column = df1.columns + val df2_column = df2.columns + val column1_length = df1_column.length + val column2_length = df2_column.length + if (column1_length != column2_length){ + println(column1_length + "\t" + column2_length) + println("The column length is not equal") + return false + } + + var df1_list = df1.collectAsList() + var df2_list = df2.collectAsList() + if (!Sorted) { + var df11 = df1.sort(df1_column(0)) + var df22 = df2.sort(df2_column(0)) + for (i <- 1 to column1_length - 1) { + df11 = df11.sort(df1_column(i)) + df22 = df22.sort(df2_column(i)) + } + df1_list = df11.collectAsList() + df2_list = df22.collectAsList() + } + if(!chooseRounding) { + for (i <- 0 to df1_count.toInt - 1){ + for (j <- 0 to column1_length - 1){ + if(df1_list.get(i).get(j) != + df2_list.get(i).get(j)){ + println(df1_list.get(i).get(j) + "\t" + df2_list.get(i).get(j)) + println("The row content is not equal") + return false + } + } + } + }else{ + for (i <- 0 to df1_count.toInt - 1){ + for (j <- 0 to column1_length - 1){ + if (df1_list.get(i).get(j) == null || + df2_list.get(i).get(j) == null){ + if (df1_list.get(i).get(j) != + df2_list.get(i).get(j)){ + println(df1_list.get(i).get(j) + "\t" + df2_list.get(i).get(j)) + println("The row content is not equal null") + return false + } + }else{ + var raw1 = (df1_list.get(i).get(j)).toString + var raw2 = (df2_list.get(i).get(j)).toString + if (raw1.endsWith("f") || raw1.endsWith("F")){ + raw1 = raw1.substring(0, raw1.length - 1) + } + if (raw2.endsWith("f") || raw2.endsWith("F")){ + raw2 = raw2.substring(0, raw2.length - 1) + } + try { + val res1 = BigDecimal(raw1) + .setScale(2, BigDecimal.RoundingMode.HALF_UP) + .toDouble + val res2 = BigDecimal(raw2) + .setScale(2, BigDecimal.RoundingMode.HALF_UP) + .toDouble + if(res1 != res2){ + println(res1 + "\t" + res2) + println("The rouding row content is not equal null") + return false + } + }catch{ + case ex: Exception => { + if(raw1 != raw2){ + println(raw1 + "\t" + raw2) + println("The rouding exce row content is not equal null") + return false + } + } + } + } + } + } + } + println("The two dataframe is equal " + df1_count) + return true + } + } diff --git a/src/test/scala/org/sparklinedata/druid/client/CodeGenCorrectnessTest.scala b/src/test/scala/org/sparklinedata/druid/client/CodeGenCorrectnessTest.scala new file mode 100644 index 0000000..7df2e5c --- /dev/null +++ b/src/test/scala/org/sparklinedata/druid/client/CodeGenCorrectnessTest.scala @@ -0,0 +1,601 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.sparklinedata.druid.client + +import org.apache.spark.Logging +import org.scalatest.BeforeAndAfterAll + +class CodeGenCorrectnessTest extends BaseTest with BeforeAndAfterAll with Logging { + + cTest("gbexprtest1", + "select sum(c_acctbal) as bal from orderLineItemPartSupplier where l_shipdate >= " + + "'1994-01-01' " + + " and l_shipdate <= '1997-01-01' group by " + + "(substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000')" + + " AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by bal", + "select sum(c_acctbal) as bal from orderLineItemPartSupplierBase where " + + "l_shipdate >= " + + "'1994-01-01' and l_shipdate " + + "<= '1997-01-01' group by " + + "(substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000')" + + " AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by bal" + ) + + cTest("gbexprtest2", + "select o_orderdate, " + + "(substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000Z') " + + "AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) x," + + "sum(c_acctbal) as bal from orderLineItemPartSupplier where l_shipdate >= " + + "'1994-01-01'" + + " and l_shipdate <= '1997-01-01' group by " + + "o_orderdate, (substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate)," + + " 'T00:00:00.000Z') AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by o_orderdate, x, bal", + "select o_orderdate, " + + "(substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate), 'T00:00:00.000Z') " + + "AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) x," + + "sum(c_acctbal) as bal from orderLineItemPartSupplierBase where To_date(l_shipdate) >= " + + "cast('1994-01-01' as date) " + + "and To_date(l_shipdate) <= cast('1997-01-01' as date) group by " + + "o_orderdate, (substr(CAST(Date_Add(TO_DATE(CAST(CONCAT(TO_DATE(o_orderdate)," + + " 'T00:00:00.000Z') AS TIMESTAMP)), 5) AS TIMESTAMP), 0, 10)) order by o_orderdate, x, bal" + ) + + cTest("gbexprtest3", + "select o_orderdate, " + + "(DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) as x " + + "from orderLineItemPartSupplier where l_shipdate >= '1994-01-01' " + + "and l_shipdate <= '1997-01-01' group by o_orderdate, " + + "cast('2015-07-21 10:10:10 PST' as date), " + + " (DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) " + + "order by o_orderdate, x", + "select o_orderdate, " + + "(DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) as x " + + "from orderLineItemPartSupplierBase where l_shipdate" + + " >= '1994-01-01' " + + "and l_shipdate <= '1997-01-01' group by o_orderdate, " + + "cast('2015-07-21 10:10:10 PST' as date), " + + " (DateDiff(cast(o_orderdate as date), cast('2015-07-21 10:10:10 PST' as date))) " + + "order by o_orderdate, x" + ) + + cTest("gbexprtest4", + "select (Date_add(cast(o_orderdate as date), 360+3)) as x " + + "from orderLineItemPartSupplier where l_shipdate >= '1994-01-01' " + + "and l_shipdate <= '1997-01-01' group by " + + "(Date_add(cast(o_orderdate as date), 360+3)) order by x", + + "select (Date_add(cast(o_orderdate as date), 360+3)) as x " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= " + + "'1994-01-01' " + + "and l_shipdate <= '1997-01-01' group by " + + "(Date_add(cast(o_orderdate as date), 360+3)) order by x" + ) + + cTest("gbexprtest5", + "select (Date_sub(cast(o_orderdate as date), 360+3)) as x " + + "from orderLineItemPartSupplier where l_shipdate >=" + + "'1994-01-01' " + + " and l_shipdate <='1997-01-01' group by " + + "(Date_sub(cast(o_orderdate as date), 360+3)) order by x", + "select (Date_sub(cast(o_orderdate as date), 360+3)) as x " + + "from orderLineItemPartSupplierBase where l_shipdate >= " + + "'1994-01-01' " + + " and l_shipdate <= '1997-01-01' group by " + + "(Date_sub(cast(o_orderdate as date), 360+3)) order by x" + ) + + cTest("gbexprtest6", + "select o_orderdate, (weekofyear(Date_Add(cast(o_orderdate as date), 1))) as x " + + "from orderLineItemPartSupplier where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' group by o_orderdate, " + + "(weekofyear(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate", + "select o_orderdate, (weekofyear(Date_Add(cast(o_orderdate as date), 1))) as x " + + "from orderLineItemPartSupplierBase where l_shipdate >= '1994-01-01' and " + + " l_shipdate <= '1997-01-01' group by o_orderdate, " + + "(weekofyear(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate" + ) + + cTest("gbexprtest7", + "select o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) as x " + + "from orderLineItemPartSupplier where l_shipdate >= '1994-01-01' and " + + " l_shipdate <= '1997-01-01' group by o_orderdate, " + + "(unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate, x", + "select o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) as x " + + "from orderLineItemPartSupplierBase where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' group by o_orderdate, " + + "(unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) order by o_orderdate, x" + ) + + + cTest("gbexprtest8", + "SELECT o_orderdate, Cast(Concat(Year(Cast(o_orderdate AS TIMESTAMP)), " + + "(CASE WHEN Month(Cast(o_orderdate AS TIMESTAMP))<4 " + + "THEN '-01' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<7 " + + "THEN '-04' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<10 " + + "THEN '-07' ELSE '-10' END), '-01 00:00:00') " + + "AS TIMESTAMP) AS x " + + "FROM (SELECT * FROM orderLineItemPartSupplier) m " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY o_orderdate, cast(concat(year(cast(o_orderdate AS timestamp)), " + + "(CASE WHEN month(cast(o_orderdate AS timestamp))<4 THEN '-01' " + + "WHEN month(cast(o_orderdate AS timestamp))<7 THEN '-04' " + + "WHEN month(cast(o_orderdate AS timestamp))<10 " + + "THEN '-07' ELSE '-10' END), '-01 00:00:00') AS timestamp)" + + " order by o_orderdate, x ", + "SELECT o_orderdate, Cast(Concat(Year(Cast(o_orderdate AS TIMESTAMP)), " + + "(CASE WHEN Month(Cast(o_orderdate AS TIMESTAMP))<4 " + + "THEN '-01' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<7 " + + "THEN '-04' WHEN Month(Cast(o_orderdate AS TIMESTAMP))<10 " + + "THEN '-07' ELSE '-10' END), '-01 00:00:00') " + + "AS TIMESTAMP) AS x " + + "FROM (SELECT * FROM orderLineItemPartSupplierBase) m " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY o_orderdate, cast(concat(year(cast(o_orderdate AS timestamp)), " + + "(CASE WHEN month(cast(o_orderdate AS timestamp))<4 THEN '-01' " + + "WHEN month(cast(o_orderdate AS timestamp))<7 THEN '-04' " + + "WHEN month(cast(o_orderdate AS timestamp))<10 " + + "THEN '-07' ELSE '-10' END), '-01 00:00:00') AS timestamp)" + + " order by o_orderdate, x " + ) + + cTest("gbexprtest9", + "select o_orderdate as x " + + "from orderLineItemPartSupplier " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) " + + "order by o_orderdate, x", + "select o_orderdate as x " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, (unix_timestamp(Date_Add(cast(o_orderdate as date), 1))) " + + "order by o_orderdate, x" + ) + + + + cTest("gbexprtest10", + " SELECT CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT) " + + "AS `qr_row_hr_ok`, YEAR(CAST(o_orderdate AS TIMESTAMP)) AS `yr_row_hr_ok` " + + "FROM ( select * from orderLineItemPartSupplier) custom_sql_query " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY " + + "CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT), " + + "YEAR(CAST(o_orderdate AS TIMESTAMP)) order by qr_row_hr_ok, yr_row_hr_ok", + " SELECT CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT) " + + "AS `qr_row_hr_ok`, YEAR(CAST(o_orderdate AS TIMESTAMP)) AS `yr_row_hr_ok` " + + "FROM ( select * from orderLineItemPartSupplierBase) custom_sql_query " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY " + + "CAST((MONTH(CAST(o_orderdate AS TIMESTAMP)) - 1) / 3 + 1 AS BIGINT), " + + "YEAR(CAST(o_orderdate AS TIMESTAMP)) order by qr_row_hr_ok, yr_row_hr_ok" + ) + + cTest("gbexprtest11", + " SELECT CAST(((MONTH(CAST(l_shipdate AS TIMESTAMP)) - 1) / 3) * 2 AS BIGINT) " + + "AS `qr_row_hr_ok`, YEAR(CAST(l_shipdate AS TIMESTAMP)) AS `yr_row_hr_ok` " + + "FROM ( select * from orderLineItemPartSupplier) custom_sql_query " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY " + + "CAST(((MONTH(CAST(l_shipdate AS TIMESTAMP)) - 1) / 3) * 2 AS BIGINT), " + + "YEAR(CAST(l_shipdate AS TIMESTAMP)) order by qr_row_hr_ok, yr_row_hr_ok", + " SELECT CAST(((MONTH(CAST(l_shipdate AS TIMESTAMP)) - 1) / 3) * 2 AS BIGINT) " + + "AS `qr_row_hr_ok`, YEAR(CAST(l_shipdate AS TIMESTAMP)) AS `yr_row_hr_ok` " + + "FROM ( select * from orderLineItemPartSupplierBase) custom_sql_query " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "GROUP BY " + + "CAST(((MONTH(CAST(l_shipdate AS TIMESTAMP)) - 1) / 3) * 2 AS BIGINT), " + + "YEAR(CAST(l_shipdate AS TIMESTAMP)) order by qr_row_hr_ok, yr_row_hr_ok" + ) + + cTest("gbexprtest12", + "select o_orderdate, (from_unixtime(second(Date_Add(cast(o_orderdate as date), 1)))) as x " + + "from orderLineItemPartSupplier " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, (from_unixtime(second(Date_Add(cast(o_orderdate as date), 1)))) " + + "order by o_orderdate, x", + "select o_orderdate, (from_unixtime(second(Date_Add(cast(o_orderdate as date), 1)))) as x " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <='1997-01-01' " + + "group by " + + "o_orderdate, (from_unixtime(second(Date_Add(cast(o_orderdate as date), 1)))) " + + "order by o_orderdate, x" + ) + + cTest("gbexprtest13", + "select o_orderdate, " + + "datediff(" + + "date_add(to_date(cast(o_orderdate as timestamp)), (year(cast(o_orderdate as date))%100)), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), quarter(cast(o_orderdate as date))*2)" + + ") as c1, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), month(cast(o_orderdate as date))), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), weekofyear(cast(o_orderdate as date)))" + + ")as c2, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), day(cast(o_orderdate as date))), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), hour(cast(o_orderdate as date))+10))" + + "as c3, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), minute(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), second(cast(o_orderdate as date))+10))" + + " as c4 " + + "from orderLineItemPartSupplier " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "year(cast(o_orderdate as date))%100)," + + "date_sub(to_date(cast(o_orderdate as timestamp)), quarter(cast(o_orderdate as date))*2))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "month(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), weekofyear(cast(o_orderdate as date))))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "day(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), hour(cast(o_orderdate as date))+10))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "minute(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), second(cast(o_orderdate as date))+10)) " + + "order by o_orderdate, c1, c2, c3, c4", + "select o_orderdate, " + + "datediff(" + + "date_add(to_date(cast(o_orderdate as timestamp)), (year(cast(o_orderdate as date))%100)), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), quarter(cast(o_orderdate as date))*2)" + + ") as c1, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), month(cast(o_orderdate as date))), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), weekofyear(cast(o_orderdate as date)))" + + ")as c2, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), day(cast(o_orderdate as date))), " + + "date_sub(to_date(cast(o_orderdate as timestamp)), hour(cast(o_orderdate as date))+10))" + + "as c3, " + + "datediff( " + + "date_add(to_date(cast(o_orderdate as timestamp)), minute(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), second(cast(o_orderdate as date))+10))" + + " as c4 " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "year(cast(o_orderdate as date))%100)," + + "date_sub(to_date(cast(o_orderdate as timestamp)), quarter(cast(o_orderdate as date))*2))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "month(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), weekofyear(cast(o_orderdate as date))))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "day(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), hour(cast(o_orderdate as date))+10))," + + "datediff(date_add(to_date(cast(o_orderdate as timestamp)), " + + "minute(cast(o_orderdate as date)))," + + "date_sub(to_date(cast(o_orderdate as timestamp)), second(cast(o_orderdate as date))+10)) " + + "order by o_orderdate, c1, c2, c3, c4" + ) + + + cTest("gbexprtest14", + "select o_orderdate, " + + "date_add(cast(upper(concat(concat(substr(cast(cast(o_orderdate as timestamp) as string)," + + " 0, 10), 't'), substr(cast(cast(o_orderdate as timestamp) as string), 11, 8))) as date)," + + " 20) as x " + + "from orderLineItemPartSupplier " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "date_add(cast(upper(concat(concat(substr(cast(cast(o_orderdate as timestamp) as string)," + + " 0, 10), 't'), substr(cast(cast(o_orderdate as timestamp) as string), 11, 8))) as date)," + + " 20)" + + "order by o_orderdate, x", + "select o_orderdate, " + + "date_add(cast(upper(concat(concat(substr(cast(cast(o_orderdate as timestamp) as string)," + + " 0, 10), 't'), substr(cast(cast(o_orderdate as timestamp) as string), 11, 8))) as date)," + + " 20) as x " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "date_add(cast(upper(concat(concat(substr(cast(cast(o_orderdate as timestamp) as string)," + + " 0, 10), 't'), substr(cast(cast(o_orderdate as timestamp) as string), 11, 8))) as date)," + + " 20)" + + "order by o_orderdate, x" + ) + + cTest("gbexprtest15", + "select o_orderdate, " + + "Coalesce((CASE WHEN Month(Cast(o_orderdate AS date)) > 0 and " + + "Month(Cast(o_orderdate AS date)) < 4 THEN \"Q1\" else null END), " + + " (CASE WHEN Month(Cast(o_orderdate AS date)) >= 4 and Month(Cast(o_orderdate AS date))" + + " <= 6 THEN \"Q2\" else null END), (CASE WHEN Month(Cast(o_orderdate AS date)) > 6" + + " and Month(Cast(o_orderdate AS date)) <= 8 THEN \"Q3\" else null END)," + + " (CASE WHEN Month(Cast(o_orderdate AS date)) <> 12 THEN \"Not Dec\" else null END)," + + " (CASE WHEN Month(Cast(o_orderdate AS date)) = 12 THEN \"Dec\" else null END))as x " + + "from orderLineItemPartSupplier " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "Coalesce((CASE WHEN Month(Cast(o_orderdate AS date)) > 0 and " + + "Month(Cast(o_orderdate AS date)) < 4 THEN \"Q1\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) >= 4 and " + + "Month(Cast(o_orderdate AS date)) <= 6 THEN \"Q2\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) > 6 and " + + "Month(Cast(o_orderdate AS date)) <= 8 THEN \"Q3\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) <> 12 " + + "THEN \"Not Dec\" else null END), (CASE WHEN Month(Cast(o_orderdate AS date)) = 12 " + + "THEN \"Dec\" else null END))" + + "order by o_orderdate, x", + "select o_orderdate, " + + "Coalesce((CASE WHEN Month(Cast(o_orderdate AS date)) > 0 and " + + "Month(Cast(o_orderdate AS date)) < 4 THEN \"Q1\" else null END), " + + " (CASE WHEN Month(Cast(o_orderdate AS date)) >= 4 and Month(Cast(o_orderdate AS date))" + + " <= 6 THEN \"Q2\" else null END), (CASE WHEN Month(Cast(o_orderdate AS date)) > 6" + + " and Month(Cast(o_orderdate AS date)) <= 8 THEN \"Q3\" else null END)," + + " (CASE WHEN Month(Cast(o_orderdate AS date)) <> 12 THEN \"Not Dec\" else null END)," + + " (CASE WHEN Month(Cast(o_orderdate AS date)) = 12 THEN \"Dec\" else null END))as x " + + "from orderLineItemPartSupplierBase " + + "where l_shipdate >= '1994-01-01' and " + + "l_shipdate <= '1997-01-01' " + + "group by " + + "o_orderdate, " + + "Coalesce((CASE WHEN Month(Cast(o_orderdate AS date)) > 0 and " + + "Month(Cast(o_orderdate AS date)) < 4 THEN \"Q1\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) >= 4 and " + + "Month(Cast(o_orderdate AS date)) <= 6 THEN \"Q2\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) > 6 and " + + "Month(Cast(o_orderdate AS date)) <= 8 THEN \"Q3\" else null END), " + + "(CASE WHEN Month(Cast(o_orderdate AS date)) <> 12 " + + "THEN \"Not Dec\" else null END), (CASE WHEN Month(Cast(o_orderdate AS date)) = 12 " + + "THEN \"Dec\" else null END))" + + "order by o_orderdate, x" + ) + + + cTest("aggTest1", + """ + |SELECT MIN(CAST(CAST(l_shipdate AS TIMESTAMP) AS TIMESTAMP)) AS x, + | MAX(CAST(CAST(l_shipdate AS TIMESTAMP) AS TIMESTAMP)) AS y, + | COUNT(1) AS c + | FROM ( select * from orderLineItemPartSupplier ) custom_sql_query + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | HAVING (COUNT(1) > 0) + """.stripMargin, + """ + |SELECT MIN(CAST(CAST(l_shipdate AS TIMESTAMP) AS TIMESTAMP)) AS x, + | MAX(CAST(CAST(l_shipdate AS TIMESTAMP) AS TIMESTAMP)) AS y, + | COUNT(1) AS c + | FROM ( select * from orderLineItemPartSupplierBase ) custom_sql_query + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | HAVING (COUNT(1) > 0) + """.stripMargin + ) + + cTest("aggTest2", + """ + |SELECT sum(l_quantity + 10) as s, MIN(l_quantity + 10) AS mi, + | MAX(l_quantity + 10) ma, COUNT(1) AS c + | FROM ( select * from orderLineItemPartSupplier ) custom_sql_query + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | HAVING (COUNT(1) > 0) order by s, mi, ma + """.stripMargin, + """ + |SELECT sum(l_quantity + 10) as s, MIN(l_quantity + 10) AS mi, + | MAX(l_quantity + 10) ma, COUNT(1) AS c + | FROM ( select * from orderLineItemPartSupplierBase ) custom_sql_query + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | HAVING (COUNT(1) > 0) order by s, mi, ma + """.stripMargin + ) + + cTest("aggTest3", + s""" + |SELECT Min(Cast(Concat(To_date(Cast(Concat(To_date(l_shipdate),' 00:00:00') + |AS TIMESTAMP)),' 00:00:00') AS TIMESTAMP)) AS mi, + |max(cast(concat(to_date(cast(concat(to_date(l_shipdate),' 00:00:00') AS timestamp)), + |' 00:00:00') AS timestamp)) AS ma, + |count(1) as c + |FROM orderLineItemPartSupplier + |where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + |HAVING (count(1) > 0) + """.stripMargin, + s""" + |SELECT Min(Cast(Concat(To_date(Cast(Concat(To_date(l_shipdate),' 00:00:00') + |AS TIMESTAMP)),' 00:00:00') AS TIMESTAMP)) AS mi, + |max(cast(concat(to_date(cast(concat(to_date(l_shipdate),' 00:00:00') AS timestamp)), + |' 00:00:00') AS timestamp)) AS ma, + |count(1) as c + |FROM orderLineItemPartSupplierBase + |where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + |HAVING (count(1) > 0) + """.stripMargin + ) + + cTest("pmod1", + """ + |SELECT max(pmod(o_totalprice, -5)) as s + | FROM orderLineItemPartSupplier + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | group by s_region + | order by s + """.stripMargin, + """ + |SELECT max(pmod(o_totalprice, -5)) as s + | FROM orderLineItemPartSupplierBase + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | group by s_region + | order by s + """.stripMargin + ) + + cTest("pmod2", + """ + |SELECT max(pmod(-5, o_totalprice)) as s + | FROM orderLineItemPartSupplier + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | group by s_region + | order by s + """.stripMargin, + """ + |SELECT max(pmod(-5, o_totalprice)) as s + | FROM orderLineItemPartSupplierBase + | where l_shipdate >= '1994-01-01' and + | l_shipdate <= '1997-01-01' + | group by s_region + | order by s + """.stripMargin + ) + + cTest("strGTLTEq1", + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplier + |where (o_orderdate <= '1993-12-12') and + |(o_orderdate >= '1993-10-12') + |and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin, + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplierBase + |where (o_orderdate <= '1993-12-12') and + |(o_orderdate >= '1993-10-12') + |and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin + ) + + cTest("dateEq1", + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplier + |where cast(o_orderdate as date) = cast('1994-06-30' as Date) + |and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin, + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplierBase + |where cast(o_orderdate as date) = cast('1994-06-30' as Date) + |and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin + ) + + cTest("dateGTLTEq1", + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplier + |where (cast(o_orderdate as date) <= cast('1993-12-12' as Date)) + | and (cast(o_orderdate as date) >= cast('1993-10-12' as Date)) + | and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin, + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplierBase + |where (cast(o_orderdate as date) <= cast('1993-12-12' as Date)) + | and (cast(o_orderdate as date) >= cast('1993-10-12' as Date)) + | and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin) + + cTest("tsGTLTEq1", + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplier + |where (cast(l_shipdate as timestamp) <= cast('1993-12-12 00:00:00' as timestamp)) + | and (cast(l_shipdate as timestamp) >= cast('1993-10-12 00:00:00' as timestamp)) + | and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin, + """ + |select o_orderstatus as x, cast(o_orderdate as date) as y + |from orderLineItemPartSupplierBase + |where (cast(l_shipdate as timestamp) <= cast('1993-12-12 00:00:00' as timestamp)) + | and (cast(l_shipdate as timestamp) >= cast('1993-10-12 00:00:00' as timestamp)) + | and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + |group by o_orderstatus, cast(o_orderdate as date) + |order by x, y + """.stripMargin) + + + cTest("inclause-insetTest1", + s"""select c_name, sum(c_acctbal) as bal + from orderLineItemPartSupplier + where to_Date(o_orderdate) >= cast('1993-01-01' as date) and to_Date(o_orderdate) <= cast('1997-12-31' as date) + and cast(order_year as int) in (1985,1986,1987,1988,1989,1990,1991,1992, + 1993,1994,1995,1996,1997,1998,1999,2000, null) and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + group by c_name + order by c_name, bal""".stripMargin, + s"""select c_name, sum(c_acctbal) as bal + from orderLineItemPartSupplierBase + where to_Date(o_orderdate) >= cast('1993-01-01' as date) and to_Date(o_orderdate) <= cast('1997-12-31' as date) + and cast(order_year as int) in (1985,1986,1987,1988,1989,1990,1991,1992, + 1993,1994,1995,1996,1997,1998,1999,2000, null) and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + group by c_name + order by c_name, bal""".stripMargin + ) + + cTest("inclause-inTest1", + s"""select c_name, sum(c_acctbal) as bal + from orderLineItemPartSupplier + where to_Date(o_orderdate) >= cast('1993-01-01' as date) and to_Date(o_orderdate) <= cast('1997-12-31' as date) + and cast(order_year as int) in (1993,1994,1995, null) and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + group by c_name + order by c_name, bal""".stripMargin, + s"""select c_name, sum(c_acctbal) as bal + from orderLineItemPartSupplierBase + where to_Date(o_orderdate) >= cast('1993-01-01' as date) and to_Date(o_orderdate) <= cast('1997-12-31' as date) + and cast(order_year as int) in (1993,1994,1995, null) and (l_shipdate >= '1994-01-01' and l_shipdate <= '1997-01-01') + group by c_name + order by c_name, bal""".stripMargin + ) +}