Commit Graph

1565 Commits

Author SHA1 Message Date
2c208e932b [Bug][RoutineLoad] Avoid TOO_MANY_TASKS error (#6342)
Use `commitAsync` to commit offset to kafka, instead of using `commitSync`, which may block for a long time.
Also assign a group.id to routine load if user not specified "property.group.id" property, so that all consumer of
this job will use same group.id instead of a random id for each consume task.
2021-08-03 11:59:06 +08:00
748604ff4f [RoutineLoad] Support alter broker list and topic for kafka routine load (#6335)
```
alter routine load for cmy2 from kafka("kafka_broker_list" = "ip2:9094", "kafka_topic" = "my_topic");
```

This is useful when the kafka broker list or topic has been changed.

Also modify `show create routine load`, support showing  "kafka_partitions" and "kafka_offsets".
2021-08-03 11:58:38 +08:00
a2eb1b9d5b fix version (#6334) 2021-07-30 09:25:22 +08:00
9ca369aa58 [Feature][LDAP] Add LDAP authentication login and LDAP group authorization support. (#6333)
* [Feature][LDAP] Add LDAP authentication login and LDAP group authorization support.

* Update docs/.vuepress/sidebar/en.js

Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>

Co-authored-by: Mingyu Chen <morningman.cmy@gmail.com>
2021-07-30 09:24:50 +08:00
14db74fac6 [Bug] Fix show load like match (#6314)
* fix show load like match

* Compatible with historical issues
2021-07-30 09:24:06 +08:00
60ac4a9660 [Bug][SparkLoad] Fix bucket_hash_value for bool value (#6284)
Co-authored-by: weixiang <weixiang06@meituan.com>
2021-07-27 13:38:42 +08:00
b3a52a05d5 [Update] Support update syntax (#6230)
[Update] Support update syntax

    The current update syntax only supports updating the filtered data of a single table.

    Syntax:

     * UPDATE table_reference
     *     SET assignment_list
     *     [WHERE where_condition]
     *
     * value:
     *     {expr}
     *
     * assignment:
     *     col_name = value
     *
     * assignment_list:
     *     assignment [, assignment] ...

    Example
    Update unique_table
         set v1=1
         where k1=1

    New Frontend Config: enable_concurrent_update
    This configuration is used to control whether multi update stmt can be executed concurrently in one table.
    Default value is false which means A table can only have one update task being executed at the same time.
    If users want to update the same table concurrently,
      they need to modify the configuration value to true and restart the master frontend.
    Concurrent updates may cause write conflicts, the result is uncertain, please be careful.

    The main realization principle:
    1. Read the rows that meet the conditions according to the conditions set by where clause.
    2. Modify the result of the row according to the set clause.
    3. Write the modified row back to the table.

    Some restrictions on the use of update syntax.
    1. Only the unique table can be updated
    2. Only the value column of the unique table can be updated
    3. The where clause currently only supports single tables

    Possible risks:
    1. Since the current implementation method is a row update,
         when the same table is updated concurrently, there may be concurrency conflicts which may cause the incorrect result.
    2. Once the conditions of the where clause are unsatisfactory, it is likely to cause a full table scan and affect query performance.
       Please pay attention to whether the column in the where clause can match the index when using it.

    [Docs][Update] Add update document and sql-reference

    Fixed #6229
2021-07-27 13:38:15 +08:00
f26e3408b2 [Profile] Support show load profile for broker load job (#6214)
1.
Add new statement:
`SHOW LOAD PROFILE "xxx";`

2.
Improve the read performance of orc scanner
2021-07-27 13:37:34 +08:00
b1f5979103 [New Feature][Meta][Image] Add file header and footer for image (#6207)
#6206 

At present, our image file does not have file header/footer. When we need to change the image format (such as adding different journal versions to the image), there is no way to distinguish different image formats.

Therefore, we suggest adding file header and footer to the image. By the new image format, we can freely distinguish and define different image reading ways.

The format of the image is as follows:

```
/**
 * Image Format:
 * |- Image --------------------------------------|
 * | - Magic String (4 bytes)                     |
 * | - Header Length (4 bytes)                    |
 * | |- Header -----------------------------|     |
 * | | |- Json Header ---------------|      |     |
 * | | | - version                   |      |     |
 * | | | - other key/value(undecided)|      |     |
 * | | |-----------------------------|      |     |
 * | |--------------------------------------|     |
 * |                                              |
 * | |- Image Body -------------------------|     |
 * | | Object a                             |     |
 * | | Object b                             |     |
 * | | ...                                  |     |
 * | |--------------------------------------|     |
 * |                                              |
 * | |- Footer -----------------------------|     |
 * | | | - Checksum (8 bytes)               |     |
 * | | |- object index --------------|      |     |
 * | | | - index a                   |      |     |
 * | | | - index b                   |      |     |
 * | | | ...                         |      |     |
 * | | |-----------------------------|      |     |
 * | | - other value(undecided)             |     |
 * | |--------------------------------------|     |
 * | - Footer Length (8 bytes)                    |
 * | - Magic String (4 bytes)                     |
 * |----------------------------------------------|
 */
```
1. Magic Number
One image format is identified by one magic string and one version field. The magic string is save in the first 4 bytes and last 4 bytes in the images.

2. Image Header:
The version is save in the header with json format now.

3. Image Body:
Equal to the original image.

4.Image Footer:
Image footer stores the file offset(index) of many image objects. If necessary, we can read some objects in the image by the footer.
2021-07-27 13:36:53 +08:00
e3db773149 [UT] Fix MaterializedViewFunctionTest run failed (#6294)
Co-authored-by: caiconghui <caiconghui@xiaomi.com>
2021-07-26 09:42:39 +08:00
75d954ced5 [Feature] Modify the cost evaluation algorithm of Broadcast and Shuffle Join (#6274)
issue #6272

After modifying the Hash Table memory cost estimation algorithm, TPC-DS query-72 etc. can be passed, avoiding OOM.
2021-07-26 09:38:41 +08:00
7771233f30 [BUG] GROUPING func and ORDER BY are used at the same time to report NullPointerException (#6266)
fix #6265

The reason for the error is that the `Grouping Func Exprs` is substituted twice. In the first substitution, `VirtualSlotRef` is used to replace the original `SlotRef`, and in the second substitution, `VirtualSlotRef` is reported in the `getTable()` Times Null pointer. IN
```
} else if (((SlotRef) child).getDesc().getParent().getTable().getType()
```
For the first substitution, the List of executable exprs in select clause has been substituted.
```
groupingInfo = new GroupingInfo(analyzer, groupByClause.getGroupingType());
            groupingInfo.substituteGroupingFn(resultExprs, analyzer);
```
In the second substitution, actually only need to substitute the unique expr in Ordering exprs.
```
createSortInfo(analyzer);
        if (sortInfo != null && CollectionUtils.isNotEmpty(sortInfo.getOrderingExprs())) {
            if (groupingInfo != null) {
                groupingInfo.substituteGroupingFn(sortInfo.getOrderingExprs(), analyzer);
            }
        }
```
change into:
```
createSortInfo(analyzer);
        if (sortInfo != null && CollectionUtils.isNotEmpty(sortInfo.getOrderingExprs())) {
            if (groupingInfo != null) {
                List<Expr> orderingExprNotInSelect = sortInfo.getOrderingExprs().stream()
                        .filter(item -> !resultExprs.contains(item)).collect(Collectors.toList());
                groupingInfo.substituteGroupingFn(orderingExprNotInSelect, analyzer);
            }
        }
```
2021-07-21 12:31:20 +08:00
7592f52d2e [Feature][Insert] Add transaction for the operation of insert #6244 (#6245)
## Proposed changes
Add transaction for the operation of insert. It will cost less time than non-transaction(it will cost 1/1000 time) when you want to insert a amount of rows.
### Syntax

```
BEGIN [ WITH LABEL label];
INSERT INTO table_name ...
[COMMIT | ROLLBACK];
```

### Example
commit a transaction:
```
begin;
insert into Tbl values(11, 22, 33);
commit;
```
rollback a transaction:
```
begin;
insert into Tbl values(11, 22, 33);
rollback;
```
commit a transaction with label:
```
begin with label test_label;
insert into Tbl values(11, 22, 33);
commit;
```

### Description
```
begin:  begin a transaction, the next insert will execute in the transaction until commit/rollback;
commit:  commit the transaction, the data in the transaction will be inserted into the table;
rollback:  abort the transaction, nothing will be inserted into the table;
```
### The main realization principle:
```
1. begin a transaction in the session. next sql is executed in the transaction;
2. insert sql will be parser and get the database name and table name, they will be used to select a be and create a pipe to accept data;
3. all inserted values will be sent to the be and write into the pipe;
4. a thread will get the data from the pipe, then write them to disk;
5. commit will complete this transaction and make these data visible;
6. rollback will abort this transaction
```

### Some restrictions on the use of update syntax.
1. Only ```insert``` can be called in a transaction.
2. If something error happened, ```commit``` will not succeed, it will ```rollback``` directly;
3. By default, if part of insert in the transaction is invalid, ```commit``` will only insert the other correct data into the table.
4. If you need ```commit``` return failed when any insert in the transaction is invalid, you need execute ```set enable_insert_strict = true``` before ```begin```.
2021-07-21 10:54:11 +08:00
8ae129967e [ODBC] Support ODBC external table of SQLServer and revise the doc. (#6223)
Support ODBC external table of SQLServer
2021-07-21 10:50:56 +08:00
94c50012b2 [Performance] Optimize the performance of tabletReport (#6200)
1. Use parallelStream to speed up tabletReport.
2. Add partitionIdInMemorySet to speed up tabletToInMemory check.
3. Add disable_storage_medium_check to disable storage medium check when user doesn't care what tablet's storage medium is, and remove enable_strict_storage_medium_check config to fix some potential migration task failures.

Co-authored-by: caiconghui <caiconghui@xiaomi.com>
2021-07-19 20:26:14 +08:00
a1a37c8cba [Feature] Support calc constant expr by BE (#6233)
At present, some constant expression calculations are implemented on the FE side,
but they are incomplete, and some expressions cannot be completely consistent with
the value calculated by BE (such as part of the time function)

Therefore, we provide a way to pass all the constants in SQL to BE for calculation,
and then begin to analyze and plan SQL. This method can also solve the problem that some
complex constant calculations issued by BI cannot be processed on the FE side.

Here through a session variable enable_fold_constant_by_be to control this function,
which is disabled by default.
2021-07-19 10:25:53 +08:00
5de79ec3f0 [Feature] Support data encrypt/decrypt (#6115)
Add support for data encryption/decryption.
2021-07-19 09:27:08 +08:00
92d41f91b8 [UT] Fix CreateMaterializedViewStmtTest failed (#6258)
In PR #6226, we open the debug level of unit test, it cause some
unexpected exception.
2021-07-18 22:16:56 +08:00
7a8837c962 [Maven][Dependency][Bug][DOE] fix sync es metadata issue on jdk 13 (#6250) 2021-07-18 22:16:38 +08:00
b53ff15ef2 [Config] set spark load and odbc table feature enable by default (#6212)
1. Also use BufferedReader to speed up orc reader
2021-07-18 22:15:13 +08:00
a4b1622ceb [HttpV2] Add more httpv2 APIs (#6210)
1. /api/cluster_overview to view some statistic info of the cluster
2. /api/meta/ to view the database/table schema
3. /api/import/file_review to review the file content with format CSV or PARQUET.
2021-07-18 22:14:42 +08:00
e21bb504a2 [LOG] Errors during mysql connection establishment should be warned (#6257)
* Errors during mysql connection establishment should be warned

Co-authored-by: yuzhou.zk <yuzhou.zk@alibaba-inc.com>
2021-07-18 20:54:40 +08:00
66f1ddaa72 [BDBJE] Add a tool to view the data in BEBJE (#6209)
When the config "enable_bdbje_debug_mode" of FE is set to true,
start FE and enter debug mode.
In this mode, only MySQL server and http server will be started.
After that, users can log in to Doris through the web front-end or MySQL client,
and then use "show proc "/bdbje"" to view the data in bdbje.

Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-17 10:45:51 +08:00
e39e1571ec [Feature] Add an indicator called errorRowsAfterResumed to distinguish between … (#6092)
1. [enhancement] add an indicator called errorRowsAfterResumed to distinguish between totalErrorRows(called errorRows) and errorRowsAfterResumed. (#6092)
2. [Refactor] separate some indicators from RoutineLoadJob class to avoid changing FeMetaVersion while modifying indicators of RoutineLoadJob.(#6092)
2021-07-17 10:43:59 +08:00
409cee0fdb [Bug][RoutineLoad] Fix bug that routine load thread on BE may be blocked (#6215)
* [Bug][RoutineLoad] Fix bug that routine load thread on BE may be blocked

This bug will cause the routine load job throw TOO MANY TASK error, and routine
load job is blocked.

* fix ut

Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-15 11:21:01 +08:00
68f988b78a [Optimize] Use flat_hash_set to replace unorderd_set in InPredicate (#6216)
Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-15 11:15:11 +08:00
d5cd3ae5ee [Compatibility] Change the response body of load info api in httpv2. (#6208)
1. To be compatible with response body of GetLoadInfoAction in httpv1.
2. Not drop partition by force in dynamic partition scheduler.

Change-Id: I50864ddadf1a1c25efa16a465940a1129f937d3d

Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-15 11:14:45 +08:00
7e77b5ed7f [Optimize] Using custom conf dir to save log config of Spring (#6205)
The log4j-config.xml will be generated at startup of FE and also when modifying FE config.
But in some deploy environment such as k8s, the conf dir is not writable.

So change the dir of log4j-config.xml to Config.custom_conf_dir.

Also fix some small bugs:

1. Typo "less then" -> "less than"
2. Duplicated `exec_mem_limit` showed in SHOW ROUTINE LOAD
3. Allow MAXVALUE in single partition column table.
4. Add IP info for "intolerate index channel failure" msg.

Change-Id: Ib4e1182084219c41eae44d3a28110c0315fdbd7d

Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-15 11:13:51 +08:00
7c34dbbc5b [Bug-Fix] Fix bug that show view report "Unresolved table reference" error (#6184) 2021-07-15 10:55:15 +08:00
39945aba1e [s3][bug] Remove log4j1 (#6211)
There are jar package conflict

Co-authored-by: chenmingyu <chenmingyu@baidu.com>
2021-07-15 10:47:59 +08:00
cbc42db010 [JoinReorder] Implement a better join reorder algorithm. (#6226)
The current JoinReorder algorithm mainly sorts according to the star model,
and only considers the query association relationship between the table and the table.
The problems are following:
1. Only applicable to user data whose data model is a star model, data of other models cannot be sorted.
2. Regardless of the cost of the table, it is impossible to determine the size of the join table relationship,
   and the real query optimization ability is weak.
3. It is impossible to avoid possible time-consuming joins such as cross joins by sorting.

The new JoinReorder algorithm mainly introduces a new sorting algorithm for Join
The new ranking algorithm introduces the cost evaluation model to Doris.

The sorting algorithm is mainly based on the following three principles:
1. The order is: Largest node, Smallest node. . . Second largest node
2. Cross join is better than Inner join
3. The right children of Outer join, semi join, and anti join do not move

PlanNode's cost model evaluation mainly relies on two values: cardinality and selectivity.
cardinality: cardinality, can also be simply understood as the number of rows.
selectivity: selectivity, a value between 0 and 1. Predicate generally has selectivity.
The cost model generally calculates the final cardinality of a PlanNode based on the pre-calculated
cardinality of PlanNode and the selectivity of the predicate to which it belongs.

Currently, you can configure "enable_cost_based_join_reorder" to control the opening and closing of JoinReorder.
When the configuration is turned on, the new sorting algorithm will take effect, when it is turned off,
the old sorting algorithm will take effect, and it is turned off by default.

The new sorting algorithm currently has no cost base evaluation for external tables (odbc, es)
and set calculations (intersect, except). When using these queries, it is not recommended to enable cost base join reorder.
When using these queries, it is not recommended to enable cost base join reorder.

At the code architecture level:
1. The new sorting algorithm occurs in the single-node execution planning stage.
2. Refactored the init and finalize phases of PlanNode to ensure that PlanNode planning
   and cost evaluation have been completed before the sorting algorithm occurs.
2021-07-14 13:08:28 +08:00
ed3ff470ce [ARRAY] Support array type load and select not include access by index (#5980)
This is part of the array type support and has not been fully completed. 
The following functions are implemented
1. fe array type support and implementation of array function, support array syntax analysis and planning
2. Support import array type data through insert into
3. Support select array type data
4. Only the array type is supported on the value lie of the duplicate table

this pr merge some code from #4655 #4650 #4644 #4643 #4623 #2979
2021-07-13 14:02:39 +08:00
8fe5c75877 [DataX] Refactor doriswriter (#6188)
1. Use `read_json_by_line` to load data
2. Use FE http server as the target host of stream load
2021-07-13 11:36:40 +08:00
394a9a1472 [Feature] Runtime Filtering for Doris (Background, Configuration, FE Implement, Tuning, Test ) (#6121)
- `RuntimeFilterGenerator` is used to generate Runtime Filter and assign it to the node that uses Runtime Filter in the query plan.

- `RuntimeFilter` represents a filter in the query plan, including the specific properties of the filter, the binding method of expr and tuple slot, etc.

- `RuntimeFilterTarget` indicates the filter information provided to ScanNode, including target expr, whether to merge, etc.
2021-07-13 11:36:01 +08:00
f93a272956 [Bug] Fix bug that nondeterministic functions should not be rewrote in create view stmt (#6096)
create view v1 as select now() should not be rewrote as:
create view v1 as select "2021-06-26 12:11:11";
2021-07-13 11:35:35 +08:00
d79cdc829f [Bug] Filter out unavaliable backends when getting tablet location (#6204)
* [Bug] Filter out unavaiable backends when getting scan range location

In the previous implementation, we will eliminate non-surviving BEs in the Coordinator phase.
But for Spark or Flink Connector, there is no such logic, so when a BE node is down,
it will cause the problem of querying errors through the Connector.

* fix ut

* fix compiule
2021-07-13 11:17:49 +08:00
76e148988a Support alter default bucket_num of partitioned olap table (#6023)
* Support modify partitioned olap table's bucket num

Co-authored-by: EmmyMiao87 <522274284@qq.com>
2021-07-12 20:28:40 +08:00
dd15da4e12 [DynamicPartition] Fix UT and add more tests for dynamic partition (#6198) 2021-07-12 15:31:33 +08:00
56112c4718 [Bug] Fix bug that adding conflicting partition doesn't report errors (#6109)
* [Bug] Fix bug that adding conflicting partition doesn't report errors

Co-authored-by: caiconghui <caiconghui@xiaomi.com>
2021-07-12 13:32:44 +08:00
b5f447b932 [ResourceLimit] Add a property to limit user instance num. (#6159)
Add a property to limit user instance num.
2021-07-10 10:15:05 +08:00
5a1aa3ec35 [Bug][Dynamic partition] Forward show dynamic partition tables stmt to Master (#6190)
1.
Only Master FE has these info.
Also catch more exception of dynamic partition scheduler.

2.
Forward admin show frontend config stmt to Master if set forward_to_master=true
2021-07-10 10:14:04 +08:00
3ad12c5f8a [Log] Optimize delete error message (#6187)
## Proposed changes

When a delete error occurs, the error message is ambiguous.

```sql
mysql> DELETE FROM nebula_trade_health_trade PARTITION q3_2021 WHERE event_day = '20210706';
ERROR 1064 (HY000): errCode = 2, detailMessage = failed to execute delete. transaction id 7215554, timeout(ms) 160000, unfinished replicas: 4718319=7345841
```

We do not know the meaning of `4718319=7345841`.

Actually the former is `BackendId` and the latter is `TabletId`.

I'll add an instruction here to help locate the problem quickly. The error message will be 

```sql
ERROR 1064 (HY000): errCode = 2, detailMessage = failed to execute delete. transaction id 7215554, timeout(ms) 160000, unfinished replicas [BackendId=TabletId]: 4718319=7345841
```
2021-07-10 10:13:08 +08:00
01bef4b40d [Load] Add "LOAD WITH HDFS" model, and make hdfs_reader support hdfs ha (#6161)
Support load data from HDFS by using `LOAD WITH HDFS` syntax and read data directly via libhdfs3
2021-07-10 10:11:52 +08:00
814840f826 [refactor] Make Regex more simple and clear (#6141)
1. Remove Redundant character escape ‘\\}’ and ‘\\:’
2. Replace ‘{0,1}’ to ‘?’
2021-07-10 10:10:41 +08:00
65892cec3b [Bug] Create dynamic partition table failed with enable create_history_partition and not specify the start value (#6129)
fix the issue #5995
Add the property "dynamic_partition.history_partition_num" to specify the history partition number when enable create_history_partition to fix the invalid date format value
and add these two properties to docs
2021-07-10 10:10:28 +08:00
e426fbd6be [Planner] Align Date and Datetime by 16 bytes (#6105)
The previous alignment of Doris is up to 8 bytes.
For types with more than 8 bytes, such as Date, Datetime is not aligned.
This PR is mainly to relax the maximum 8-byte limitation
Also, because the data type Decimal v1 no longer exists,
the logic of the 40-byte Decimal v1 is also discarded.
2021-07-10 10:10:04 +08:00
cca813a57b [Bug] Fix the bug of bucket shuffle join cause error plan (#6172) 2021-07-08 15:44:39 +08:00
40bc3fed53 [Code] basic property related classes supports create, query, read, write, etc. (#6153)
Provides basic property related classes supports create, query, read, write, etc.
Currently, Doris FE mostly uses `if` statement to check properties in SQL. There is a lot of redundancy in the code.
The `PropertySet` class can be used in the analysis phase of `Statement`. The validation and correctness of the input properties are automatic verified. It can simplify the code and improve the readability of the code.

Usage:
1. Create a custom class that implements `SchemaGroup` interface.
2. Define the properties to be used. If it's a required parameter, there is no need to set the default value.
3. According the the requirements, in the logic called `readFromStrMap` and other functions to check and obtain parameters.

Demo:

Class definition

```
public class FileFormat implements PropertySchema.SchemaGroup {
    public static final PropertySchema<FileFormat.Type> FILE_FORMAT_TYPE =
            new PropertySchema.EnumProperty<>("type", FileFormat.Type.class).setDefauleValue(FileFormat.Type.CSV);
    public static final PropertySchema<String> RECORD_DELIMITER =
            new PropertySchema.StringProperty("record_delimiter").setDefauleValue("\n");
    public static final PropertySchema<String> FIELD_DELIMITER =
            new PropertySchema.StringProperty("field_delimiter").setDefauleValue("|");
    public static final PropertySchema<Integer> SKIP_HEADER =
            new PropertySchema.IntProperty("skip_header", true).setMin(0).setDefauleValue(0);

    private static final FileFormat INSTANCE = new FileFormat();

    private ImmutableMap<String, PropertySchema> schemas = PropertySchema.createSchemas(
            FILE_FORMAT_TYPE,
            RECORD_DELIMITER,
            FIELD_DELIMITER,
            SKIP_HEADER);

    public ImmutableMap<String, PropertySchema> getSchemas() {
        return schemas;
    }

    public static FileFormat get() {
        return INSTANCE;
    }
}

```

Usage
```
public class CreateXXXStmt extends DdlStmt {
    private PropertiesSet<FileFormat> analyzedFileFormat = PropertiesSet.empty(FileFormat.get());
    private final Map<String, String> fileFormatOptions;
    ...

    public void analyze(Analyzer analyzer) throws UserException {
        ...
        if (fileFormatOptions != null) {
            try {
                analyzedFileFormat = PropertiesSet.readFromStrMap(FileFormat.get(), fileFormatOptions);
            } catch (IllegalArgumentException e) {
                ...
            }
        }

        // 1. Get property value
        String recordDelimiter = analyzedFileFormat.get(FileFormat.RECORD_DELIMITER)
        // 2. Check the validity of parameters
        PropertiesSet.verifyKey(FileFormat.get(), fileFormatOptions);
        ...
    }

}
```
2021-07-08 09:55:07 +08:00
fb123b2b4b [httpv2] Switch SpringBoot built-in container to jetty (#6149)
Fix the 307 redirect problem
2021-07-08 09:54:28 +08:00
e312c0f58f Fix null pointer exception in Routine load (#6163)
The where clause in routine load will also be rewritten.
But there is no connection context.
The PR fix this problem #6162
2021-07-07 10:34:10 +08:00