Skip to content

Commit

Permalink
[VL] Enable Spark mask function (#6271)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaoyangxiaozhu authored Jul 30, 2024
1 parent b5657d3 commit 295899c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,24 @@ abstract class ScalarFunctionsValidateSuite extends FunctionsValidateTest {
}
}

testWithSpecifiedSparkVersion("mask", Some("3.4")) {
runQueryAndCompare("SELECT mask(c_comment) FROM customer limit 50") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
runQueryAndCompare("SELECT mask(c_comment, 'Y') FROM customer limit 50") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
runQueryAndCompare("SELECT mask(c_comment, 'Y', 'y') FROM customer limit 50") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
runQueryAndCompare("SELECT mask(c_comment, 'Y', 'y', 'o') FROM customer limit 50") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
runQueryAndCompare("SELECT mask(c_comment, 'Y', 'y', 'o', '*') FROM customer limit 50") {
checkGlutenOperatorMatch[ProjectExecTransformer]
}
}

test("bit_length") {
runQueryAndCompare(
"select bit_length(c_comment), bit_length(cast(c_comment as binary))" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ object ExpressionNames {
final val LEVENSHTEIN = "levenshtein"
final val UNBASE64 = "unbase64"
final val BASE64 = "base64"
final val MASK = "mask"

// URL functions
final val PARSE_URL = "parse_url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class Spark34Shims extends SparkShims {
Sig[Empty2Null](ExpressionNames.EMPTY2NULL),
Sig[TimestampAdd](ExpressionNames.TIMESTAMP_ADD),
Sig[RoundFloor](ExpressionNames.FLOOR),
Sig[RoundCeil](ExpressionNames.CEIL)
Sig[RoundCeil](ExpressionNames.CEIL),
Sig[Mask](ExpressionNames.MASK)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Spark35Shims extends SparkShims {
Sig[Csc](ExpressionNames.CSC),
Sig[KnownNullable](ExpressionNames.KNOWN_NULLABLE),
Sig[Empty2Null](ExpressionNames.EMPTY2NULL),
Sig[Mask](ExpressionNames.MASK),
Sig[TimestampAdd](ExpressionNames.TIMESTAMP_ADD),
Sig[RoundFloor](ExpressionNames.FLOOR),
Sig[RoundCeil](ExpressionNames.CEIL)
Expand Down

0 comments on commit 295899c

Please sign in to comment.