Commit Graph

3570 Commits

Author SHA1 Message Date
3894de49d2 [Enhancement](topn) support two phase read for topn query (#15642)
This PR optimize topn query like `SELECT * FROM tableX ORDER BY columnA ASC/DESC LIMIT N`.

TopN is is compose of SortNode and ScanNode, when user table is wide like 100+ columns the order by clause is just a few columns.But ScanNode need to scan all data from storage engine even if the limit is very small.This may lead to lots of read amplification.So In this PR I devide TopN query into two phase:
1. The first phase we just need to read `columnA`'s data from storage engine along with an extra RowId column called `__DORIS_ROWID_COL__`.The other columns are pruned from ScanNode.
2. The second phase I put it in the ExchangeNode beacuase it's the central node for topn nodes in the cluster.The ExchangeNode will spawn a RPC to other nodes using the RowIds(sorted and limited from SortNode) read from the first phase and read row by row from storage engine.

After the second phase read, Block will contain all the data needed for the query
2023-01-19 10:01:33 +08:00
c7a72436e6 [Feature](multi-catalog)Add support for JuiceFS (#15969)
The broker implements the interface to juicefs,It supports loading data from juicefs to doris through broker.
At the same time, it also implements the multi catalog to read the hive data stored in juicefs
2023-01-19 08:54:16 +08:00
wxy
7288f1f1d4 [Fix](profile) do not send export profile when enable_profile=false. (#15996) 2023-01-19 08:06:39 +08:00
c43edbdfea [bug](cooldown)fix bug for single cooldown (#16040)
* fix bug for single cooldown

* fix bug for single cooldown
2023-01-19 08:03:32 +08:00
76622bcab4 [enhance](FE): remove constructor just used for UT and useless ERROR code (#16080)
* [enhance](FE): remove constructor just used for UT.

* [enhance](FE): remove useless ERROR Code

* fix checkstyle
2023-01-19 08:00:48 +08:00
d8f598eeab [enhancement](Nereids) add timestampadd, timestampdiff functions (#16072) 2023-01-19 01:05:25 +08:00
2acf634f84 [CleanUp](FE): cleanup useless code in FE. (#16058) 2023-01-18 22:25:41 +08:00
78ba446487 [Enhancement](Nereids) add more clear message when parse failed (#16056) 2023-01-18 22:19:46 +08:00
cbcd5228b7 [enhance](nereids): polish code for mergeGroup(). (#16057) 2023-01-18 21:03:46 +08:00
feeb69438b [opt](Nereids) optimize DistributeSpec generator of OlapScan (#15965)
use the size of selected partitions instead of olap table partition size to decide whether generate hashDistributeSpec
2023-01-18 20:18:11 +08:00
34075368ec (improvement)[bucket] Add auto bucket implement (#15250) 2023-01-18 19:50:18 +08:00
0916cbcb10 [ehancement](nereids) Made the parse for named expression more complete (#16010)
After this PR, we could support such grammar.

SELECT SUBSTRING("dddd编", 0, 3) AS "测试";
SELECT SUBSTRING("dddd编", 0, 3) "测试";
2023-01-18 19:44:51 +08:00
4035bd83c3 [fix](jdbc) fix jdbc driver bug and external datasource p2 test case issue (#16033)
Fix bug that when create jdbc resource with only jdbc driver file name, it will failed to do checksum
This is because we forgot the pass the full driver url to JdbcClient.

Add ResultSet.FETCH_FORWARD and set AutoCommit to false to jdbc connection, so to avoid OOM when fetching large amount of data

set useCursorFetch in jdbc url for both MySQL and PostgreSQL.

Fix some p2 external datasource bug
2023-01-18 17:48:06 +08:00
5265f5142f [fix](Nereids) add string and character type (#16044) 2023-01-18 17:27:45 +08:00
1fa2b662cf [opt](Nereids) add date_add/sub function (#16048)
1. add week_add week_diff function
2. register all date_add/date_diff function
2023-01-18 17:11:44 +08:00
bd0d650c3d [fix](Nereids) prohibit cross join with on clause (#16035) 2023-01-18 16:21:01 +08:00
d257059e6b [refactor](remove hadoop dpp) remove hadoop dpp code since it is not used (#16009) 2023-01-18 15:01:04 +08:00
de0e402e52 [fix](nereids) bucket shuffle join use wrong shuffled column info (#16011) 2023-01-18 14:44:36 +08:00
46ce97a190 [enhance](planner)convert 'or' into 'in-predicate' (#15737)
in previous [PR 12872](https://github.com/apache/doris/pull/12872), we convert multi equals on same slot into `in predicate`. for example, `a =1 or a = 2` => `a in (1, 2)`

This pr makes 4 changes about convert or to in:
1. fix a bug: `Not IN`  is merged with equal. `a =1 or a not in (2, 3)` => `a in (1, 2, 3)`
2. extends this rule on more cases
  - merge for more than one slot: 'a =1 or a = 2 or b = 3 or b = 4' => `a in (1, 2) or b in (3, 4)`
  - merge skip not-equal and not-in: 'a =1 or a = 2 or b !=3 or c not in (1, 2)' => 'a in (1, 2) or b!=3 or c not in (1,2)`
3. rewrite recursively. 
4. OrToIn is implemented in ExtractCommonFactorsRule. This rule will generate new exprs. OrToIn should apply on such generated exprs. for example `(a=1 and b=2) or (a=3 and b=4)` => `(a=1 or a=3) and (b=2 or b=4) and [(a=1 and b=2) or (a=3 and b=4)]` => `a in (1,3) and b in (2 ,4) and [(a=1 and b=2) or (a=3 and b=4)]` 

In addition, this pr add toString() for some Expr.
2023-01-18 12:33:20 +08:00
c0ea9b0b81 [fix](Nereids) running_difference return type is not right (#16028) 2023-01-18 11:35:02 +08:00
121f4d6ac0 [fix](Nereids) cannot put two same table value function into one memo (#16026) 2023-01-18 11:32:09 +08:00
18f71180ce [fix](Nereids) avoid same group expression add to one group when do merge (#15999) 2023-01-18 11:22:18 +08:00
40fa5b4019 [fix](MTMV) Show MTMV statement on table raises exceptions (#15882) 2023-01-18 10:25:33 +08:00
96b9115286 [fix](nereids) fix bug of invalid column in olap scan node when a materialized view is selected (#15976)
if a materialized view is selected, the olap scan node's NonUserVisibleOutput property may contains column from other materialized view. This pr remove invalid column
2023-01-18 01:02:12 +08:00
388d623506 [fix](MTMV) Refine the process of refreshing data (#16006)
1. Remove some redundant code.
2. Fix the issue with the state of MTMV task.
3. Fix the case - test_create_mtmv.

## Problem summary

1. We used a retry policy to re-run the failed MTMV tasks, but we set the state to `FAILURE` during re-running the tasks.
We should do this after all the retry runs fail.
2. There are some redundant code can be removed.
3. In the case test_create_mtmv, we created many background tasks to refresh the data. Some task may fail due to the concurrency and cause the test fail. Actually, we only need single one task to verify the functionality.
2023-01-17 23:08:12 +08:00
0c8255d9b8 [fix](nereids)nest loop join should support filter conjuncts like hash join (#15979) 2023-01-17 20:38:38 +08:00
3d05ffb10e [fix](Nereids) add 'integer' as alias of int type (#15983) 2023-01-17 20:33:26 +08:00
e2d145cf5d [fix](fe)fix anti join bug (#15955)
* [fix](fe)fix anti join bug

* fix fe ut
2023-01-17 20:25:00 +08:00
wxy
061b28b32e [Fix](profile) fix /rest/v1/query_profile action. (#15981)
Co-authored-by: wangxiangyu@360shuke.com <wangxiangyu@360shuke.com>
2023-01-17 20:21:48 +08:00
02a7995171 [fix](planner)wrong result when has order by under join (#15974) 2023-01-17 20:20:56 +08:00
38663526b7 [fix](planner) Keep type of null literal expr when register conjuncts (#15878)
For now, type information of child expr which is NullLiteral would get lost in the CastExpr#getResultValue, this will produce a NullLiteral with Null  type which cause BE core when doing cast
2023-01-17 16:48:02 +08:00
7e4bc1fee6 [fix](Nereids) add a rule to adjust nullable of all expressions (#15791)
we have some rules that change output's nullable in rewrite step. So we need a rule to adjust nullable at the end of rewrite step.

TODO
- remove the output slot map
- add nullable compare into slot reference
- use exprid to compare two slot if do not need to compare nullable
- merge all rules into one to adjust all type plans
2023-01-17 15:51:25 +08:00
82e2102e18 [fix](MTMV) Exceptions occur when dropping meterialized view with if exists (#15568) 2023-01-17 15:29:39 +08:00
d062ca2944 [refactor](vectorized) remove unnecessary vectorization check (#15984) 2023-01-17 12:21:46 +08:00
b469efdb17 [fix](Nereids) all slot in grouping sets in repeat node should be nullable (#15991)
according to be's code, all slot in grouping set should be nullable.
reference to be code (be3482e6d6/be/src/vec/exec/vrepeat_node.cpp (L113))
2023-01-17 11:47:55 +08:00
d98abb12f9 [fix](Nereids)set oepration type coercion is diff with legacy planner (#15982) 2023-01-17 11:41:41 +08:00
ce1d19b373 [fix](Nereids) lateral view cannot bind function nested in generators (#15960) 2023-01-17 11:37:56 +08:00
8d25b156aa [fix](nereids) bind slot using exactly match (#15950)
example:
unbound slot k
bounded [k, t.k]

In previous binding algorithm, there are 2 candidate bindings,
in which bounded k is exactly matched unbound slot k, it has higher priority than that of t1.k
2023-01-17 11:25:08 +08:00
b6d9e73c59 [feature](merge-on-write) enable by default (#15920) 2023-01-17 11:15:42 +08:00
1ea11aa120 [Bug](datev2) Fix wrong cast expr (#15985)
Found by regression tests when I turn on enable_date_conversion
2023-01-17 10:18:20 +08:00
4b49d05e97 [refactor](fe) remove type related class to fe-common to reduce java-udf jar size (#15808) 2023-01-17 00:01:15 +08:00
525f990d2b [feture-wip](multi-catalog) upgrade iceberg pom version to 1.1.0, for rest catalog api (#15964)
Co-authored-by: jinzhe <jinzhe@selectdb.com>
2023-01-16 23:10:41 +08:00
899f5f5cf5 [feature](multi-catalog) support hive metastore more events (#15702)
support hive metastore more events
2023-01-16 14:16:12 +08:00
fa03c8a241 [feature](nereids) const folding for in-predicate with null literal (#15880)
select 1 in (2 , null)  => null
select 1 in (1 , null)  => true
select 1 not in (2 , null)  => null
select 1 not in (1 , null)  => false
2023-01-16 13:48:45 +08:00
wxy
067b33bca7 [Enhancement](profile) use queryId of originStatement as the queryId. (#15898)
* [Enhancement](profile) use queryId of originStatement as the queryId.

Co-authored-by: wangxiangyu@360shuke.com <wangxiangyu@360shuke.com>
2023-01-15 18:26:14 +08:00
58c520dbfd [Feature](remote) Cooldown cold data to object storage only one replica (#15832) 2023-01-14 23:58:00 +08:00
0a57f12578 [Bug](datev2) Fix bugs for datev2 (#15860)
These bugs are found when I run regression test with enable_date_conversion on
2023-01-14 18:36:36 +08:00
313e14d220 [Bugfix] (ROLLUP) fix the coredump when add rollup by link schema change (#15654)
Because of the rollup has the same keys and the keys's order is same, BE will do linked schema change. The base tablet's segments will link to the new rollup tablet. But the unique id from the base tablet is starting from 0 and as the rollup tablet also. In this case, the unique id 4 in the base table is column 'city', but in the rollup tablet is 'cost'. It will decode the varcode page to bigint page so that be coredump. It needs to be rejected.

I think that if a rollup add by link schema change, it means this rollup is redundant. It brings no additional revenue and wastes storage space. So It needs to be rejected.
2023-01-14 10:20:07 +08:00
2810029d24 [fix](multi-catalog) fix bug that replay init catalog may happen after catalog is dropped (#15919) 2023-01-14 09:41:37 +08:00
cedbed67be [feature-wip](MTMV) Support table aliases when creating a materialized view with multiple tables (#15849)
## Use Case

mysql> CREATE TABLE t_user (
    ->   event_day DATE,
    ->   id bigint,
    ->   username varchar(20)
    -> )
    -> DISTRIBUTED BY HASH(id) BUCKETS 10
    -> PROPERTIES ('replication_num' = '1');
Query OK, 0 rows affected (0.07 sec)

mysql> CREATE TABLE t_user_pv(
    ->   event_day DATE,
    ->   id bigint,
    ->   pv bigint
    -> )
    -> DISTRIBUTED BY HASH(id) BUCKETS 10
    -> PROPERTIES ('replication_num' = '1');
Query OK, 0 rows affected (0.09 sec)

mysql> CREATE MATERIALIZED VIEW mv
    -> BUILD IMMEDIATE REFRESH COMPLETE
    -> START WITH "2022-10-27 19:35:00"
    -> NEXT 1 SECOND
    -> KEY (username)
    -> DISTRIBUTED BY HASH(username) BUCKETS 10
    -> PROPERTIES ('replication_num' = '1')
    -> AS SELECT t1.username ,t2.pv FROM t_user t1 LEFT JOIN t_user_pv t2 on t1.id = t2.id;
Query OK, 0 rows affected (0.10 sec)

mysql> DESC mv;
+----------+-------------+------+-------+---------+-------+
| Field    | Type        | Null | Key   | Default | Extra |
+----------+-------------+------+-------+---------+-------+
| username | VARCHAR(20) | Yes  | true  | NULL    |       |
| pv       | BIGINT      | Yes  | false | NULL    | NONE  |
+----------+-------------+------+-------+---------+-------+
2 rows in set (0.02 sec)
2023-01-14 01:29:32 +08:00