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

SQL: Fix edge case: <field> IN (null) #34802

Merged
merged 7 commits into from
Oct 25, 2018
Merged

Conversation

matriv
Copy link
Contributor

@matriv matriv commented Oct 24, 2018

Handle the case when null is the only value in the list so that
it's translated to a MatchNoDocsQuery.

Followup to: #34750

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@matriv
Copy link
Contributor Author

matriv commented Oct 24, 2018

Depends on #34812

@matriv matriv removed request for costin and astefan October 24, 2018 15:47
@matriv matriv added the WIP label Oct 24, 2018
@matriv matriv changed the title SQL: Fix edge case: `<field> IN(null) SQL: Fix edge case: <field> IN(null) Oct 24, 2018
@matriv matriv force-pushed the mt/fix-edge-case-in branch from d931ed9 to 99f5698 Compare October 24, 2018 16:21
Handle the case when `null` is the only value in the list so that
it's translated to a `MatchNoDocsQuery`.

Followup to: elastic#34750
@matriv matriv force-pushed the mt/fix-edge-case-in branch from 99f5698 to c5c5cfd Compare October 24, 2018 18:38
@matriv matriv changed the title SQL: Fix edge case: <field> IN(null) SQL: Fix edge case: <field> IN (null) Oct 24, 2018
@matriv matriv requested review from costin and astefan October 24, 2018 18:39
@matriv matriv removed the WIP label Oct 24, 2018
@matriv
Copy link
Contributor Author

matriv commented Oct 24, 2018

@costin @astefan This is ready for review now.

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM. Just one picky comment.

}

@Override
public Boolean fold() {
if (value.dataType() == DataType.NULL || list.size() == 1 && list.get(0).dataType() == DataType.NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better readability if additional brackets are used? if (value.dataType() == DataType.NULL || (list.size() == 1 && list.get(0).dataType() == DataType.NULL))

if (values.isEmpty()) {
this.values = Collections.emptySet();
} else {
this.values = new LinkedHashSet<>(Foldables.valuesOf(values, values.get(0).dataType()));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming that here all the values in values are of the same type otherwise we would have had the error message about different types.

Copy link
Contributor Author

@matriv matriv Oct 24, 2018

Choose a reason for hiding this comment

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

yes that's true!

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM

@matriv
Copy link
Contributor Author

matriv commented Oct 24, 2018

retest this please

@matriv matriv merged commit bd14333 into elastic:master Oct 25, 2018
@matriv matriv deleted the mt/fix-edge-case-in branch October 25, 2018 12:25
matriv pushed a commit that referenced this pull request Oct 25, 2018
Handle the case when `null` is the only value in the list so that
it's translated to a `MatchNoDocsQuery`.

Followup to: #34750
@matriv
Copy link
Contributor Author

matriv commented Oct 25, 2018

Backported to 6.x with 281b44b

matriv pushed a commit that referenced this pull request Oct 25, 2018
Handle the case when `null` is the only value in the list so that
it's translated to a `MatchNoDocsQuery`.

Followup to: #34750
@matriv
Copy link
Contributor Author

matriv commented Oct 25, 2018

Backported to 6.5 with 4290f69

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Oct 26, 2018
* master: (74 commits)
  XContent: Check for bad parsers (elastic#34561)
  Docs: Align prose with snippet (elastic#34839)
  document the search context is freed if the scroll is not extended (elastic#34739)
  Test: Lookup node versions on rest test start (elastic#34657)
  SQL: Return error with ORDER BY on non-grouped. (elastic#34855)
  Reduce channels in AbstractSimpleTransportTestCase (elastic#34863)
  [DOCS] Updates Elasticsearch monitoring tasks (elastic#34339)
  Check self references in metric agg after last doc collection (elastic#33593) (elastic#34001)
  [Docs] Add `indices.query.bool.max_clause_count` setting (elastic#34779)
  Add 6.6.0 version to master (elastic#34847)
  Test: ensure char[] doesn't being with prefix (elastic#34816)
  Remove static import from HLRC doc snippet (elastic#34834)
  Logging: server: clean up logging (elastic#34593)
  Logging: tests: clean up logging (elastic#34606)
  SQL: Fix edge case: `<field> IN (null)` (elastic#34802)
  [Test] Mute FullClusterRestartIT.testShrink() until test is fixed
  SQL: Introduce ODBC mode, similar to JDBC (elastic#34825)
  SQL: handle X-Pack or X-Pack SQL not being available in a more graceful way (elastic#34736)
  [Docs] Add explanation for code snippets line width (elastic#34796)
  CCR: Rename follow-task parameters and stats (elastic#34836)
  ...
kcm pushed a commit that referenced this pull request Oct 30, 2018
Handle the case when `null` is the only value in the list so that
it's translated to a `MatchNoDocsQuery`.

Followup to: #34750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants