mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Changes to rounding and naming. Enabling the extended datatypes tests.
This commit is contained in:
parent
d68338a792
commit
f44bdc0b75
File diff suppressed because it is too large
Load Diff
@ -63,7 +63,7 @@ def inline_check(self, arithmetic_func, expected_result, int_type, min, max, nod
|
||||
|
||||
with When(f"I check {arithmetic_func} with {int_type} max and min value"):
|
||||
execute_query(f"""
|
||||
SELECT {arithmetic_func}(to{int_type}(\'{max}\'), to{int_type}(1)), {arithmetic_func}(to{int_type}(\'{min}\'), to{int_type}(1))
|
||||
SELECT round({arithmetic_func}(to{int_type}(\'{max}\'), to{int_type}(1)), 7), round({arithmetic_func}(to{int_type}(\'{min}\'), to{int_type}(1)), 7)
|
||||
""")
|
||||
|
||||
@TestOutline
|
||||
@ -95,7 +95,7 @@ def table_check(self, arithmetic_func, expected_result, int_type, min, max, node
|
||||
else:
|
||||
|
||||
with When(f"I insert {arithmetic_func} with {int_type} into the table"):
|
||||
node.query(f"INSERT INTO {table_name} SELECT {arithmetic_func}(to{int_type}(1), to{int_type}(1))")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(to{int_type}(1), to{int_type}(1)), 7)")
|
||||
|
||||
with Then("I check that the output matches the expected value"):
|
||||
output = node.query(f"SELECT * FROM {table_name}").output
|
||||
@ -125,7 +125,7 @@ def table_check(self, arithmetic_func, expected_result, int_type, min, max, node
|
||||
for value in [min, max]:
|
||||
|
||||
with When(f"I insert {arithmetic_func} with {int_type} {value} into the table"):
|
||||
node.query(f"INSERT INTO {table_name} SELECT {arithmetic_func}(to{int_type}(\'{value}\'), to{int_type}(1))")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(to{int_type}(\'{value}\'), to{int_type}(1)), 7)")
|
||||
|
||||
with Then(f"I check the table output of {arithmetic_func} with {int_type}"):
|
||||
execute_query(f"""
|
||||
@ -191,7 +191,7 @@ def table_check_dec(self, arithmetic_func, expected_result, node=None):
|
||||
|
||||
else:
|
||||
with When(f"I insert {arithmetic_func} with toDecimal256 into the table"):
|
||||
node.query(f"INSERT INTO {table_name} SELECT {arithmetic_func}(toDecimal256(1,0), toDecimal256(1,0))")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(toDecimal256(1,0), toDecimal256(1,0)), 7)")
|
||||
|
||||
with Then("I check that the output matches the expected value"):
|
||||
output = node.query(f"SELECT * FROM {table_name}").output
|
||||
|
@ -39,12 +39,12 @@ def array_func(self, data_type, node=None):
|
||||
f'arrayConcat([{to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}],',
|
||||
'arrayFilter(x -> x == 1, ']:
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
execute_query(f"""
|
||||
SELECT {func}array({to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}))
|
||||
""")
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = f'Array({data_type})')
|
||||
@ -58,12 +58,12 @@ def array_func(self, data_type, node=None):
|
||||
|
||||
for func in ['arraySplit((x, y) -> x=y, [0, 0, 0],']:
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
execute_query(f"""
|
||||
SELECT {func}array({to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}))
|
||||
""")
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = f'Array(Array({data_type}))')
|
||||
@ -77,12 +77,12 @@ def array_func(self, data_type, node=None):
|
||||
|
||||
for func in [f'arrayZip([{to_data_type(data_type,1)}],']:
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
execute_query(f"""
|
||||
SELECT {func}array({to_data_type(data_type,3)}))
|
||||
""")
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = f'Array(Tuple({data_type}, {data_type}))')
|
||||
@ -115,11 +115,11 @@ def array_func(self, data_type, node=None):
|
||||
|
||||
if func in ['arrayMin(','arrayMax(','arraySum(', 'arrayAvg('] and data_type in ['Decimal256(0)']:
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
node.query(f"SELECT {func}array({to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}))",
|
||||
exitcode = 44, message = 'Exception:')
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = data_type)
|
||||
@ -134,13 +134,13 @@ def array_func(self, data_type, node=None):
|
||||
|
||||
else:
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
|
||||
execute_query(f"""
|
||||
SELECT {func}array({to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}))
|
||||
""")
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = data_type)
|
||||
@ -161,11 +161,11 @@ def array_func(self, data_type, node=None):
|
||||
else:
|
||||
exitcode = 43
|
||||
|
||||
with Scenario(f"Inline - {data_type} - {func}"):
|
||||
with Scenario(f"Inline - {data_type} - {func})"):
|
||||
node.query(f"SELECT {func}array({to_data_type(data_type,3)}, {to_data_type(data_type,2)}, {to_data_type(data_type,1)}))",
|
||||
exitcode = exitcode, message = 'Exception:')
|
||||
|
||||
with Scenario(f"Table - {data_type} - {func}"):
|
||||
with Scenario(f"Table - {data_type} - {func})"):
|
||||
table_name = get_table_name()
|
||||
|
||||
table(name = table_name, data_type = data_type)
|
||||
|
@ -11,6 +11,7 @@ funcs = [
|
||||
]
|
||||
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]} - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_list_dec = [tuple(list(func)+[Name(f'{func[0]} - Decimal256')]) for func in funcs]
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func int_type min max', Examples_list)
|
||||
@ -51,7 +52,7 @@ def comp_int_table(self, func, int_type, min, max, node=None):
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func', funcs)
|
||||
@Examples('func', Examples_list_dec)
|
||||
def comp_dec_inline(self, func, node=None):
|
||||
"""Check comparison functions with Decimal256 using inline tests.
|
||||
"""
|
||||
@ -67,7 +68,7 @@ def comp_dec_inline(self, func, node=None):
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func', funcs)
|
||||
@Examples('func', Examples_list_dec)
|
||||
def comp_dec_table(self, func, node=None):
|
||||
"""Check comparison functions with Decimal256 using table tests.
|
||||
"""
|
||||
|
@ -176,10 +176,24 @@ def to_decimal256(self, node=None):
|
||||
if node is None:
|
||||
node = self.context.node
|
||||
|
||||
with When(f"I check toDecimal256 with 0 scale with 1, {max}, and {min}"):
|
||||
|
||||
for value in [1,min,max]:
|
||||
output = node.query(f"SELECT toDecimal256(\'{value}\',0)").output
|
||||
assert output == str(value), error()
|
||||
|
||||
for scale in range(1,76):
|
||||
|
||||
with When(f"I check toDecimal256 with {scale} scale with its max"):
|
||||
output = node.query(f"SELECT toDecimal256(\'{10**(76-scale)-1}\',{scale})").output
|
||||
assert float(output) == float(10**(76-scale)-1), error()
|
||||
|
||||
with And(f"I check toDecimal256 with {scale} scale with its min"):
|
||||
output = node.query(f"SELECT toDecimal256(\'{-10**(76-scale)+1}\',{scale})").output
|
||||
assert float(output) == float(-10**(76-scale)+1), error()
|
||||
|
||||
#, toDecimal256(\'{-10**(76-scale)+1}\',{scale})
|
||||
|
||||
@TestScenario
|
||||
@Requirements(
|
||||
RQ_SRS_020_ClickHouse_Extended_Precision_Conversion_ToMySQL("1.0"),
|
||||
|
@ -9,6 +9,7 @@ funcs = [
|
||||
]
|
||||
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]} - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_list_dec = [tuple(list(func)+[Name(f'{func[0]} - Decimal256')]) for func in funcs]
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func int_type min max', Examples_list)
|
||||
|
@ -37,8 +37,8 @@ funcs = [
|
||||
('hypot(1,', 1, 43),
|
||||
]
|
||||
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]} - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_dec_list = [tuple(list(func)+[Name(f'{func[0]} - Decimal256')]) for func in funcs]
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]}) - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_dec_list = [tuple(list(func)+[Name(f'{func[0]}) - Decimal256')]) for func in funcs]
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func expected_result exitcode int_type min max', Examples_list)
|
||||
@ -65,7 +65,7 @@ def math_int_inline(self, func, expected_result, exitcode, int_type, min, max, n
|
||||
|
||||
with And(f"I check {func} with {int_type} using max and min"):
|
||||
execute_query(f"""
|
||||
SELECT {func} to{int_type}(\'{max}\')), {func} to{int_type}(\'{min}\'))
|
||||
SELECT round({func} to{int_type}(\'{max}\')), 7), round({func} to{int_type}(\'{min}\')), 7)
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@ -94,7 +94,7 @@ def math_int_table(self, func, expected_result, exitcode, int_type, min, max, no
|
||||
for value in [1, max, min]:
|
||||
|
||||
with And(f"I insert the output of {func} with {int_type} using {value} into a table"):
|
||||
node.query(f"INSERT INTO {table_name} SELECT to{int_type}OrZero( toString({func} to{int_type}(\'{value}\'))))")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round(to{int_type}OrZero( toString({func} to{int_type}(\'{value}\')))), 7)")
|
||||
|
||||
with Then(f"I check the outputs of {func} with {int_type}"):
|
||||
execute_query(f"""
|
||||
@ -129,7 +129,7 @@ def math_dec_inline(self, func, expected_result, exitcode, node=None):
|
||||
|
||||
with And(f"I check {func} with Decimal256 using max and min"):
|
||||
execute_query(f"""
|
||||
SELECT {func} toDecimal256(\'{max}\',0)), {func} toDecimal256(\'{min}\',0))
|
||||
SELECT round({func} toDecimal256(\'{max}\',0)),7), round({func} toDecimal256(\'{min}\',0)),7)
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@ -161,7 +161,7 @@ def math_dec_table(self, func, expected_result, exitcode, node=None):
|
||||
for value in [1, max, min]:
|
||||
|
||||
with When(f"I insert the output of {func} with Decimal256 using {value} into a table"):
|
||||
node.query(f"INSERT INTO {table_name} SELECT toDecimal256OrZero( toString({func} toDecimal256(\'{value}\',0))),0)")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round(toDecimal256OrZero( toString({func} toDecimal256(\'{value}\',0))),0), 7)")
|
||||
|
||||
with Then(f"I check the outputs of {func} with Decimal256"):
|
||||
execute_query(f"""
|
||||
|
@ -11,7 +11,8 @@ funcs = [
|
||||
('nullIf(1,', '\\N'),
|
||||
]
|
||||
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]} - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_list = [tuple(list(func)+list(data_type)+[Name(f'{func[0]}) - {data_type[0]}')]) for func in funcs for data_type in data_types]
|
||||
Examples_list_dec = [tuple(list(func)+[Name(f'{func[0]}) - Decimal256')]) for func in funcs]
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func expected_result int_type min max', Examples_list)
|
||||
@ -56,7 +57,7 @@ def null_int_table(self, func, expected_result, int_type, min, max, node=None):
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func expected_result', funcs)
|
||||
@Examples('func expected_result', Examples_list_dec)
|
||||
def null_dec_inline(self, func, expected_result, node=None):
|
||||
"""Check null function with Decimal256 using inline tests.
|
||||
"""
|
||||
@ -76,7 +77,7 @@ def null_dec_inline(self, func, expected_result, node=None):
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
@Examples('func expected_result', funcs)
|
||||
@Examples('func expected_result', Examples_list_dec)
|
||||
def null_dec_table(self, func, expected_result, node=None):
|
||||
"""Check null function with Decimal256 using table tests.
|
||||
"""
|
||||
|
@ -30,7 +30,7 @@ def regression(self, local, clickhouse_binary_path, stress=None, parallel=None):
|
||||
run_scenario(pool, tasks, Feature(test=load("window_functions.regression", "regression")), args)
|
||||
run_scenario(pool, tasks, Feature(test=load("datetime64_extended_range.regression", "regression")), args)
|
||||
#run_scenario(pool, tasks, Feature(test=load("kerberos.regression", "regression")), args)
|
||||
#run_scenario(pool, tasks, Feature(test=load("extended_precision_data_types.regression", "regression")), args)
|
||||
run_scenario(pool, tasks, Feature(test=load("extended_precision_data_types.regression", "regression")), args)
|
||||
finally:
|
||||
join(tasks)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user