Commit Graph

267 Commits

Author SHA1 Message Date
Joanna Hulboj
501cc390f6 Prevent duplicates in column name hints. Improve formatting. 2022-12-22 16:58:30 +00:00
Kseniia Sumarokova
7bb1f64df4
Merge pull request #43987 from kssenii/positional-args-fix
Fix order by positional arg in case unneeded columns pruning
2022-12-08 13:15:37 +01:00
Kruglov Pavel
0598ca92a3
Merge pull request #43873 from canhld94/ch_canh_fix_normalize
Fix some incorrect logic in ast level optimization
2022-12-08 12:38:36 +01:00
vdimir
4b50e5c15e
fix 2022-12-07 16:27:01 +00:00
kssenii
3725cf4aa7 Better 2022-12-07 11:26:32 +01:00
kssenii
862da8f459 Fix 2022-12-06 17:07:28 +01:00
Duc Canh Le
3b9c590a12 Merge branch 'master' into ch_canh_fix_normalize 2022-12-02 17:59:21 +08:00
Duc Canh Le
518058b92e fix some bad logics in ast level optimization 2022-12-02 17:56:23 +08:00
Nikita Taranov
488610bd96
impl (#43709) 2022-11-29 18:22:24 +01:00
Antonio Andelic
c52ca6e10e Merge branch 'master' into substitute-udf-create 2022-11-23 16:08:37 +00:00
Antonio Andelic
981e8a3a27 Modifiy visitor 2022-11-23 13:32:36 +00:00
taofengliu
d0767cab1d GROUP BY ALL in Analyzer 2022-11-01 16:18:56 +08:00
taofengliu
82581b73ea fix 2022-10-28 21:52:27 +08:00
taofengliu
7d1fbdbfeb Merge remote-tracking branch 'upstream/master' into group_by_all 2022-10-28 21:48:56 +08:00
taofengliu
56ab264ec9 fix 2022-10-28 21:48:48 +08:00
Maksim Kita
40cb904a3d Added support for JOIN, ARRAY JOIN 2022-10-24 10:22:19 +02:00
taofengliu
a7c1c69830 fix bug 2022-10-21 15:07:42 +08:00
taofengliu
abfa257e04 alias 2022-10-20 20:37:52 +08:00
taofengliu
4d5bf0e3b2 avoid extracting the deepest columns 2022-10-20 18:17:40 +08:00
taofengliu
7c13110ab3 style 2022-10-19 12:15:43 +08:00
Alexey Milovidov
4440df6461
Update TreeRewriter.cpp 2022-10-19 03:00:09 +03:00
taofengliu
46739eeaf8 support GROUP BY ALL 2022-10-18 10:46:37 +08:00
Vitaly Baranov
91c438eebe
Merge pull request #42263 from vitlibar/refactor-udf
Refactor the implementation of user-defined functions
2022-10-15 12:33:10 +02:00
Vitaly Baranov
2e59d671fc Split UserDefinedSQLObjectsLoader to interface and implementation. 2022-10-13 10:32:32 +02:00
Alexey Milovidov
0e3b9bf3ff Add more checkStackSize calls 2022-10-01 17:48:56 +02:00
Alexey Milovidov
9c5f9f1815
Merge pull request #41158 from den-crane/bug/trivial_count_optimization_with_array_join
Fix: trivial count optimization with array join. revert revert #39466
2022-09-12 08:56:10 +03:00
kssenii
2f3bfc5411 Fix 2022-09-11 13:54:25 +02:00
Denny Crane
be90cecbd2 Revert "Revert "Fix trivial count optimization with array join""
This reverts commit 17de7b2876.
2022-09-09 14:56:38 -03:00
luocongkai
56e4179cad fix bug when remove unneeded columns in subquery 2022-09-01 17:10:32 +08:00
Raúl Marín
32c63f43a1 Don't visit the AST for UDFs if none are registered 2022-08-10 17:54:56 +02:00
Nikolai Kochetov
658a269d56
Merge branch 'master' into use-dag-in-key-condition 2022-08-04 16:18:40 +02:00
Kruglov Pavel
6457c069a9
Merge pull request #39293 from kssenii/fix-positional-args-case
Fix positional arguments in case of unneeded columns pruning
2022-08-01 12:42:18 +02:00
Nikolai Kochetov
22fbfe19a4 Merge branch 'master' into use-dag-in-key-condition 2022-07-31 21:54:12 +02:00
kssenii
d66c108a04 Fix 2022-07-30 18:42:22 +03:00
kssenii
efff78819a Merge remote-tracking branch 'upstream/master' into fix-positional-args-case 2022-07-29 22:07:51 +03:00
Maksim Kita
8fc6bad4f4 Join enums refactoring 2022-07-29 18:35:05 +02:00
Nikolai Kochetov
59a11b32ad
Merge branch 'master' into use-dag-in-key-condition 2022-07-29 17:01:33 +02:00
Nikolai Kochetov
6919ae7c91 Fixing a test with indexHint 2022-07-28 12:24:16 +00:00
vdimir
96bcae419c
Cleanup logic around join_algorithm setting 2022-07-21 14:53:39 +00:00
kssenii
e6437f46b1 Fix 2022-07-16 22:23:49 +02:00
Vladimir C
db838f1343
Merge pull request #35796 from vdimir/full-sorting-merge-join 2022-07-07 19:16:49 +02:00
vdimir
4e88e8f5ec
full sort join: move block list to all join state 2022-07-06 14:26:17 +00:00
vdimir
fa8eb35599
Pipeline for full sorting merge join 2022-07-06 14:23:44 +00:00
Igor Nikonov
5a01c27eb1 Fix: clear children in order by element during rewriting
- remove unnecessary code for this PR
2022-07-05 22:48:48 +00:00
Igor Nikonov
fd62494a77 Fix: ORDER BY with braces inefficient execution 2022-07-05 22:48:48 +00:00
Azat Khuzhin
d98336ad83 Fix incorrect columns order in subqueries of UNION
Consider the following query:

    SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y)

