mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fixed tests
This commit is contained in:
parent
d39be3ac9c
commit
47ece846bc
@ -4519,14 +4519,6 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve function arguments
|
||||
|
||||
bool allow_table_expressions = is_special_function_in || is_special_function_exists;
|
||||
auto arguments_projection_names = resolveExpressionNodeList(function_node_ptr->getArgumentsNode(),
|
||||
scope,
|
||||
true /*allow_lambda_expression*/,
|
||||
allow_table_expressions /*allow_table_expression*/);
|
||||
|
||||
if (is_special_function_exists)
|
||||
{
|
||||
/// Rewrite EXISTS (subquery) into 1 IN (SELECT 1 FROM (subquery) LIMIT 1).
|
||||
@ -4535,20 +4527,26 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
|
||||
auto constant_data_type = std::make_shared<DataTypeUInt64>();
|
||||
|
||||
auto in_subquery = std::make_shared<QueryNode>(Context::createCopy(scope.context));
|
||||
in_subquery->setIsSubquery(true);
|
||||
in_subquery->getProjection().getNodes().push_back(std::make_shared<ConstantNode>(1UL, constant_data_type));
|
||||
in_subquery->getJoinTree() = exists_subquery_argument;
|
||||
in_subquery->getLimit() = std::make_shared<ConstantNode>(1UL, constant_data_type);
|
||||
in_subquery->resolveProjectionColumns({NameAndTypePair("1", constant_data_type)});
|
||||
in_subquery->setIsSubquery(true);
|
||||
|
||||
function_node_ptr = std::make_shared<FunctionNode>("in");
|
||||
function_node_ptr->getArguments().getNodes() = {std::make_shared<ConstantNode>(1UL, constant_data_type), in_subquery};
|
||||
node = function_node_ptr;
|
||||
function_name = "in";
|
||||
|
||||
is_special_function_in = true;
|
||||
}
|
||||
|
||||
/// Resolve function arguments
|
||||
|
||||
bool allow_table_expressions = is_special_function_in;
|
||||
auto arguments_projection_names = resolveExpressionNodeList(function_node_ptr->getArgumentsNode(),
|
||||
scope,
|
||||
true /*allow_lambda_expression*/,
|
||||
allow_table_expressions /*allow_table_expression*/);
|
||||
|
||||
auto & function_node = *function_node_ptr;
|
||||
|
||||
/// Replace right IN function argument if it is table or table function with subquery that read ordinary columns
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <TableFunctions/ITableFunction.h>
|
||||
#include <Analyzer/FunctionNode.h>
|
||||
#include <Analyzer/TableFunctionNode.h>
|
||||
#include <Interpreters/evaluateConstantExpression.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Access/ContextAccess.h>
|
||||
@ -36,6 +38,23 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<size_t> TableFunctionMerge::skipAnalysisForArguments(const QueryTreeNodePtr & query_node_table_function, ContextPtr) const
|
||||
{
|
||||
auto & table_function_node = query_node_table_function->as<TableFunctionNode &>();
|
||||
auto & table_function_arguments_nodes = table_function_node.getArguments().getNodes();
|
||||
size_t table_function_arguments_size = table_function_arguments_nodes.size();
|
||||
|
||||
std::vector<size_t> result;
|
||||
|
||||
for (size_t i = 0; i < table_function_arguments_size; ++i)
|
||||
{
|
||||
auto * function_node = table_function_arguments_nodes[i]->as<FunctionNode>();
|
||||
if (function_node && function_node->getFunctionName() == "REGEXP")
|
||||
result.push_back(i);
|
||||
}
|
||||
|
||||
return {0};
|
||||
}
|
||||
|
||||
void TableFunctionMerge::parseArguments(const ASTPtr & ast_function, ContextPtr context)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ private:
|
||||
using DBToTableSetMap = std::map<String, TableSet>;
|
||||
const DBToTableSetMap & getSourceDatabasesAndTables(ContextPtr context) const;
|
||||
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
|
||||
std::vector<size_t> skipAnalysisForArguments(const QueryTreeNodePtr & query_node_table_function, ContextPtr context) const override;
|
||||
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
||||
static TableSet getMatchedTablesWithAccess(const String & database_name, const String & table_regexp, const ContextPtr & context);
|
||||
|
||||
|
@ -17,17 +17,17 @@ DROP TABLE IF EXISTS t1_00203;
|
||||
DROP TABLE IF EXISTS t2_00203;
|
||||
|
||||
CREATE TABLE t1_00203 (k1 UInt32, k2 UInt32, k3 UInt32, val_t1 String) ENGINE=TinyLog;
|
||||
CREATE TABLE t2_00203 (val_t2 String, k3 UInt32, k2_alias UInt32, k1 UInt32) ENGINE=TinyLog;
|
||||
CREATE TABLE t2_00203 (val_t2 String, k3 UInt32, k2 UInt32, k1 UInt32) ENGINE=TinyLog;
|
||||
|
||||
INSERT INTO t1_00203 VALUES (1, 2, 3, 'aaa'), (2, 3, 4, 'bbb');
|
||||
INSERT INTO t2_00203 VALUES ('ccc', 4, 3, 2), ('ddd', 7, 6, 5);
|
||||
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY FULL JOIN t2_00203 USING (k3, k1, k2 AS k2_alias) ORDER BY k1, k2, k3;
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY RIGHT JOIN t2_00203 USING (k3, k1, k2 AS k2_alias) ORDER BY k1, k2, k3;
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY FULL JOIN t2_00203 USING (k3, k1, k2) ORDER BY k1, k2, k3;
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY RIGHT JOIN t2_00203 USING (k3, k1, k2) ORDER BY k1, k2, k3;
|
||||
|
||||
SET any_join_distinct_right_table_keys = 0;
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY FULL JOIN t2_00203 USING (k3, k1, k2 AS k2_alias) ORDER BY k1, k2, k3; -- { serverError 48 }
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY RIGHT JOIN t2_00203 USING (k3, k1, k2 AS k2_alias) ORDER BY k1, k2, k3;
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY FULL JOIN t2_00203 USING (k3, k1, k2) ORDER BY k1, k2, k3; -- { serverError 48 }
|
||||
SELECT k1, k2, k3, val_t1, val_t2 FROM t1_00203 ANY RIGHT JOIN t2_00203 USING (k3, k1, k2) ORDER BY k1, k2, k3;
|
||||
|
||||
DROP TABLE t1_00203;
|
||||
DROP TABLE t2_00203;
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS test_00744;
|
||||
CREATE TEMPORARY TABLE test_00744
|
||||
(
|
||||
@ -11,27 +13,33 @@ FROM
|
||||
(
|
||||
SELECT
|
||||
x,
|
||||
1
|
||||
FROM test_00744
|
||||
`1`
|
||||
FROM
|
||||
(
|
||||
SELECT x, 1 FROM test_00744
|
||||
)
|
||||
ALL INNER JOIN
|
||||
(
|
||||
SELECT
|
||||
count(),
|
||||
1
|
||||
FROM test_00744
|
||||
) jss2 USING (1)
|
||||
) jss2 USING (`1`)
|
||||
LIMIT 10
|
||||
);
|
||||
|
||||
SELECT
|
||||
x,
|
||||
1
|
||||
FROM test_00744
|
||||
`1`
|
||||
FROM
|
||||
(
|
||||
SELECT x, 1 FROM test_00744
|
||||
)
|
||||
ALL INNER JOIN
|
||||
(
|
||||
SELECT
|
||||
count(),
|
||||
1
|
||||
FROM test_00744
|
||||
) js2 USING (1)
|
||||
) js2 USING (`1`)
|
||||
LIMIT 10;
|
||||
|
@ -1,11 +1,13 @@
|
||||
-- Tags: zookeeper
|
||||
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
create table rmt1 (d DateTime, n int) engine=ReplicatedMergeTree('/test/01165/{database}/rmt', '1') order by n partition by toYYYYMMDD(d);
|
||||
create table rmt2 (d DateTime, n int) engine=ReplicatedMergeTree('/test/01165/{database}/rmt', '2') order by n partition by toYYYYMMDD(d);
|
||||
|
||||
system stop replicated sends rmt1;
|
||||
insert into rmt1 values (now(), arrayJoin([1, 2])); -- { clientError 36 }
|
||||
insert into rmt1(n) select * from system.numbers limit arrayJoin([1, 2]); -- { serverError 36 }
|
||||
insert into rmt1(n) select * from system.numbers limit arrayJoin([1, 2]); -- { serverError 440 }
|
||||
insert into rmt1 values (now(), rand());
|
||||
drop table rmt1;
|
||||
|
||||
|
@ -1,29 +1,29 @@
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x WHERE a in (SELECT a FROM y)
|
||||
ORDER BY a;
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x left JOIN y USING a
|
||||
ORDER BY a;
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5))
|
||||
SELECT * FROM x JOIN y USING a
|
||||
ORDER BY x.a;
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT toUInt64(1) b)
|
||||
SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z);
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
@ -31,19 +31,17 @@ w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT * FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
ORDER BY x.a;
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT max(a) FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
HAVING a > (SELECT min(a) FROM w);
|
||||
SELECT max(a) FROM x JOIN y USING a WHERE a in (SELECT * FROM z) AND a > (SELECT min(a) FROM w);
|
||||
|
||||
WITH
|
||||
WITH
|
||||
x AS (SELECT number AS a FROM numbers(10)),
|
||||
y AS (SELECT number AS a FROM numbers(5)),
|
||||
z AS (SELECT * FROM x WHERE a % 2),
|
||||
w AS (SELECT * FROM y WHERE a > 0)
|
||||
SELECT a FROM x JOIN y USING a WHERE a in (SELECT * FROM z)
|
||||
HAVING a <= (SELECT max(a) FROM w)
|
||||
SELECT a FROM x JOIN y USING a WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w)
|
||||
ORDER BY x.a;
|
||||
|
@ -47,7 +47,6 @@ SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)'
|
||||
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 RIGHT JOIN t_ab2 USING (a, b);
|
||||
SELECT any(toTypeName(a)) == 'Int32' AND any(toTypeName(b)) == 'Nullable(Int64)' FROM t_ab1 INNER JOIN t_ab2 USING (a, b);
|
||||
|
||||
SELECT * FROM ( SELECT a, b as "_CAST(a, Int32)" FROM t_ab1 ) t_ab1 FULL JOIN t_ab2 ON (t_ab1.a == t_ab2.a); -- { serverError 44 }
|
||||
SELECT * FROM ( SELECT a, b as "_CAST(a, Int32)" FROM t_ab1 ) t_ab1 FULL JOIN t_ab2 USING (a) FORMAT Null;
|
||||
|
||||
{% endfor %}
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t2_nullable;
|
||||
@ -31,7 +33,6 @@ SELECT t1.key, t1.key2 FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key ==
|
||||
SELECT '--';
|
||||
SELECT t1.key FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2;
|
||||
SELECT t1.key FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 AND 0; -- { serverError INVALID_JOIN_ON_EXPRESSION }
|
||||
SELECT t1.key FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 AND 1; -- { serverError INVALID_JOIN_ON_EXPRESSION }
|
||||
|
||||
SELECT '--';
|
||||
SELECT '333' = t1.key FROM t1 INNER ANY JOIN t2 ON t1.id == t2.id AND t2.key == t2.key2 AND t1.key == t1.key2 AND t2.id > 2;
|
||||
@ -71,8 +72,8 @@ SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id; -- { serverError
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id + 2; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id + 2; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.key; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.key; -- { serverError 43 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key; -- { serverError 43 }
|
||||
SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 AND (t1.id == t2.id OR isNull(t2.key2)); -- { serverError 403 }
|
||||
SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 OR t1.id == t2.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 JOIN t2 ON (t2.key == t2.key2 AND (t1.key == t1.key2 AND t1.key != 'XXX' OR t1.id == t2.id)) AND t1.id == t2.id; -- { serverError 403 }
|
||||
|
@ -1,3 +1,5 @@
|
||||
SET allow_experimental_analyzer = 1;
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
DROP TABLE IF EXISTS t2_nullable;
|
||||
@ -68,8 +70,8 @@ SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id; -- { serverError
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.id + 2; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.id + 2; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.key; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key; -- { serverError 403 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t1.key; -- { serverError 43 }
|
||||
SELECT * FROM t1 INNER ALL JOIN t2 ON t1.id == t2.id AND t2.key; -- { serverError 43 }
|
||||
SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 AND (t1.id == t2.id OR isNull(t2.key2)); -- { serverError 403 }
|
||||
SELECT * FROM t1 JOIN t2 ON t2.key == t2.key2 OR t1.id == t2.id; -- { serverError 403 }
|
||||
SELECT * FROM t1 JOIN t2 ON (t2.key == t2.key2 AND (t1.key == t1.key2 AND t1.key != 'XXX' OR t1.id == t2.id)) AND t1.id == t2.id; -- { serverError 403 }
|
||||
|
@ -38,7 +38,7 @@ SELECT n, source, inter FROM (
|
||||
# Test INTERPOLATE with inconsistent column - should produce error
|
||||
SELECT n, source, inter FROM (
|
||||
SELECT toFloat32(number % 10) AS n, 'original' AS source, number as inter FROM numbers(10) WHERE number % 3 = 1
|
||||
) ORDER BY n WITH FILL FROM 0 TO 11.51 STEP 0.5 INTERPOLATE (inter AS source); -- { serverError 6 }
|
||||
) ORDER BY n WITH FILL FROM 0 TO 11.51 STEP 0.5 INTERPOLATE (inter AS source); -- { serverError 32 }
|
||||
|
||||
# Test INTERPOLATE with aliased column
|
||||
SELECT n, source, inter + 1 AS inter_p FROM (
|
||||
|
Loading…
Reference in New Issue
Block a user