ClickHouse/tests/queries/0_stateless/02227_union_match_by_name.reference
Azat Khuzhin a813f5996e Fix converting types for UNION queries (may produce LOGICAL_ERROR)
CI founds [1]:

    2022.02.20 15:14:23.969247 [ 492 ] {} <Fatal> BaseDaemon: (version 22.3.1.1, build id: 6082C357CFA6FF99) (from thread 472) (query_id: a5187ff9-962a-4e7c-86f6-8d48850a47d6) (query: SELECT 0., round(avgWeighted(x, y)) FROM (SELECT toDate(toDate('214748364.8', '-922337203.6854775808', '-0.1', NULL) - NULL, 10.000100135803223, '-2147483647'), 255 AS x, -2147483647 AS y UNION ALL SELECT y, NULL AS x, 2147483646 AS y)) Received signal Aborted (6)

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/0/26d0e5438c86e52a145aaaf4cb523c399989a878/fuzzer_astfuzzerdebug,actions//report.html

The problem is that subqueries returns different headers:
- first query  -- x, y
- second query -- y, x

v2: Make order of columns strict only for UNION
    https://s3.amazonaws.com/clickhouse-test-reports/34775/9cc8c01a463d18c471853568b2f0af659a4e643f/stateless_tests__address__actions__[2/2].html
    Fixes: 00597_push_down_predicate_long
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-05-25 20:31:47 +03:00

45 lines
1.7 KiB
Plaintext

-- { echo }
EXPLAIN header = 1, optimize = 0 SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y);
Expression (Projection)
Header: avgWeighted(x, y) Nullable(Float64)
Expression (Before ORDER BY)
Header: avgWeighted(x, y) Nullable(Float64)
Aggregating
Header: avgWeighted(x, y) Nullable(Float64)
Expression (Before GROUP BY)
Header: x Nullable(UInt8)
y UInt8
Union
Header: x Nullable(UInt8)
y UInt8
Expression (Conversion before UNION)
Header: x Nullable(UInt8)
y UInt8
Expression (Projection)
Header: x UInt8
y UInt8
Expression (Before ORDER BY)
Header: 255 UInt8
1 UInt8
dummy UInt8
SettingQuotaAndLimits (Set limits and quota after reading from storage)
Header: dummy UInt8
ReadFromStorage (SystemOne)
Header: dummy UInt8
Expression (Conversion before UNION)
Header: x Nullable(UInt8)
y UInt8
Expression (Projection)
Header: x Nullable(Nothing)
y UInt8
Expression (Before ORDER BY)
Header: NULL Nullable(Nothing)
1 UInt8
dummy UInt8
SettingQuotaAndLimits (Set limits and quota after reading from storage)
Header: dummy UInt8
ReadFromStorage (SystemOne)
Header: dummy UInt8
SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y);
255