Here is UNION from two SELECT queries
- `SELECT NULL, 255 AS x, 1 AS y`
- `SELECT y, NULL AS x, 1 AS y`

UNION queries matches columns by positions, not names, so the following
columns should be used by `avgWeighted()`:
- `255 AS x,  1 AS y`
- `NULL AS x, 1 AS y`

Result types of arguments should be:
- `x Nullable(UInt8)`
- `y UInt8`

And in case of UNION query is a subselect itself, it will return only
required columns, for the example above it needs only `x` and `y`.
For this it will get positions of these arguments from the first query,
and then use those positions to get required column names from the
second query (since there is no ability to get columns by positions
instead of names internally), and due to duplicated columns the second
query will return (`y`, `x`) not (`x`, `y`), and this will make the
result incorrect:

    EXPLAIN header = 1, optimize = 0, actions=1 SELECT avgWeighted(x, y) FROM (SELECT NULL, 255 AS x, 1 AS y UNION ALL SELECT y, NULL AS x, 1 AS y)

    Aggregates:
        avgWeighted(x, y)
          Function: avgWeighted(Nullable(UInt8), UInt8) → Nullable(Float64)
          Arguments: x, y
          Argument positions: 0, 1
      Expression (Before GROUP BY)
      Header: x UInt8
              y Nullable(UInt8)
      ...
      Union
      Header: x UInt8
              y Nullable(UInt8)
        Expression (Conversion before UNION)
        Header: x UInt8
                y Nullable(UInt8)
        Expression (Conversion before UNION)
        Header: x UInt8
                y Nullable(UInt8)

And the query itself fails with an error:

    Logical error: 'Bad cast from type DB::ColumnVector<char8_t> to DB::ColumnNullable'.

_NOTE: `avgWeighted()` here is required to trigger `LOGICAL_ERROR`_

CI: https://s3.amazonaws.com/clickhouse-test-reports/37796/e637489f81768df582fe7389e57f7ed12893087c/fuzzer_astfuzzerdebug,actions//report.html
Fixes: 02227_union_match_by_name
v2: fix untuple() (reserve space for output_columns_positions too)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-06-28 22:53:03 +03:00
Azat Khuzhin
ee0f2651ee Revert "Fix converting types for UNION queries (may produce LOGICAL_ERROR)"
This fix is incorrect, and it introduce new issues, in particular it
may breaks UNION queries w/o column aliases, i.e.:

    SELECT a, b, c FROM (SELECT 3 AS a, 2147483647 AS b, 1048575 AS c UNION ALL SELECT -2, NULL, -2) AS js1 ORDER BY a

CI: https://s3.amazonaws.com/clickhouse-test-reports/37796/e637489f81768df582fe7389e57f7ed12893087c/fuzzer_astfuzzerdebug,actions//report.html
Reverts: #37593/#34775 (2613149f6b)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-06-28 22:50:01 +03:00
Anton Kozlov
5f81bcd84f
CLICKHOUSE-1331 Rewrite tuple functions as literals in backwards-compatibility mode (#38096)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-27 14:13:21 +02:00
mergify[bot]
670a63865e
Merge branch 'master' into window-function-expression 2022-06-19 22:14:54 +00:00
Dmitry Novik
376412e417 Small refactoring 2022-06-16 15:41:04 +00:00