mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
fix query parameter visitor
This commit is contained in:
parent
2401bc9143
commit
ae9aaa006d
@ -25,14 +25,18 @@ namespace ErrorCodes
|
||||
|
||||
|
||||
void ReplaceQueryParameterVisitor::visit(ASTPtr & ast)
|
||||
{
|
||||
if (ast->as<ASTQueryParameter>())
|
||||
visitQueryParameter(ast);
|
||||
else
|
||||
visitChildren(ast);
|
||||
}
|
||||
|
||||
|
||||
void ReplaceQueryParameterVisitor::visitChildren(ASTPtr & ast)
|
||||
{
|
||||
for (auto & child : ast->children)
|
||||
{
|
||||
if (child->as<ASTQueryParameter>())
|
||||
visitQueryParameter(child);
|
||||
else
|
||||
visit(child);
|
||||
}
|
||||
visit(child);
|
||||
}
|
||||
|
||||
const String & ReplaceQueryParameterVisitor::getParamValue(const String & name)
|
||||
|
@ -22,6 +22,7 @@ private:
|
||||
const NameToNameMap & query_parameters;
|
||||
const String & getParamValue(const String & name);
|
||||
void visitQueryParameter(ASTPtr & ast);
|
||||
void visitChildren(ASTPtr & ast);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -3,3 +3,4 @@
|
||||
2 testparam [0.3]
|
||||
3 paramparam []
|
||||
4 evaluateparam [0.2]
|
||||
5 param [0.2,0.3]
|
||||
|
@ -15,6 +15,9 @@ $CLICKHOUSE_CLIENT --input_format_values_deduce_templates_of_expressions=1 --inp
|
||||
$CLICKHOUSE_CLIENT --input_format_values_deduce_templates_of_expressions=0 --input_format_values_interpret_expressions=1 --param_p_n="-1" --param_p_s="param" --param_p_a="[0.2,0.3]" --query="INSERT INTO insert_values_parametrized VALUES \
|
||||
(5 + {p_n:Int8}, lower(concat('Evaluate', {p_s:String})), arrayIntersect([0, 0.2, 0.6], {p_a:Array(Nullable(Float32))}))"
|
||||
|
||||
$CLICKHOUSE_CLIENT --param_p_n="5" --param_p_s="param" --param_p_a="[0.2,0.3]" --query="INSERT INTO insert_values_parametrized VALUES \
|
||||
({p_n:Int8}, {p_s:String}, {p_a:Array(Nullable(Float32))})"
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT * FROM insert_values_parametrized ORDER BY n";
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE insert_values_parametrized";
|
||||
|
Loading…
Reference in New Issue
Block a user