-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Handle NaN when extracting predicate #4266
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
Changes from all commits
093c8b9
96034b7
189cf6a
199daa7
a8f44b9
5cdbb7c
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 |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ | |
| import java.util.stream.Collectors; | ||
|
|
||
| import static com.google.common.collect.ImmutableList.toImmutableList; | ||
| import static io.prestosql.spi.type.TypeUtils.isFloatingPointNaN; | ||
| import static io.prestosql.sql.ExpressionUtils.combineConjuncts; | ||
| import static io.prestosql.sql.ExpressionUtils.expressionOrNullSymbols; | ||
| import static io.prestosql.sql.ExpressionUtils.extractConjuncts; | ||
|
|
@@ -332,6 +333,7 @@ public Expression visitValues(ValuesNode node, Void context) | |
|
|
||
| ImmutableList.Builder<Object> builder = ImmutableList.builder(); | ||
| boolean hasNull = false; | ||
| boolean hasNaN = false; | ||
| boolean nonDeterministic = false; | ||
| for (int row = 0; row < node.getRows().size(); row++) { | ||
| Expression value = node.getRows().get(row).get(column); | ||
|
|
@@ -352,6 +354,9 @@ public Expression visitValues(ValuesNode node, Void context) | |
| hasNull = true; | ||
| } | ||
| else { | ||
| if (isFloatingPointNaN(type, evaluated)) { | ||
| hasNaN = true; | ||
| } | ||
| builder.add(evaluated); | ||
| } | ||
| } | ||
|
|
@@ -364,10 +369,15 @@ public Expression visitValues(ValuesNode node, Void context) | |
|
|
||
| List<Object> values = builder.build(); | ||
|
|
||
| Domain domain = Domain.none(type); | ||
|
|
||
| if (!values.isEmpty()) { | ||
| domain = domain.union(Domain.multipleValues(type, values)); | ||
| Domain domain; | ||
| if (values.isEmpty()) { | ||
| domain = Domain.none(type); | ||
| } | ||
| else if (hasNaN) { | ||
|
Member
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. Consider adding comment. It might not be obvious for reader why
Member
Author
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. This knowledge is sprinkled in multiple places in the code base already. |
||
| domain = Domain.notNull(type); | ||
| } | ||
| else { | ||
| domain = Domain.multipleValues(type, values); | ||
| } | ||
|
|
||
| if (hasNull) { | ||
|
|
||
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.
Do we need to handle
emptyas special case? ShouldDomain.multipleValueshandle thatin order to reduce
iffs?For example:
Yet
multipleValuesis implemented asThere 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.
i do not have a strong opinion. There are exactly 3 non-test call sites for
multipleValues, so updating it in a follow up would not be a problem.