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

Add support for ANSI SQL syntax in trim function #11236

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

ebyhr
Copy link
Member

@ebyhr ebyhr commented Mar 1, 2022

Description

Add support for ANSI SQL syntax in trim function

<trim function> ::=
  TRIM <left paren>  <trim operands>  <right paren> 

<trim operands> ::=
  [ [ <trim specification>  ] [ <trim character>  ] FROM ] <trim source> 

<trim source> ::=
  <character value expression> 

<trim specification> ::=
    LEADING
  | TRAILING
  | BOTH

<trim character> ::=
  <character value expression> 

Documentation

(x) Documentation issue #11347 is filed, and can be handled later.

Release notes

(x) Release notes entries required with the following suggested text:

# General
* Add support for ANSI compliant `trim` function. ({issue}`11236 `)

@cla-bot cla-bot bot added the cla-signed label Mar 1, 2022
@github-actions github-actions bot added the docs label Mar 1, 2022
@ebyhr ebyhr requested a review from kasiafi March 11, 2022 01:30
Copy link
Member

@kasiafi kasiafi left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!
I have some more comments.
However, the issue that worries me the most right now is the thing I mentioned in the previous round: #11236 (comment)
Apparently, the semantics of trim functions is broken for char types. I'd rather we didn't add support for new syntax before we fix the underlying logic.

@ebyhr ebyhr force-pushed the ebi/trim branch 2 times, most recently from ff4fcb4 to b82f08d Compare March 24, 2022 02:20
@ebyhr ebyhr requested a review from kasiafi March 24, 2022 06:07
@kasiafi
Copy link
Member

kasiafi commented Mar 24, 2022

This constructor is used from ExpressionTreeRewriter.

And who uses the rewriter? Trim should not be created in the Planner.

@kasiafi
Copy link
Member

kasiafi commented Mar 28, 2022

Addressed the comments except for calling Trim constructor without location in TranslationMap. Could you share the condition when doing that?

I'm sorry for not making it clear. I didn't mean that you have to use the constructor directly. What I meant is that if you do defaultRewrite on the Trim node, it will call that constructor underneath.

@ebyhr ebyhr requested a review from kasiafi March 29, 2022 08:51
Copy link
Member

@kasiafi kasiafi left a comment

Choose a reason for hiding this comment

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

LGTM overall

Copy link
Member

@kasiafi kasiafi left a comment

Choose a reason for hiding this comment

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

Approved. Please squash the commits.

@ebyhr
Copy link
Member Author

ebyhr commented Apr 8, 2022

CI #11368

@ebyhr ebyhr merged commit a319b0b into trinodb:master Apr 8, 2022
@ebyhr ebyhr deleted the ebi/trim branch April 8, 2022 12:26
@ebyhr ebyhr mentioned this pull request Apr 8, 2022
@github-actions github-actions bot added this to the 377 milestone Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants