提交 e85906f2 编写于 作者: H Heikki Linnakangas 提交者: Bhuvnesh

Move grouping tests from TINC.

上级 53552da6
此差异已折叠。
......@@ -124,7 +124,7 @@ test: qp_functions_in_contexts_setup
test: qp_functions_in_from qp_functions_in_select qp_functions_in_subquery qp_functions_in_subquery_constant qp_functions_in_with
test: olap_setup
test: qp_olap_group
test: qp_olap_group qp_olap_group2
ignore: tpch500GB_orca
......
此差异已折叠。
......@@ -330,7 +330,6 @@ optimizer_functional_part2:
$(TESTER) $(DISCOVER) \
-s dml \
-s functions \
-s olap \
-q tags=ORCA \
-q tags!=FEATURE_BRANCH_ONLY \
-q tags!=dpe
......
import os
import sys
import datetime
import math
import tinctest
import re
from time import gmtime, strftime
import unittest2 as unittest
from fnmatch import fnmatch
from mpp.models import SQLTestCase
import tinctest
from tinctest.lib import run_shell_command, Gpdiff
from mpp.lib.PSQL import PSQL
@tinctest.skipLoading("Test model")
class GroupingFunctionTestCase(SQLTestCase):
def __init__(self, methodName, baseline_result = None, sql_file = None, db_name = None):
super(GroupingFunctionTestCase, self).__init__(methodName, baseline_result, sql_file, db_name)
self.optimizer_mode='on'
def _infer_metadata(self):
super(GroupingFunctionTestCase, self)._infer_metadata()
self.executemode= self._metadata.get('executemode', 'positivetest')
def run_test(self):
sql_file = self.sql_file
ans_file = self.ans_file
source_file = sys.modules[self.__class__.__module__].__file__
source_dir = os.path.dirname(source_file)
out_file = os.path.join(self.get_out_dir(), os.path.basename(sql_file).replace('.sql', '.out'))
extrainfo = os.path.join(self.get_out_dir(), os.path.basename(sql_file).replace('.sql', '_extrainfo.diff'))
self.gucs.add('optimizer=on')
self.gucs.add('client_min_messages=\'log\'')
self.gucs.add('optimizer_log=on')
mod_sql_file = self._add_gucs_to_sql_file(sql_file)
PSQL.run_sql_file(mod_sql_file, dbname = self.db_name, out_file = out_file)
init_file_path = os.path.join(os.path.dirname(sql_file), 'init_file')
init_files = []
if os.path.exists(init_file_path):
init_files.append(init_file_path)
err = ""
if self.executemode == 'expectedfallback':
result_plan = self._checkforstring(out_file, 'Planner produced plan :0')
if result_plan == False:
err = "did not fallback properly"
else:
result_plan = self._checkforstring(out_file, 'Planner produced plan')
if result_plan == True:
err = "ORCA was not used when it's suppose to"
if len(err) > 0:
f = open(extrainfo, 'w')
f.write(err)
f.close()
result = Gpdiff.are_files_equal(out_file, self.ans_file, match_sub = init_files)
if len(err) < 1 and result:
return True
else:
return False
def _checkforstring(self, file, string):
f = open(file, 'r')
content = f.readlines()
f.close()
for x in content:
x = x.strip()
if string in x:
return True
return False
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc1.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT GROUPING(product.pname) as g1 FROM product, sale WHERE product.pn=sale.pn GROUP BY GROUPING SETS (sale.pn, product.pname) ORDER BY g1;
g1
----
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
(15 rows)
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc10.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT GROUPING(sale.pn) as g1 FROM product, sale WHERE product.pn=sale.pn GROUP BY ROLLUP((sale.pn,product.pname)) ORDER BY g1;
g1
----
0
0
0
0
0
0
0
0
1
(9 rows)
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc100.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT SUM(sale.pn) as g1, GROUPING(product.pname) as g2 FROM product, sale WHERE product.pn=sale.pn GROUP BY ROLLUP((sale.pn,product.pname)) ORDER BY g1,g2;
g1 | g2
------+----
200 | 0
300 | 0
400 | 0
600 | 0
700 | 0
800 | 0
800 | 0
1000 | 0
4800 | 1
(9 rows)
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc101.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT SUM(sale.pn) as g1, GROUPING(product.pname) as g2 FROM product, sale WHERE product.pn=sale.pn GROUP BY ROLLUP((sale.pn,product.pname,sale.pn)) ORDER BY g1,g2;
g1 | g2
------+----
200 | 0
300 | 0
400 | 0
600 | 0
700 | 0
800 | 0
800 | 0
1000 | 0
4800 | 1
(9 rows)
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc102.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT SUM(sale.pn) as g1, GROUPING(product.pname) as g2 FROM product, sale WHERE product.pn=sale.pn GROUP BY ROLLUP((sale.pn),(product.pname),(sale.pn)) ORDER BY g1,g2;
g1 | g2
------+----
200 | 0
200 | 0
200 | 1
300 | 0
300 | 0
300 | 1
400 | 0
400 | 0
400 | 1
600 | 0
600 | 0
600 | 1
700 | 0
700 | 0
700 | 1
800 | 0
800 | 0
800 | 0
800 | 0
800 | 1
800 | 1
1000 | 0
1000 | 0
1000 | 1
4800 | 1
(25 rows)
-- @author tungs1
-- @modified 2013-07-28 12:00:00
-- @created 2013-07-28 12:00:00
-- @description groupingfunction groupingfunc103.sql
-- @db_name groupingfunction
-- @executemode normal
-- @tags groupingfunction
-- order 1
SELECT SUM(sale.pn) as g1, GROUPING(sale.pn) as g2 FROM product, sale WHERE product.pn=sale.pn GROUP BY GROUPING SETS (sale.pn, product.pname) ORDER BY g1,g2;
g1 | g2
------+----
200 | 0
200 | 1
300 | 0
300 | 1
400 | 0
400 | 1
600 | 0
700 | 0
700 | 1
800 | 0
800 | 0
800 | 1
800 | 1
1000 | 0
1600 | 1
(15 rows)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册