Skip to content

[BEAM-5113][SQL] Add NOT LIKE based on LIKE expression#6186

Merged
akedin merged 1 commit intoapache:masterfrom
amaliujia:rui_wang-add_not_like_based_on_like
Aug 9, 2018
Merged

[BEAM-5113][SQL] Add NOT LIKE based on LIKE expression#6186
akedin merged 1 commit intoapache:masterfrom
amaliujia:rui_wang-add_not_like_based_on_like

Conversation

@amaliujia
Copy link
Copy Markdown
Contributor

Add NOT LIKE based on LIKE expression.


Follow this checklist to help us incorporate your contribution quickly and easily:

  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

It will help us expedite review of your Pull Request if you tag someone (e.g. @username) to look at it.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- --- --- --- ---
Java Build Status Build Status Build Status Build Status Build Status Build Status Build Status
Python Build Status --- Build Status
Build Status
--- --- --- ---

break;

case "NOT LIKE":
ret = new BeamSqlNotLikeExpression(subExps);
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.

Can we just pass a flag into BeamSqlLikeExpression?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I prefer this wrapper way because readability reason. Flag introduces more complexity here to understand the code. It seems to me that if true then return value else reversed value is more confusing.

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.

Cool, I don't mind it this way.

But I disagree that it is more readable :) It is a whole new separate class for NotLike. If I see it in the code, I would wonder how is it different from Like, and I have to read the whole class now to make sure it works as expected. And in this case I am confused because it defines operation for numbers and dates, so now I also have to read the Like class to learn that it's undefined there and throws exceptions. It also adds surface area for errors, now reading this I have to make sure that there's no ! missing anywhere. Instead I could just read 2 lines of code :) and it doesn't have to be a boolean flag though, e.g.:

enum Like { LIKE, NOT_LIKE }
...
like = compare();
return (type == NOT_LIKE) ? !like : like;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see. It makes sense to think from this perspective. Readers might stop reading when read the class name (which self-explains the functionality of class). However, if readers have to dig into the implementation of the separate class, it indeed reduces readability of the code.

@akedin akedin merged commit 28ca0ed into apache:master Aug 9, 2018
@amaliujia amaliujia deleted the rui_wang-add_not_like_based_on_like branch August 9, 2018 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants