mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #11916 from ClickHouse/query-parameters-keep-alias
Keep aliases for substitutions in query.
This commit is contained in:
commit
2ce2588770
@ -49,6 +49,7 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
|
||||
const auto & ast_param = ast->as<ASTQueryParameter &>();
|
||||
const String & value = getParamValue(ast_param.name);
|
||||
const String & type_name = ast_param.type;
|
||||
String alias = ast_param.alias;
|
||||
|
||||
const auto data_type = DataTypeFactory::instance().get(type_name);
|
||||
auto temp_column_ptr = data_type->createColumn();
|
||||
@ -63,6 +64,7 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
|
||||
+ value.substr(0, read_buffer.count()), ErrorCodes::BAD_QUERY_PARAMETER);
|
||||
|
||||
ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(temp_column[0]), type_name);
|
||||
ast->setAlias(alias);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
a
|
||||
Nullable(Nothing)
|
||||
\N
|
6
tests/queries/0_stateless/01342_query_parameters_alias.sh
Executable file
6
tests/queries/0_stateless/01342_query_parameters_alias.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT --param_x '\N' --query 'SELECT {x:Nullable(Nothing)} as a' --format TSVWithNamesAndTypes
|
Loading…
Reference in New Issue
Block a user