mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Merge pull request #20303 from azat/constant-folding-fixes
Do not allow early constant folding of explicitly forbidden functions
This commit is contained in:
commit
371e84957a
@ -29,6 +29,7 @@ public:
|
||||
}
|
||||
|
||||
bool useDefaultImplementationForNulls() const override { return false; }
|
||||
bool isSuitableForConstantFolding() const override { return false; }
|
||||
|
||||
/// We should never return LowCardinality result, cause we declare that result is always constant zero.
|
||||
/// (in getResultIfAlwaysReturnsConstantAndHasArguments)
|
||||
|
@ -89,8 +89,7 @@ bool allowEarlyConstantFolding(const ActionsDAG & actions, const Settings & sett
|
||||
{
|
||||
if (node.type == ActionsDAG::ActionType::FUNCTION && node.function_base)
|
||||
{
|
||||
auto name = node.function_base->getName();
|
||||
if (name == "ignore")
|
||||
if (!node.function_base->isSuitableForConstantFolding())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,9 @@ def test_mutation_simple(started_cluster, replicated):
|
||||
result_part = "all_{}_{}_0_{}".format(starting_block, starting_block, starting_block + 1)
|
||||
|
||||
def alter():
|
||||
node1.query("ALTER TABLE {name} UPDATE a = 42 WHERE sleep(2) OR 1".format(name=name))
|
||||
node1.query("ALTER TABLE {name} UPDATE a = 42 WHERE sleep(2) OR 1".format(name=name), settings={
|
||||
'mutations_sync': 1,
|
||||
})
|
||||
|
||||
t = threading.Thread(target=alter)
|
||||
t.start()
|
||||
@ -159,8 +161,6 @@ def test_mutation_simple(started_cluster, replicated):
|
||||
]
|
||||
t.join()
|
||||
|
||||
time.sleep(1.5)
|
||||
|
||||
assert node_check.query("SELECT * FROM system.merges WHERE table = '{name}'".format(name=table_name)) == ""
|
||||
|
||||
finally:
|
||||
|
@ -115,6 +115,7 @@ FROM
|
||||
SELECT
|
||||
1 AS id,
|
||||
identity(cast(1, \'UInt8\')) AS subquery
|
||||
WHERE subquery = 1
|
||||
)
|
||||
WHERE subquery = 1
|
||||
1 1
|
||||
|
@ -2,7 +2,7 @@ SELECT 1
|
||||
WHERE 0
|
||||
SELECT 1
|
||||
SELECT 1
|
||||
WHERE 0
|
||||
WHERE (1 IN (0, 2)) AND (2 = (identity(cast(2, \'UInt8\')) AS subquery))
|
||||
SELECT 1
|
||||
WHERE 1 IN (
|
||||
(
|
||||
|
@ -4,7 +4,7 @@ EXPLAIN SYNTAX SELECT 1 WHERE 1 = 0;
|
||||
|
||||
EXPLAIN SYNTAX SELECT 1 WHERE 1 IN (0, 1, 2);
|
||||
|
||||
EXPLAIN SYNTAX SELECT 1 WHERE 1 IN (0, 2) AND 2 = (SELECT 2);
|
||||
EXPLAIN SYNTAX SELECT 1 WHERE 1 IN (0, 2) AND 2 = ((SELECT 2) AS subquery);
|
||||
|
||||
-- no constant folding
|
||||
|
||||
|
@ -7,3 +7,5 @@ EXPLAIN SYNTAX SELECT (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUI
|
||||
SELECT
|
||||
identity(cast(0, \'UInt64\')) AS n,
|
||||
toUInt64(10 / n)
|
||||
SELECT * FROM (WITH (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n) as q SELECT * FROM system.one WHERE q > 0);
|
||||
0
|
||||
|
@ -2,3 +2,4 @@
|
||||
SELECT * FROM (SELECT (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n)) FORMAT CSV;
|
||||
SELECT (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n) FORMAT CSV;
|
||||
EXPLAIN SYNTAX SELECT (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n);
|
||||
SELECT * FROM (WITH (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n) as q SELECT * FROM system.one WHERE q > 0);
|
||||
|
Loading…
Reference in New Issue
Block a user