-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Kernel][Expressions] Add IS NOT DISTINCT FROM
support
#2830
Changes from all commits
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 |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import static io.delta.kernel.defaults.internal.expressions.DefaultExpressionUtils.booleanWrapperVector; | ||
import static io.delta.kernel.defaults.internal.expressions.DefaultExpressionUtils.childAt; | ||
import static io.delta.kernel.defaults.internal.expressions.DefaultExpressionUtils.compare; | ||
import static io.delta.kernel.defaults.internal.expressions.DefaultExpressionUtils.compareNullSafe; | ||
import static io.delta.kernel.defaults.internal.expressions.DefaultExpressionUtils.evalNullability; | ||
import static io.delta.kernel.defaults.internal.expressions.ImplicitCastExpression.canCastTo; | ||
|
||
|
@@ -156,6 +157,19 @@ ExpressionTransformResult visitComparator(Predicate predicate) { | |
} | ||
} | ||
|
||
@Override | ||
ExpressionTransformResult visitNullSafeComparator(Predicate predicate) { | ||
switch (predicate.getName()) { | ||
case "<=>": | ||
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. Add the new operator to the Java doc of Predicate. 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. Wondering if we should just use 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. @vkorukanti is |
||
return new ExpressionTransformResult( | ||
transformBinaryComparator(predicate), | ||
BooleanType.BOOLEAN); | ||
default: | ||
throw DeltaErrors.unsupportedExpression( | ||
predicate, Optional.of("unsupported expression encountered")); | ||
} | ||
} | ||
|
||
@Override | ||
ExpressionTransformResult visitLiteral(Literal literal) { | ||
// nothing to validate or rewrite | ||
|
@@ -445,6 +459,27 @@ ColumnVector visitComparator(Predicate predicate) { | |
return new DefaultBooleanVector(numRows, Optional.of(nullability), result); | ||
} | ||
|
||
@Override | ||
ColumnVector visitNullSafeComparator(Predicate predicate) { | ||
PredicateChildrenEvalResult argResults = evalBinaryExpressionChildren(predicate); | ||
int numRows = argResults.rowCount; | ||
boolean[] result = new boolean[numRows]; | ||
int[] compareResult = compareNullSafe(argResults.leftResult, argResults.rightResult); | ||
Comment on lines
+465
to
+467
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. we want to get away from this model to lazy compute model (#2541) this can be rewritten as
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 am a bit confused on
Shouldn't |
||
switch (predicate.getName()) { | ||
case "<=>": | ||
for (int rowId = 0; rowId < numRows; rowId++) { | ||
result[rowId] = compareResult[rowId] == 0; | ||
} | ||
break; | ||
default: | ||
throw DeltaErrors.unsupportedExpression( | ||
predicate, | ||
Optional.of("unsupported expression encountered")); | ||
} | ||
|
||
return new DefaultBooleanVector(numRows, Optional.empty(), result); | ||
} | ||
|
||
@Override | ||
ColumnVector visitLiteral(Literal literal) { | ||
DataType dataType = literal.getDataType(); | ||
|
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.
Can this be combined into the
visitComparator
above? That way we can avoid an additional method on this visitor.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.
fixed in #3230