Skip to content

[Feature](Complex-type) Add struct and map type to Doris - #16444

Merged
xy720 merged 27 commits into
masterfrom
struct-map-type
Feb 10, 2023
Merged

[Feature](Complex-type) Add struct and map type to Doris#16444
xy720 merged 27 commits into
masterfrom
struct-map-type

Conversation

@xy720

@xy720xy720 commented Feb 6, 2023

Copy link
Copy Markdown
Member

Proposed changes

Support complex type struct and map to Doris.

Design docs for struct and map

Problem summary

This commit support:

1、Insert + select for struct/map type
2、Json stream load for struct type
3、m[key] function for map type

How to use:

Set the fe config to create table for struct and map type
1、admin set frontend config("enable_struct_type" = "true");
2、admin set frontend config("enable_map_type" = "true");

#16547

Co-authored-by: xy720 <xuyang25@baidu.com>
Co-authored-by: amory <wangqiannan@selectdb.com>
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
Co-authored-by: hucheng01 <hucheng01@baidu.com>

Checklist(Required)

  1. Does it affect the original behavior:
    • Yes
    • No
    • I don't know
  2. Has unit tests been added:
    • Yes
    • No
    • No Need
  3. Has document been added or modified:
    • Yes
    • No
    • No Need
  4. Does it need to update dependencies:
    • Yes
    • No
  5. Are there any changes that cannot be rolled back:
    • Yes (If Yes, please explain WHY)
    • No

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actionsgithub-actionsBot added area/planner Issues or PRs related to the query planner area/sql/function Issues or PRs related to the SQL functions area/vectorization kind/docs Categorizes issue or PR as related to documentation. labels Feb 6, 2023
@xy720xy720 changed the title [Feature](Struct/Map-type) Add struct and map type to Doris[Feature](Complex-type) Add struct and map type to DorisFeb 6, 2023
@xy720xy720 added struct-type Issues or PRs related to struct type map-type Issues or PRs related to map type labels Feb 6, 2023
@hello-stephen

hello-stephen commented Feb 6, 2023

Copy link
Copy Markdown
Contributor

TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 34.54 seconds
load time: 471 seconds
storage size: 17171008864 Bytes
https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20230206134540_clickbench_pr_90973.html

@morningman

Copy link
Copy Markdown
Contributor

LGTM with thrift and proto.
cc @xiaokang , PTAL

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment threadbe/src/olap/types.h
Comment threadbe/src/olap/types.h
Comment threadbe/src/olap/types.h
Comment threadbe/src/olap/types.h
Comment threadbe/test/vec/jsonb/serialize_test.cpp
Comment threadbe/test/vec/jsonb/serialize_test.cpp
cambyzju
cambyzju previously approved these changes Feb 8, 2023

@cambyzjucambyzju left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Feb 8, 2023
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@xiaokangxiaokang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

add some comments that can be fixed by further PRs

Comment threadfe/fe-core/src/main/jflex/sql_scanner.flex Outdated
Comment threadgensrc/thrift/Exprs.thrift Outdated
Comment threadREADME.md
;

struct_literal ::=
LBRACE expr_list:list RBRACE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User may get confused if map literal and struct literal both use brace{}.

@xy720xy720Feb 8, 2023

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, we keep struct literal using brace{}.
After we implement struct() function, we can support paren() for struct.

public String getStringValue() {
List<String> list = new ArrayList<>(children.size());
children.forEach(v -> list.add(v.getStringValue()));
return "{" + StringUtils.join(list, ", ") + "}";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest using '(' ')' to keep consistency.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we should support '(' ')' only in insert stmt in future.
For select stmt and other places, we keep using brace{}.

Comment threadbe/src/olap/rowset/segment_v2/column_writer.cpp Outdated
@@ -95,7 +97,10 @@ class DataTypeFactory {
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

register Map to _invert_data_type_map like Array

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we will add this part in next map pr.

Comment threadbe/src/vec/data_types/data_type_factory.cpp
Comment threadbe/src/vec/data_types/data_type_struct.cpp Outdated
Comment threadbe/src/vec/exprs/vexpr.cpp
xiaokang
xiaokang previously approved these changes Feb 8, 2023
@xy720
xy720 dismissed stale reviews from xiaokang and cambyzju via 7049decFebruary 8, 2023 07:34
@github-actionsgithub-actionsBot removed the approved Indicates a PR has been approved by one committer. label Feb 8, 2023

@cambyzjucambyzju left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Feb 10, 2023
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@xy720
xy720 merged commit 1b3902b into masterFeb 10, 2023
YangShaw pushed a commit to YangShaw/doris that referenced this pull request Feb 17, 2023
This commit support:
1、Insert + select for struct/map type
2、Json stream load for struct type
3、m[key] function for map type
How to use:
Set the fe config to create table for struct and map type
1、admin set frontend config("enable_struct_type" = "true");
2、admin set frontend config("enable_map_type" = "true");
apache#16547
Co-authored-by: xy720 <xuyang25@baidu.com>
Co-authored-by: amory <wangqiannan@selectdb.com>
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
Co-authored-by: hucheng01 <hucheng01@baidu.com>
@xy720xy720 mentioned this pull request Feb 24, 2023
88 tasks
@adonis0147
adonis0147 deleted the struct-map-type branch November 13, 2023 06:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.area/plannerIssues or PRs related to the query plannerarea/sql/functionIssues or PRs related to the SQL functionsarea/vectorizationkind/docsCategorizes issue or PR as related to documentation.kind/testmap-typeIssues or PRs related to map typereviewedstruct-typeIssues or PRs related to struct type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@xy720@hello-stephen@morningman@xiaokang@cambyzju@carlvinhust2012