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

[Kernel] Remove unused ExpressionHandler.isSupported(...) for now #3018

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@
*/
@Evolving
public interface ExpressionHandler {
/**
* Is the given expression evaluation supported on the data with given schema?
*
* @param inputSchema Schema of input data on which the expression is evaluated.
* @param expression Expression to check whether it is supported for evaluation.
* @param outputType Expected result data type.
* @return true if supported and false otherwise.
*/
boolean isSupported(StructType inputSchema, Expression expression, DataType outputType);

/**
* Create an {@link ExpressionEvaluator} that can evaluate the given <i>expression</i> on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ trait BaseMockExpressionHandler extends ExpressionHandler {
outputType: DataType): ExpressionEvaluator =
throw new UnsupportedOperationException("not supported in this test suite")

override def isSupported(
inputSchema: StructType,
expression: Expression,
outputType: DataType): Boolean =
throw new UnsupportedOperationException("not supported in this test suite")

override def createSelectionVector(values: Array[Boolean], from: Int, to: Int): ColumnVector =
throw new UnsupportedOperationException("not supported in this test suite")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@
* Default implementation of {@link ExpressionHandler}
*/
public class DefaultExpressionHandler implements ExpressionHandler {
@Override
public boolean isSupported(StructType inputSchema, Expression expression, DataType outputType) {
// There is no extra cost to create an expression handler in default implementation in
// addition to checking the expression support. So we can just use `getEvaluator`.
try {
getEvaluator(inputSchema, expression, outputType);
return true;
} catch (UnsupportedOperationException e) {
return false;
}
}

@Override
public ExpressionEvaluator getEvaluator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,6 @@ class DefaultExpressionHandlerSuite extends AnyFunSuite with ExpressionTestUtils
assert(ex.getMessage.contains("values is null"))
}

val tableSchema = new StructType()
.add("d1", INTEGER)
.add("d2", STRING)
.add("d3", new StructType()
.add("d31", BOOLEAN)
.add("d32", LONG))
.add("p1", INTEGER)
.add("p2", STRING)
val unsupportedExpr = Map(
(unsupported("d1"), BOOLEAN) -> false, // unsupported function
(lt(col("d1"), int(12)), BOOLEAN) -> true,
(lt(col("d1"), int(12)), INTEGER) -> false, // output type is not supported
(lt(nestedCol("d3.d32"), int(12)), BOOLEAN) -> true, // implicit conversion from int to long
(gt(col("d1"), str("sss")), STRING) -> false, // unexpected input type to > operator
// unsupported expression in one of the AND inputs
(and(gt(col("d2"), str("sss")), unsupported("d2")), BOOLEAN) -> false,
// both unsupported expressions in AND inputs
(and(gt(nestedCol("d3.d31"), str("sss")), unsupported("d2")), BOOLEAN) -> false,
// unsupported expression in one of the OR inputs
(or(gt(col("p2"), str("sss")), unsupported("d2")), BOOLEAN) -> false,
// both unsupported expressions in OR inputs
(or(gt(nestedCol("d3.d31"), str("sss")), unsupported("d2")), BOOLEAN) -> false
).foreach {
case ((expr, outputType), expected) =>
test(s"is expression supported: $expr -> $outputType") {
assert(
new DefaultExpressionHandler().isSupported(tableSchema, expr, outputType) == expected)
}
}

private def selectionVector(values: Array[Boolean], from: Int, to: Int) = {
new DefaultExpressionHandler().createSelectionVector(values, from, to)
}
Expand Down
Loading