Skip to content
Open
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 @@ -127,6 +127,7 @@ yield visitBinaryArithmetic(
case "LTRIM" -> visitTrim("LEADING", expressionsToStringArray(e.children()));
case "RTRIM" -> visitTrim("TRAILING", expressionsToStringArray(e.children()));
case "OVERLAY" -> visitOverlay(expressionsToStringArray(e.children()));
case "GET_ARRAY_ITEM" -> visitGetArrayItem(expressionsToStringArray(e.children()));
// TODO supports other expressions
default -> visitUnexpectedExpr(expr);
};
Expand Down Expand Up @@ -342,6 +343,13 @@ protected String visitTrim(String direction, String[] inputs) {
}
}

protected String visitGetArrayItem(String[] inputs) {
throw new SparkUnsupportedOperationException(
"_LEGACY_ERROR_TEMP_3177",
Map.of("class", this.getClass().getSimpleName(), "funcName", "GET_ARRAY_ITEM")
);
}

protected String visitExtract(Extract extract) {
return visitExtract(extract.field(), build(extract.source()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ class V2ExpressionBuilder(e: Expression, isPredicate: Boolean = false) extends L
case _: Sha2 => generateExpressionWithName("SHA2", expr, isPredicate)
case _: StringLPad => generateExpressionWithName("LPAD", expr, isPredicate)
case _: StringRPad => generateExpressionWithName("RPAD", expr, isPredicate)
case GetArrayItem(_, _, failOnError) if failOnError =>
// Pushdown only if ANSI is enabled (fail on error) to be compatible with remote systems.
generateExpressionWithName("GET_ARRAY_ITEM", expr, isPredicate)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can make new v2 expression as well to be able to pass failOnError argument, since get method in spark returns 0-indexed element of array, but it does not fail for index out of bounds, so it would be beneficial to pass failOnError to be able to support get method pushdown beside bracket access. WDYT @srielau @cloud-fan ?

// TODO supports other expressions
case ApplyFunctionExpression(function, children) =>
val childrenExpressions = children.flatMap(generateExpression(_))
Expand Down