mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Forbid use_structure_from_insertion_table_in_table_functions when execute scalar
This commit is contained in:
parent
9e7e581813
commit
a900d08a5f
@ -77,6 +77,10 @@ static auto getQueryInterpreter(const ASTSubquery & subquery, ExecuteScalarSubqu
|
||||
subquery_settings.max_result_rows = 1;
|
||||
subquery_settings.extremes = false;
|
||||
subquery_context->setSettings(subquery_settings);
|
||||
|
||||
/// When execute `INSERT INTO t WITH ... SELECT ...`, it may lead to `Unknown columns`
|
||||
/// exception with this settings enabled(https://github.com/ClickHouse/ClickHouse/issues/52494).
|
||||
subquery_context->getQueryContext()->setSetting("use_structure_from_insertion_table_in_table_functions", false);
|
||||
if (!data.only_analyze && subquery_context->hasQueryContext())
|
||||
{
|
||||
/// Save current cached scalars in the context before analyzing the query
|
||||
|
@ -0,0 +1,3 @@
|
||||
user127 1
|
||||
user405 1
|
||||
user902 1
|
16
tests/queries/0_stateless/02843_insertion_table_schema_infer.sh
Executable file
16
tests/queries/0_stateless/02843_insertion_table_schema_infer.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-parallel, no-fasttest
|
||||
|
||||
set -e
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
DATA_DIR=$CUR_DIR/data_tsv
|
||||
|
||||
$CLICKHOUSE_LOCAL --multiquery \
|
||||
"CREATE VIEW users AS SELECT * FROM file('$DATA_DIR/mock_data.tsv', TSVWithNamesAndTypes);
|
||||
CREATE TABLE users_output (name String, tag UInt64)ENGINE = Memory;
|
||||
INSERT INTO users_output WITH (SELECT groupUniqArrayArray(mapKeys(Tags)) FROM users) AS unique_tags SELECT UserName AS name, length(unique_tags) AS tag FROM users;
|
||||
SELECT * FROM users_output;"
|
5
tests/queries/0_stateless/data_tsv/mock_data.tsv
Normal file
5
tests/queries/0_stateless/data_tsv/mock_data.tsv
Normal file
@ -0,0 +1,5 @@
|
||||
UserName Age Tags
|
||||
String Int8 Map(String, UInt64)
|
||||
user127 20 {'test': 123}
|
||||
user405 43 {'test': 123}
|
||||
user902 43 {'test': 123}
|
|
Loading…
Reference in New Issue
Block a user