Commit Graph

1 Commits

Author SHA1 Message Date
Azat Khuzhin
a5a8ecfe42 Fix inconsistent formatting for tupleElement (for fuzzer)
fuzzer sometimes [1] may inserts tupleElement() created from ASTLiteral:

    Function_tupleElement, 0xx
    -ExpressionList_, 0xx
    --Literal_Int64_255, 0xx
    --Literal_Int64_100, 0xx

And in this case it will be printed as "255.100", which
later will be parsed as float, and formatting will be
inconsistent.

So instead of printing it as regular tuple,
let's print it as ExpressionList instead (i.e. with ", " delimiter).

Simple reproducer:

    void ast()
    {
        auto arg1 = std::make_shared<ASTLiteral>(Field(255));
        auto arg2 = std::make_shared<ASTLiteral>(Field(100));

        auto func = makeASTFunction("tupleElement", arg1, arg2);

        auto ast = func;
        std::cerr << ast->formatForErrorMessage() << std::endl;
        std::cerr << ast->dumpTree() << std::endl;
    }

  [1]: https://clickhouse-test-reports.s3.yandex.net/23517/f1187aeb69109c88f0be978b8083080c7a843820/fuzzer_debug/report.html#fail1
2021-04-25 00:30:17 +03:00