ClickHouse/tests/queries/0_stateless/01840_tupleElement_formatting_fuzzer.reference
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

18 lines
506 B
Plaintext

SelectWithUnionQuery (children 1)
ExpressionList (children 1)
SelectQuery (children 1)
ExpressionList (children 1)
Function tupleElement (children 1)
ExpressionList (children 2)
Literal UInt64_255
Literal UInt64_100
SelectWithUnionQuery (children 1)
ExpressionList (children 1)
SelectQuery (children 1)
ExpressionList (children 1)
Function tupleElement (children 1)
ExpressionList (children 2)
Literal Tuple_(UInt64_255, UInt64_1)
Literal UInt64_1
255