Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature](struct) Add a new syntax for struct constructor #41118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

xy720
Copy link
Member

@xy720 xy720 commented Sep 23, 2024

Proposed changes

Add a new syntax for struct construct.

STRUCT( expr1 [AS field_name] [, ... ])

e.g.

select struct(1 as a, 'a' as b, 4, 5) => {"a":1, "b":"a", "col3":4, "col4":5}

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@xy720
Copy link
Member Author

xy720 commented Sep 23, 2024

run buildall

@xy720
Copy link
Member Author

xy720 commented Sep 23, 2024

run buildall

@xy720
Copy link
Member Author

xy720 commented Sep 23, 2024

run buildall

@xy720
Copy link
Member Author

xy720 commented Sep 24, 2024

run buildall

@xy720
Copy link
Member Author

xy720 commented Sep 24, 2024

run p0

@@ -1555,7 +1555,7 @@ functionCallExpression
: functionIdentifier
LEFT_PAREN (
(DISTINCT|ALL)?
arguments+=expression (COMMA arguments+=expression)*
arguments+=argumentExpression (COMMA arguments+=argumentExpression)*
Copy link
Contributor

@morrySnow morrySnow Sep 24, 2024

Choose a reason for hiding this comment

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

  1. namedExpression contains expression, so use namedExpression directly is ok
  2. i think any other function should throw exception explicitly, such as abs(a as b). so we should specific struct function and should not change any other function 's syntax

Copy link
Contributor

@lide-reed lide-reed left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Sep 26, 2024
Copy link
Contributor

PR approved by anyone and no changes requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants