Commit Graph

5755 Commits

Author SHA1 Message Date
6d4f06689f [fix](Nereids) avoid Stats NaN (#23445)
tpcds 61 plan changed:
improved from 1.75 sec to 1.67 sec
2023-08-25 16:27:34 +08:00
0ccb7262a7 [feature](Nereids) add password func (#23244)
add password function
```
select password("123");
+-------------------------------------------+
| password('123')                           |
+-------------------------------------------+
| *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
+-------------------------------------------+
```
2023-08-25 14:04:49 +08:00
ba931d9eed [fix](Nereids) infer predicates generate wrong result (#23456)
We use two facilities to do predicate infer: PredicatePropagation and
PullUpPredicates. In the prvious implementation, we use a set to save
the intermediate result of PredicatePropagation. The purpose is infer
new predicate though two equal relation. However, it is the wrong way.
Because it could infer wrong predicate through outer join. For example

```sql
select a.c1
   from a
   left join b on a.c2 = b.c2 and a.c1 = '1'
   left join c on a.c2 = c.c2 and a.c1 = '2'
   inner join d on a.c3=d.c3
```

the predicates `a.c1 = '1'` and `a.c1 = '2'` should not be inferred as
filter to relation `a`.

This PR:
1. revert the change from PR #22145, commit 3c58e9ba
2. Remove the unreasonable restrict in PullupPredicate.
3. Use new Filter node rather than new otherCondition on join node to
   save infer predicates
2023-08-25 11:59:28 +08:00
8ef6b4d996 [fix](json) fix json int128 overflow (#22917)
* support int128 in jsonb

* fix jsonb int128 write

* fix jsonb to json int128

* fix json functions for int128

* add nereids function jsonb_extract_largeint

* add testcase for json int128

* change docs for json int128

* add nereids function jsonb_extract_largeint

* clang format

* fix check style

* using int128_t = __int128_t for all int128

* use fmt::format_to instead of snprintf digit by digit for int128

* clang format

* delete useless check

* add warn log

* clang format
2023-08-25 11:40:30 +08:00
372f83df5c [opt](Nereids) remove between expression to simplify planner (#23421) 2023-08-25 11:28:12 +08:00
37b90021b7 [fix](planner)literal expr should do nothing in substituteImpl() method (#23438)
substitute a literal expr is pointless and wrong. This pr keep literal expr unchanged during substitute process
2023-08-25 11:21:35 +08:00
18094511e7 [fix](Outfile/Nereids) fix that csv_with_names and csv_with_names_and_types file format could not be exported on nereids (#23387)
This problem is casued by #21197

Fixed an issue that `csv_with_names` and `csv_with_names_and_types` file format could not be exported on nereids optimizer when using `select...into outfile`.
2023-08-25 11:12:04 +08:00
6614c219cb [opt](Nereids) use NUMERIC_PRECEDENCE in int div (#23403) 2023-08-25 11:03:50 +08:00
69e75f04ab [fix](feut) should not enable InternalSchemaDb in fe ut (#23400) 2023-08-25 11:03:37 +08:00
3786ffec51 [opt](Nereids) add some array functions (#23324)
1. rename TVFProperties to Properties
2. add generating function explode and explode_outer
3. fix concat_ws could not apply on array
4. check tokenize second argument format on FE
5. add test case for concat_ws, tokenize, explode, explode_outer and split_by_string
2023-08-25 11:01:50 +08:00
d30bb8042e [fuzzy](hash join) disable fuzzy enable_hash_join_early_start_probe (#23413) 2023-08-25 10:11:20 +08:00
7cfb3cc0aa [fix](functions) fix function substitute for datetimeV1/V2 (#23344)
* fix

* function fe
2023-08-25 09:59:38 +08:00
441a9fff6d [fix](planner) fix now function param type error (#23446) 2023-08-25 00:12:21 +08:00
6a4976921d [fix](auth)Disable column auth temporarily (#23295)
- add config `enable_col_auth` to temporarily disable column permissions(because old/new planner has bug when select from view)
- Restore the old optimizer to the previous authentication method
- Support for new optimizer authentication(Legacy issue: When querying the view, the permissions of the base table will be authenticated. The view's own permissions should be authenticated and processed after the new optimizer is improved)
- fix: show grants for non-existent users
- fix: role:`admin` can not grant/revoke to/from user
2023-08-24 23:37:06 +08:00
966561a6ed [improvement and fix](statistics)Load the cache for external table row count while init table (#23170)
1. Load the cache for external table row count while init table, this could avoid no row number stats for the very first time to run an sql.
2. Show cardinality for an external scan node when explain the sql.
3. fix bugs introduced by https://github.com/apache/doris/pull/22963
2023-08-24 23:34:16 +08:00
f6c5c8f7b5 [Fix](Nereids) fix that select...from tablets() are invalidated when there exists predicates (#23365)
Problem: `select...from tablets()` are invalidated when there exists predicates, such as:
```sql
// The all data is:
mysql> select * from student3;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | ftw  |   18 |
|    3 | yy   |   19 |
|    4 | xx   |   21 |
|    2 | cyx  |   20 |
+------+------+------+

// when we specified tablet to read:
mysql> select * from student3 tablet(131131);
+------+------+------+
| id   | name | age  |
+------+------+------+
|    1 | ftw  |   18 |
|    3 | yy   |   19 |
+------+------+------+

// Howerver, when there exists predicates, the `tablet(131131)` is invalidated
mysql> select * from student3 tablet(131131) where id > 1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    4 | xx   |   21 |
|    3 | yy   |   19 |
|    2 | cyx  |   20 |
+------+------+------+
```

After the fix, we get promising data
```sql
mysql> select * from student3 tablet(131131) where id > 1;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    3 | yy   |   19 |
+------+------+------+
```
2023-08-24 23:29:59 +08:00
320eda78e6 [fix](nereids) remove useless cast in in-predicate (#23171)
consider sql "select * from test_simplify_in_predicate_t where a in ('1992-01-31', '1992-02-01', '1992-02-02', '1992-02-03', '1992-02-04');"
before:

```
|   0:VOlapScanNode                                                                                                                                                                                      |
|      TABLE: default_cluster:bugfix.test_simplify_in_predicate_t(test_simplify_in_predicate_t), PREAGGREGATION: OFF. Reason: No aggregate on scan.                                                      |
|      PREDICATES: CAST(a[#0] AS DATETIMEV2(0)) IN ('1992-01-31 00:00:00', '1992-02-01 00:00:00', '1992-02-02 00:00:00', '1992-02-03 00:00:00', '1992-02-04 00:00:00') AND __DORIS_DELETE_SIGN__[#1] = 0 |
|      partitions=0/1, tablets=0/0, tabletList=                                                                                                                                                          |
|      cardinality=1, avgRowSize=0.0, numNodes=1                                                                                                                                                         |
|      pushAggOp=NONE                                                                                                                                                                                    |
|      projections: a[#0]                                                                                                                                                                                |
|      project output tuple id: 1                                                                                                                                                                        |
|      tuple ids: 0  
```
after:

```
|   0:VOlapScanNode                                                                                                                                 |
|      TABLE: default_cluster:bugfix.test_simplify_in_predicate_t(test_simplify_in_predicate_t), PREAGGREGATION: OFF. Reason: No aggregate on scan. |
|      PREDICATES: a[#0] IN ('1992-01-31', '1992-02-01', '1992-02-02', '1992-02-03', '1992-02-04') AND __DORIS_DELETE_SIGN__[#1] = 0                |
|      partitions=0/1, tablets=0/0, tabletList=                                                                                                     |
|      cardinality=1, avgRowSize=0.0, numNodes=1                                                                                                    |
|      pushAggOp=NONE                                                                                                                               |
|      projections: a[#0]                                                                                                                           |
|      project output tuple id: 1                                                                                                                   |
|      tuple ids: 0  

```
2023-08-24 18:14:43 +08:00
6c5072ffc5 [FIX](array-func) fix array index func with decimal (#23399)
fix array index func with decimal
in old analyzer when sql with array_position or array_contains with decimal , may loss precision to which will make result wrong
2023-08-24 17:58:20 +08:00
044423f902 [fix](Nereids) use Stopwatch to do timeout checker (#23383)
1. avoid thread leak if exception thrown in planning
2. avoid memory release delays since the timer task hold CascadesContext
   object
2023-08-24 09:49:35 +08:00
f0bc2c2eff [fix](tablet clone) fix partition rebalance apply move exception (#23222) 2023-08-23 21:50:50 +08:00
156f7b7699 [improvement](transaction) make commit txn fail hint more understandable (#23227) 2023-08-23 21:50:24 +08:00
448b7755c6 [feature](jdbc catalog) support doris jdbc catalog array type (#23056) 2023-08-23 21:17:16 +08:00
daa4db097e [fix](Nereids) array_difference and array_position get wrong result (#23331)
1. change array_difference signature to let it return same type as arg
2. do not change precision when signature not use wildcard type
2023-08-23 20:38:09 +08:00
dad1587799 [opt](stats) don't load stats when task is killed (#23354)
Sync cache after analyze task is killed is meaningless and make error message confused
2023-08-23 20:24:08 +08:00
1b7d692d72 [fix](planner & nereids) convert to double if div decimal overflow (#23272) 2023-08-23 20:10:53 +08:00
f0c16ab20d [fix](Nereids): visitLogicalWindow don't override (#23376)
- visitLogicalWindow don't override
- head index is wrong
2023-08-23 18:50:15 +08:00
711913ee07 [refactor](Nereids): remove penalty in CostModel (#23375) 2023-08-23 18:44:42 +08:00
51ac92f65c Revert "[fix](function) to_bitmap parameter parsing failure returns null instead of bitmap_empty (#21236)" (#23368)
This reverts commit 1c3cc77a54938ed948ad8186b8dea8385977d23c.
2023-08-23 18:27:35 +08:00
4c751202e3 [fix](Es Catalog) Pushdown predicate of Es catalog query in nereids (#23345) 2023-08-23 18:03:39 +08:00
8140fc737e [Fix](inverted index) fix bug when match condition in hash join (#23105)
* [Fix](inverted index) fix bug when match condition in hash join
2023-08-23 17:48:31 +08:00
c3327b51b9 [Fix](Nereids) add nereids load function in read fields of GlobalFunctionMgr and Database (#23248)
add nereids load function in read fields of GlobalFunctionMgr and Database
to fix some udf is lost when restart FE and query with Nereids.
2023-08-23 15:59:50 +08:00
c7b9eb5f9c [enhancement](bitmap)support bitmap type for non-key column in unique table (#23228) 2023-08-23 14:21:22 +08:00
527293aa41 [refactor](dynamic table) remove dynamic table (#23298) 2023-08-23 14:15:14 +08:00
d8a31405c4 [refactor](Nereids): remove Penalty (#23321) 2023-08-23 13:31:01 +08:00
ab9b29f11f [fix](multi-catalog)fix broker and tvf params (#23252)
fix fs specifics, broker and tvf params, and NPE
2023-08-23 10:33:24 +08:00
35d0c9e71e [refactor](nereids) Refactor stats collection framework (#22963)
* remove auto analyze grammer
* refactor ResultRow
2023-08-23 10:05:57 +08:00
78c6b115c3 [fix](planner)avg function need support large int param (#23254)
* [fix](planner)avg function need support large int param
2023-08-23 10:05:08 +08:00
2ad46c5826 [fix](show) show load warning support load v2 (#22759) 2023-08-22 20:08:19 +08:00
a4e041ea55 [improve](alter-job) Add a config for forbiding doing alter job (#23294) 2023-08-22 16:28:36 +08:00
820d328ad7 [feature](Nereids) support handle query in fe (#23263)
1. fix select variable with alias parsed as two level alias expression.
2. support handle query in fe
2023-08-22 15:28:29 +08:00
a7675243d9 [fix](jdbc catalog) fix adaptation to Oracle special character / table names (#23080)
The changes of this PR for JdbcOracleClient are as follows:

#### bug fixes:
  1. Fix the problem that if there is an approximate table name for Schema synchronization with a table name with `/` characters, the synchronization Column will be confused
  2. Fix the NPE problem of metadata synchronization after enabling lower_case_table_names configuration

#### improvement:
  1. Modify the method of synchronizing Oracle User to Doris Database mapping, use `metadata.getSchemas` instead of `SELECT DISTINCT OWNER FROM all_tables`
  2. When synchronizing metadata, change `null` at the catalog level to `conn.getcatalog`
2023-08-22 15:25:42 +08:00
6c8af92175 [fix])(nereids)Support select catalog.db.table.column from xxx for nereids planner. #23221
Nereids doesn't support select table.* from table, this pr is to fix this bug.
Support three layer qualifier. (catalog.database.table)
2023-08-22 13:58:25 +08:00
51db11ed0b [improve](jdbc catalog) Add a variable to accommodate the final keyword in ClickHouse Jdbc Catalog queries (#23282) 2023-08-22 12:13:36 +08:00
5d9678700c [feature](Nereids) support select tablets with nereids optimizer (#23164) 2023-08-22 10:14:27 +08:00
8f48acaab1 [refactor](nereids) convert session var name "beNumForTest" #23255
this var is used for test only. So keep "for_test" as suffix.
2023-08-22 10:12:07 +08:00
b670dd0db7 [feature](Nereids) support array type (#22851)
FEATURE:
1. enable array type in Nereids
2. support generice on function signature
3. support array and map type in type coercion and type check
4. add element_at and element_slice syntax in Nereids parser

REFACTOR:
1. remove AbstractDataType

BUG FIX:
1. remove FROM from nonReserved keyword list

TODO:
1. support lambda expression
2. use Nereids' way do function type coercion
3. use castIfnotSame when do implict cast on BoundFunction
4. let AnyDataType type coercion do same thing as function type coercion
5. add below array function
- array_apply
- array_concat
- array_filter
- array_sortby
- array_exists
- array_first_index
- array_last_index
- array_count
- array_shuffle shuffle
- array_pushfront
- array_pushback
- array_repeat
- array_zip
- reverse
- concat_ws
- split_by_string
- explode
- bitmap_from_array
- bitmap_to_array
- multi_search_all_positions
- multi_match_any
- tokenize
2023-08-22 09:47:55 +08:00
4e63aa052c [fix](session-var) fix forward parallel fragment instance num, and forward some session by the way (#23234) 2023-08-22 09:00:29 +08:00
ae48de70d6 [improve](jdbc catalog) Improve the speed of writing to postgresql databases (#23279)
reWriteBatchedInserts (boolean) Default false
This will change batch inserts from insert into foo (col1, col2, col3) values (1, 2, 3) into insert into foo (col1, col2, col3) values (1, 2, 3), (4, 5, 6) this provides 2-3x performance improvement

from https://jdbc.postgresql.org/documentation/use/#reWriteBatchedInserts

delete useless parameters useCursorFetch
2023-08-21 23:46:27 +08:00
ea5fd53f22 [enhancement](Nereids): optimize deepEquals (#22944) 2023-08-21 23:03:06 +08:00
4c8f269f19 [fix](Nereids): fix LogicalProject equals() (#23241)
* [fix](Nereids): fix LogicalProject equals()

* [refactor](Nereids): SubqueryExpr is LeafExpression

* remove toArray()
2023-08-21 23:01:22 +08:00