fix conversion function to literal

This commit is contained in:
Anton Popov 2022-01-24 15:26:54 +03:00
parent 3567e18f6e
commit 6cbcfd706f
3 changed files with 5 additions and 1 deletions

View File

@ -32,7 +32,7 @@ void ASTFunction::appendColumnNameImpl(WriteBuffer & ostr) const
if (name == "view")
throw Exception("Table function view cannot be used as an expression", ErrorCodes::UNEXPECTED_EXPRESSION);
/// If function can be converted to literal it will be parsed as literal after formating.
/// If function can be converted to literal it will be parsed as literal after formatting.
/// In distributed query it may lead to mismathed column names.
/// To avoid it we check whether we can convert function to literal.
if (auto literal = toLiteral())
@ -135,6 +135,8 @@ static ASTPtr createLiteral(const ASTs & arguments)
{
if (auto func_literal = func->toLiteral())
container.push_back(func_literal->as<ASTLiteral>()->value);
else
return {};
}
else
/// Some of the Array or Tuple arguments is not literal

View File

@ -8,3 +8,4 @@
(0,1)
[[0,1],[2,3]]
[[0,1],[0,0]]
[[[0]],[[1],[2,3]]]

View File

@ -8,3 +8,4 @@ SELECT any(array(number, 1)) AS k FROM remote('127.0.0.{1,2}', numbers(10));
SELECT any(tuple(number, 1)) AS k FROM remote('127.0.0.{1,2}', numbers(10));
SELECT any(array(array(0, 1), [2, 3])) AS k FROM remote('127.0.0.{1,2}', numbers(10));
SELECT any(array(array(0, 1), [number, number])) AS k FROM remote('127.0.0.{1,2}', numbers(10));
SELECT any([[[number]],[[number + 1], [number + 2, number + 3]]]) AS k FROM remote('127.0.0.{1,2}', numbers(10));