mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge pull request #67260 from ClickHouse/remove-strange-code
Remove strange code
This commit is contained in:
commit
d4055fc21b
@ -13,10 +13,6 @@
|
|||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
namespace ErrorCodes
|
|
||||||
{
|
|
||||||
extern const int LOGICAL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -237,16 +233,8 @@ void SubstituteColumnOptimizer::perform()
|
|||||||
|
|
||||||
const auto & compare_graph = metadata_snapshot->getConstraints().getGraph();
|
const auto & compare_graph = metadata_snapshot->getConstraints().getGraph();
|
||||||
|
|
||||||
// Fill aliases
|
if (compare_graph.getNumOfComponents() == 0)
|
||||||
if (select_query->select())
|
return;
|
||||||
{
|
|
||||||
auto * list = select_query->refSelect()->as<ASTExpressionList>();
|
|
||||||
if (!list)
|
|
||||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "List of selected columns must be ASTExpressionList");
|
|
||||||
|
|
||||||
for (ASTPtr & ast : list->children)
|
|
||||||
ast->setAlias(ast->getAliasOrColumnName());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto run_for_all = [&](const auto func)
|
auto run_for_all = [&](const auto func)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
/** Set the alias. */
|
/** Set the alias. */
|
||||||
virtual void setAlias(const String & /*to*/)
|
virtual void setAlias(const String & /*to*/)
|
||||||
{
|
{
|
||||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Can't set alias of {}", getColumnName());
|
throw Exception(ErrorCodes::LOGICAL_ERROR, "Can't set alias of {} of {}", getColumnName(), getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the text that identifies this element. */
|
/** Get the text that identifies this element. */
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
1
|
1
|
||||||
1
|
1
|
||||||
0
|
0
|
||||||
SELECT count() AS `count()`
|
SELECT count()
|
||||||
FROM constraint_test_constants
|
FROM constraint_test_constants
|
||||||
WHERE (b > 100) OR (c > 100)
|
WHERE (b > 100) OR (c > 100)
|
||||||
SELECT count() AS `count()`
|
SELECT count()
|
||||||
FROM constraint_test_constants
|
FROM constraint_test_constants
|
||||||
WHERE c > 100
|
WHERE c > 100
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -53,7 +53,7 @@ QUERY id: 0
|
|||||||
COLUMN id: 6, column_name: c, result_type: Int64, source_id: 3
|
COLUMN id: 6, column_name: c, result_type: Int64, source_id: 3
|
||||||
CONSTANT id: 7, constant_value: UInt64_100, constant_value_type: UInt8
|
CONSTANT id: 7, constant_value: UInt64_100, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT count() AS `count()`
|
SELECT count()
|
||||||
FROM constraint_test_constants
|
FROM constraint_test_constants
|
||||||
WHERE c > 100
|
WHERE c > 100
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -71,7 +71,7 @@ QUERY id: 0
|
|||||||
COLUMN id: 6, column_name: c, result_type: Int64, source_id: 3
|
COLUMN id: 6, column_name: c, result_type: Int64, source_id: 3
|
||||||
CONSTANT id: 7, constant_value: UInt64_100, constant_value_type: UInt8
|
CONSTANT id: 7, constant_value: UInt64_100, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT count() AS `count()`
|
SELECT count()
|
||||||
FROM constraint_test_constants
|
FROM constraint_test_constants
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
PROJECTION COLUMNS
|
PROJECTION COLUMNS
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
SELECT
|
SELECT
|
||||||
(b AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`,
|
(b AS `cityHash64(a)`) + 10,
|
||||||
(b AS b) + 3 AS `plus(b, 3)`
|
(b AS b) + 3
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE b = 1
|
WHERE b = 1
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -59,8 +59,8 @@ QUERY id: 0
|
|||||||
CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8
|
CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT
|
SELECT
|
||||||
(b AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`,
|
(b AS `cityHash64(a)`) + 10,
|
||||||
(b AS b) + 3 AS `plus(b, 3)`
|
(b AS b) + 3
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE b = 0
|
WHERE b = 0
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -89,8 +89,8 @@ QUERY id: 0
|
|||||||
CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8
|
CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT
|
SELECT
|
||||||
(b AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`,
|
(b AS `cityHash64(a)`) + 10,
|
||||||
(b AS b) + 3 AS `plus(b, 3)`
|
(b AS b) + 3
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE b = 0
|
WHERE b = 0
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -119,8 +119,8 @@ QUERY id: 0
|
|||||||
CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8
|
CONSTANT id: 14, constant_value: UInt64_0, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT
|
SELECT
|
||||||
(b AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`,
|
(b AS `cityHash64(a)`) + 10,
|
||||||
(b AS b) + 3 AS `plus(b, 3)`
|
(b AS b) + 3
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE b = 1
|
WHERE b = 1
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -148,7 +148,7 @@ QUERY id: 0
|
|||||||
COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5
|
COLUMN id: 13, column_name: b, result_type: UInt64, source_id: 5
|
||||||
CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8
|
CONSTANT id: 14, constant_value: UInt64_1, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT (b AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`
|
SELECT (b AS `cityHash64(a)`) + 10
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE b = 0
|
WHERE b = 0
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -171,8 +171,8 @@ QUERY id: 0
|
|||||||
CONSTANT id: 10, constant_value: UInt64_0, constant_value_type: UInt8
|
CONSTANT id: 10, constant_value: UInt64_0, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT
|
SELECT
|
||||||
(cityHash64(a) AS `cityHash64(a)`) + 10 AS `plus(cityHash64(a), 10)`,
|
(cityHash64(a) AS `cityHash64(a)`) + 10,
|
||||||
a AS a
|
a
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE cityHash64(a) = 0
|
WHERE cityHash64(a) = 0
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
@ -203,8 +203,8 @@ QUERY id: 0
|
|||||||
CONSTANT id: 15, constant_value: UInt64_0, constant_value_type: UInt8
|
CONSTANT id: 15, constant_value: UInt64_0, constant_value_type: UInt8
|
||||||
SETTINGS allow_experimental_analyzer=1
|
SETTINGS allow_experimental_analyzer=1
|
||||||
SELECT
|
SELECT
|
||||||
(cityHash64(a) AS b) + 10 AS `plus(b, 10)`,
|
(cityHash64(a) AS b) + 10,
|
||||||
a AS a
|
a
|
||||||
FROM column_swap_test_test
|
FROM column_swap_test_test
|
||||||
WHERE cityHash64(a) = 0
|
WHERE cityHash64(a) = 0
|
||||||
QUERY id: 0
|
QUERY id: 0
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
DROP TABLE IF EXISTS test_table;
|
||||||
|
CREATE TABLE test_table
|
||||||
|
(
|
||||||
|
id UInt64,
|
||||||
|
value String
|
||||||
|
) ENGINE=TinyLog;
|
||||||
|
|
||||||
|
EXPLAIN SYNTAX
|
||||||
|
WITH 1 AS compound_value SELECT * APPLY (x -> compound_value.*)
|
||||||
|
FROM test_table WHERE x > 0
|
||||||
|
SETTINGS convert_query_to_cnf = true, optimize_using_constraints = true, optimize_substitute_columns = true; -- { serverError UNKNOWN_IDENTIFIER }
|
||||||
|
|
||||||
|
DROP TABLE test_table;
|
Loading…
Reference in New Issue
Block a user