-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Changes from 1 commit
c5c5cfd
72ad48c
1617fa2
06bcc7e
4eb8600
c8aa34c
fa27325
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,23 +11,28 @@ | |
import org.elasticsearch.xpack.sql.tree.Location; | ||
import org.elasticsearch.xpack.sql.type.DataType; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import static org.elasticsearch.index.query.QueryBuilders.termsQuery; | ||
|
||
public class TermsQuery extends LeafQuery { | ||
|
||
private final String term; | ||
private final LinkedHashSet<Object> values; | ||
private final Set<Object> values; | ||
|
||
public TermsQuery(Location location, String term, List<Expression> values) { | ||
super(location); | ||
this.term = term; | ||
values.removeIf(e -> e.dataType() == DataType.NULL); | ||
this.values = new LinkedHashSet<>(Foldables.valuesOf(values, values.get(0).dataType())); | ||
this.values.removeIf(Objects::isNull); | ||
if (values.isEmpty()) { | ||
this.values = Collections.emptySet(); | ||
} else { | ||
this.values = new LinkedHashSet<>(Foldables.valuesOf(values, values.get(0).dataType())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming that here all the values in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes that's true! |
||
} | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
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))