Commit Graph

189 Commits

Author SHA1 Message Date
60253c827c [fix](nereids) do not push RF into nested cte (#33769) 2024-04-20 20:08:00 +08:00
a8ba933947 [Fix](nereids) fix bind order by expression logic (#33843) 2024-04-19 15:02:49 +08:00
e4eb76212a [fix](Nereids): add order for constraint test (#33323) 2024-04-11 09:31:50 +08:00
5e59c09a60 [Fix](nereids) modify the binding aggregate function in order by (#32758)
modify the bind logical to make the order by has same behavior with mysql when sort child is aggregate.
when an order by Expr has aggregate function, all slots in this order by Expr should bind the LogicalAggregate non-AggFunction outputs first, then bind the LogicalAggregate Child
e.g.
select 2*abs(sum(c1)) as c1, c1,sum(c1)+c1 from t_order_by_bind_priority group by c1 order by sum(c1)+c1 asc;
in this sql, the two c1 in order by all bind to the c1 in t_order_by_bind_priority
2024-04-10 15:26:09 +08:00
9bc7902e5a [fix](Nereids) fix bind group by int literal (#33117)
This sql will failed because

    2 in the group by will bind to 1 as col2 in BindExpression
    ResolveOrdinalInOrderByAndGroupBy will replace 1 to MIN (LENGTH (cast(age as varchar)))
    CheckAnalysis will throw an exception because group by can not contains aggregate function

select MIN (LENGTH (cast(age as varchar))), 1 AS col2
from test_bind_groupby_slots
group by 2

we should move ResolveOrdinalInOrderByAndGroupBy into BindExpression

(cherry picked from commit 3fab4496c3fefe95b4db01f300bf747080bfc3d8)
2024-04-10 14:59:46 +08:00
285e2fcb5a [fix] (vectorization) regexp all_pass string (#32515) 2024-04-10 11:34:30 +08:00
3d14d9e379 [fix](Nereids) fix bind having aggregate failed again (#32687)
follow up #32490

add more tests and fix some cases because some sqls are valid to mysql, but failed in doris
2024-03-24 08:06:13 +08:00
6812b575b2 [fix](Nereids) fix bind having aggregate failed (#32490)
fix bind having aggregate failed, keep the behavior like mysql
2024-03-22 16:36:46 +08:00
8e3d28b93a [Feature] Support Array Type compare function for nereids planner (#31701)
Support Array Type compare function for nereids planner
2024-03-21 14:07:49 +08:00
ccd21a6ea4 [Improve](InPredict) enhance in predict with array type (#31828) 2024-03-12 14:19:14 +08:00
561709451c [fix](Nereids) fix group_concat(distinct) failed (#31873) 2024-03-07 16:16:05 +08:00
3777ffb43f [enhancement](nereids)support null partition for list partition (#31613) 2024-03-06 13:05:22 +08:00
0fcdab468d [nereids] config global partition topn (#31476)
* [nereids] config global partition topn

* [nereids] config global partition topn

---------

Co-authored-by: zhongjian.xzj <zhongjian.xzj@zhongjianxzjdeMacBook-Pro.local>
2024-02-29 08:42:35 +08:00
ad07dec0ed [Improve](InPredict) enhance in predict with struct type (#30840) 2024-02-22 13:01:49 +08:00
8a0ea4b651 [enhancement](Nereids): datetime support microsecond overflow (#30744) 2024-02-03 20:26:04 +08:00
b86bd2672f [fix](Nereids) add logical project to prevent extra wrong column (#30459)
Issue Number: close #30264
2024-02-01 19:00:50 +08:00
f7e01ceffa [bug](node) add dependency for set operation node (#30203)
These sinks must be completed one by one in order, eg: child(1) must wait child(0) build finish
2024-01-30 15:30:39 +08:00
f17d29090e [feat](Nereids): drop foreign key after dropping primary key that is referenced by the foreign key (#30417) 2024-01-29 19:03:48 +08:00
ce47354d59 [fix](Nereids) result nullable of sum distinct in scalar agg is wrong (#30221) 2024-01-23 10:09:54 +08:00
07de535c4c [fix](Nereids) should not fold constant when do ordinal group by (#29976) 2024-01-16 18:46:19 +08:00
34fe5ee38b [feat](Nereids) support show constraint command (#29667)
show constraints from t1;
+------+-------------+-----------------------------------------+
| Name | Type        | Definition                              |
+------+-------------+-----------------------------------------+
| fk   | FOREIGN KEY | FOREIGN KEY (id) REFERENCES cir.t1 (id) |
| uk   | UNIQUE      | UNIQUE (id)                             |
| pk   | PRIMARY KEY | PRIMARY KEY (id)                        |
+------+-------------+-----------------------------------------+
2024-01-12 11:44:21 +08:00
abd9000368 [Feat](Nereids) add distribute hint to leading hint (#28562)
add distribute hint to leading hint, we can use leading like:
/*+ leading(t1 broadcase{t2 t3}) */ after this commit
2024-01-04 17:51:06 +08:00
d2dc12bed5 [fix](nereids)exists subquery should handle top level scarlar agg correctly (#29135) 2023-12-29 09:45:20 +08:00
e51e94fdec [fix](Nereids) join order is not right after sql parsing (#28721)
for sql
```
t1, t2 join t3
```

we should generate plan like:
```
t1 join (t2 join t3)
```

but we generate:
```
(t1 join t2) join t3
```
to follow legancy planner.
2023-12-21 20:31:40 +08:00
a540b7eb43 [fix](Nereids) multi_distinct_sum should inherit NullableAggregateFunction (#28349) 2023-12-14 19:27:06 +08:00
8ac52aeda7 [fix](nereids) wrong result when simplify int compare with decimal literal (#28195)
SimplifyComparisonPredicate rule create wrong result when simplify int compare with decimal literal
2023-12-13 16:13:42 +08:00
cd8885f63e [fix](Nereids): support Chinese characters set (#28256) 2023-12-12 13:22:14 +08:00
2f63999066 [fix](Nereids): Preserve "" in single quote strings and '' in double quote strings. (#27959) 2023-12-05 12:30:03 +08:00
f2cfc87aca [fix](nereids) temporary partition is selected only if user manually specified (#27893)
q1: "select * from ut_p temporary partitions(tp1) where val > 0"
in q1, temporary partition tp1 is scaned

q2: "select * from ut_p where val > 0"
in q2, temporary partition tp1 is not scaned.
2023-12-04 09:44:27 +08:00
2ea1e9db44 [fix](nereids) temp partition is always pruned (#27636) 2023-11-28 14:18:14 +08:00
0a9d71ebd2 [Fix](Planner) fix varchar does not show real length (#25171)
Problem:
when we create table with datatype varchar(), we regard it to be max length by default. But when we desc, it does not show
real length but show varchar()
Reason:
when we upgrade version from 2.0.1 to 2.0.2, we support new feature of creating varchar(), and it shows the same way with
ddl schema. So user would confuse of the length of varchar
Solved:
change the showing of varchar() to varchar(65533), which in compatible with hive
2023-11-14 10:49:21 +08:00
17b1108635 [fix](nereids)support uncorrelated subquery in join condition (#26672)
sql select * from t1 a join t1 b on b.id in (select 1) and a.id = b.id; will report an error.
This pr support uncorrelated subquery in join condition to fix it
2023-11-13 11:49:11 +08:00
ce64f0c917 [enhancement](Nereids): add phase in shape string (#26682) 2023-11-10 14:56:28 +08:00
f138aaa07a [fix](nereids) unnest in-subquery with agg node in proper condition (#25800)
consider sql having in-subquery

SELECT count(*)
        FROM sub_query_correlated_subquery6
        WHERE k1 IN 
            (SELECT k1
            FROM 
                (**SELECT k1,
                sum(k3) AS bbb,
                count(k2) AS aaa
                FROM sub_query_correlated_subquery7
                WHERE k1 > 0
                        AND k3 > 0
                GROUP BY  k1** ) y
                WHERE y.aaa>0
                        AND k1>1); 

The subquery part having agg is un-correlated, which can be unnested.

on the other side:
SELECT count(*)
                    FROM sub_query_correlated_subquery6
                    WHERE k1 IN 
                        (SELECT k1
                        FROM 
                            (**SELECT k1,
                            sum(k3) AS bbb,
                            count(k2) AS aaa
                            FROM sub_query_correlated_subquery7
                            WHERE k1 > 0
                                    AND k3 > 0 and sub_query_correlated_subquery6.k1 > 2
                            GROUP BY  k1** ) y
                            WHERE y.aaa>0
                                    AND k1>1);

The subquery part having agg is correlated, which can't be unnested.
2023-11-06 20:35:13 -06:00
a89477e8b5 [fix](Nereids) could not run query with repeat node in cte (#26330)
ExpressionDeepCopier not process VirtualReference, so we generate inline
plan with mistake.
2023-11-03 01:24:01 -05:00
3e10e5af39 [Fix](Serde) Fix content displayed by complex types in MySQL Client (#25946)
This pr makes three changes to the display of complex types:
1. NULL value in complex types refers to being displayed as `null`, not `NULL`
2. struct type is displayed as "column_name": column_value
3. Time types such as `datetime` and `date`, are displayed with double quotes in complex types. like
    `{1, "2023-10-26 12:12:12"}`

This pr also do a code refactor:
1. nesting_level is set to a member variable of the `DataTypeSerDe`, rather than a parameter in methods.

What's more, this pr fix a bug that fileSize is not correct, introduced by this pr: #25854
2023-11-01 23:48:55 +08:00
d7d284b4f8 [fix](Nereids) fix '' and "" in string literal (#25752)
'' represents ' in sql standard
"" represents " in sql standard
2023-10-26 11:18:21 +08:00
59dee6b235 [fix](Nereids) support string cast to complex type (#25154) 2023-10-10 10:26:33 +08:00
f5b826b66d [fix](mark join) mark join column should be nullable (#24910) 2023-10-10 10:10:36 +08:00
bb7f8d18a8 [fix](nereids) push down filter through partition topn (#24944)
support pushing down filter through partition topn if the filter can pass through window.
fix CreatePartitionTopNFromWindow bug which may generate two partition topn unexpectly.
case:
select * from (select c2, row_number() over (partition by c2) as rn from t1) T where rn<=1 and c2 = 1;
before this pr:
| PhysicalResultSink                       |
| --PhysicalDistribute                     |
| ----filter((rn <= 1))                    |
| ------PhysicalWindow                     |
| --------PhysicalQuickSort                |
| ----------PhysicalDistribute             |
| ------------PhysicalPartitionTopN        |
| --------------filter((T.c2 = 1))         |
| ----------------PhysicalPartitionTopN    |
| ------------------PhysicalProject        |
| --------------------PhysicalOlapScan[t1] |
+------------------------------------------+
after:

| PhysicalResultSink                     |
| --PhysicalDistribute                   |
| ----filter((rn <= 1))                  |
| ------PhysicalWindow                   |
| --------PhysicalQuickSort              |
| ----------PhysicalDistribute           |
| ------------PhysicalPartitionTopN      |
| --------------PhysicalProject          |
| ----------------filter((T.c2 = 1))     |
| ------------------PhysicalOlapScan[t1] |
+----------------------------------------+
2023-09-27 19:38:04 +08:00
90791f0b19 [fix](nereids)fix bug of exists subquery with limit clause (#24630)
create table t1(c1 int, c2 int);
create table t2(c1 int, c2 int);
insert into t1 values (1,1);
insert into t2 values (1,1);

select * from t1 where exists (select * from t2 where t1.c1 = t2.c1 limit 0);

the result should be empty set.
2023-09-25 17:15:08 +08:00
49f6eda843 [fix](nested_join) incorrect result of semi/anti mark join (#24616) 2023-09-20 10:41:06 +08:00
699023069d [regression](lateral view) add test case for explode_bitmap (#24421) 2023-09-15 17:30:26 +08:00
46f5988245 [fix](Nereids) set operation children output order not same (#24060)
we generate project for all set operation's children to ensure the order
of all children are not changed. However, some rules, such as
PushDownProjectThroughLimit could remove these projects involuntarily.
When it happen, the column order is wrong and lead to BE core dump.
This PR use a new variable in SetOperation to save the output order of
children of set operation. Then the children's output order could be
changed and never affect to SetOperation at all.
2023-09-14 11:09:58 +08:00
335064f897 [feature](Nereids) add lambda argument and array_map function (#23598)
add array_map function

SELECT ARRAY_MAP(x->x+1, ARRAY(87, 33, -49))
+----------------------------------------------------------------------+
| array_map([x] -> (x + 1), x#1 of array(87, 33, -49))     |
+----------------------------------------------------------------------+
| [88, 34, -48]                                                                 |
+----------------------------------------------------------------------+
2023-09-13 14:24:16 +08:00
93c1151f1a [fix](join) incorrect result of mark join (#24112) 2023-09-10 11:30:45 +08:00
8c2a721873 [opt](nereids)push down filter through window #23935
select rank() over (partition by A, B) as r, sum(x) over(A, C) as s from T;
A is a common partition key for all windowExpressions, that is A is intersection of {A,B} and {A, C}
we could push filter A=1 through this window, since A is a common Partition key:
select * from (select a, row_number() over (partition by a) from win) T where a=1;
origin plan:

----filter((T.a = 1))
----------PhysicalWindow
------------PhysicalQuickSort
--------------PhysicalProject
------------------PhysicalOlapScan[win]
transformed to

----PhysicalWindow
------PhysicalQuickSort
--------PhysicalProject
----------filter((T.a = 1))
------------PhysicalOlapScan[win]
But C=1 can not be pushed through window.
2023-09-09 20:53:31 +08:00
Pxl
69868f18d6 [Bug](join) fix nested loop join some problems (#24034) 2023-09-08 17:40:41 +08:00
db306a51b3 [fix](nereids) missing return value of resetLogicalProperties() (#23850)
physicalPlan.resetLogicalProperties(); will not change the origin plan but create a new plan with no logical property. So should update the plan using resetLogicalProperties()'s return value.
2023-09-04 17:37:26 +08:00
Pxl
bb3fadc5d3 [Bug](materialized-view) fix mv not match because cast and alias name (#23580)
fix mv not match because cast and alias name
2023-09-04 12:46:33 +08:00