mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Rounding precision controlled by one variable
This commit is contained in:
parent
1d64786e81
commit
8169399589
@ -8,6 +8,8 @@ from testflows.asserts import values, error, snapshot
|
||||
|
||||
from helpers.common import *
|
||||
|
||||
rounding_precision = 7
|
||||
|
||||
@contextmanager
|
||||
def allow_experimental_bigint(node):
|
||||
"""Enable experimental big int setting in Clickhouse.
|
||||
|
@ -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 round({arithmetic_func}(to{int_type}(\'{max}\'), to{int_type}(1)), 7), round({arithmetic_func}(to{int_type}(\'{min}\'), to{int_type}(1)), 7)
|
||||
SELECT round({arithmetic_func}(to{int_type}(\'{max}\'), to{int_type}(1)), {rounding_precision}), round({arithmetic_func}(to{int_type}(\'{min}\'), to{int_type}(1)), {rounding_precision})
|
||||
""")
|
||||
|
||||
@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 round({arithmetic_func}(to{int_type}(1), to{int_type}(1)), 7)")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(to{int_type}(1), to{int_type}(1)), {rounding_precision})")
|
||||
|
||||
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 round({arithmetic_func}(to{int_type}(\'{value}\'), to{int_type}(1)), 7)")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(to{int_type}(\'{value}\'), to{int_type}(1)), {rounding_precision})")
|
||||
|
||||
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 round({arithmetic_func}(toDecimal256(1,0), toDecimal256(1,0)), 7)")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round({arithmetic_func}(toDecimal256(1,0), toDecimal256(1,0)), {rounding_precision})")
|
||||
|
||||
with Then("I check that the output matches the expected value"):
|
||||
output = node.query(f"SELECT * FROM {table_name}").output
|
||||
|
@ -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 round({func} to{int_type}(\'{max}\')), 7), round({func} to{int_type}(\'{min}\')), 7)
|
||||
SELECT round({func} to{int_type}(\'{max}\')), {rounding_precision}), round({func} to{int_type}(\'{min}\')), {rounding_precision})
|
||||
""")
|
||||
|
||||
@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 round(to{int_type}OrZero( toString({func} to{int_type}(\'{value}\')))), 7)")
|
||||
node.query(f"INSERT INTO {table_name} SELECT round(to{int_type}OrZero( toString({func} to{int_type}(\'{value}\')))), {rounding_precision})")
|
||||
|
||||
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 round({func} toDecimal256(\'{max}\',0)),7), round({func} toDecimal256(\'{min}\',0)),7)
|
||||
SELECT round({func} toDecimal256(\'{max}\',0)),{rounding_precision}), round({func} toDecimal256(\'{min}\',0)),{rounding_precision})
|
||||
""")
|
||||
|
||||
@TestOutline(Scenario)
|
||||
|
Loading…
Reference in New Issue
Block a user