cloud-fan commented on code in PR #42020:
URL: https://github.com/apache/spark/pull/42020#discussion_r1265406700
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/maskExpressions.scala:
##########
@@ -321,3 +273,72 @@ object Mask {
}
}
}
+
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+ usage =
+ """_FUNC_(input[, upperChar, lowerChar, digitChar, otherChar]) - masks the
given string value.
+ The function replaces characters with 'X' or 'x', and numbers with 'n'.
+ This can be useful for creating copies of tables with sensitive
information removed.
+ """,
+ arguments = """
+ Arguments:
+ * input - string value to mask. Supported types: STRING, VARCHAR,
CHAR
+ * upperChar - character to replace upper-case characters with. Specify
NULL to retain original character. Default value: 'X'
+ * lowerChar - character to replace lower-case characters with. Specify
NULL to retain original character. Default value: 'x'
+ * digitChar - character to replace digit characters with. Specify NULL
to retain original character. Default value: 'n'
+ * otherChar - character to replace all other characters with. Specify
NULL to retain original character. Default value: NULL
+ """,
+ examples = """
+ Examples:
+ > SELECT _FUNC_('abcd-EFGH-8765-4321');
+ xxxx-XXXX-nnnn-nnnn
+ > SELECT _FUNC_('abcd-EFGH-8765-4321', 'Q');
+ xxxx-QQQQ-nnnn-nnnn
+ > SELECT _FUNC_('AbCD123-@$#', 'Q', 'q');
+ QqQQnnn-@$#
+ > SELECT _FUNC_('AbCD123-@$#');
+ XxXXnnn-@$#
+ > SELECT _FUNC_('AbCD123-@$#', 'Q');
+ QxQQnnn-@$#
+ > SELECT _FUNC_('AbCD123-@$#', 'Q', 'q');
+ QqQQnnn-@$#
+ > SELECT _FUNC_('AbCD123-@$#', 'Q', 'q', 'd');
+ QqQQddd-@$#
+ > SELECT _FUNC_('AbCD123-@$#', 'Q', 'q', 'd', 'o');
+ QqQQdddoooo
+ > SELECT _FUNC_('AbCD123-@$#', NULL, 'q', 'd', 'o');
+ AqCDdddoooo
+ > SELECT _FUNC_('AbCD123-@$#', NULL, NULL, 'd', 'o');
+ AbCDdddoooo
+ > SELECT _FUNC_('AbCD123-@$#', NULL, NULL, NULL, 'o');
+ AbCD123oooo
+ > SELECT _FUNC_(NULL, NULL, NULL, NULL, 'o');
+ NULL
+ > SELECT _FUNC_(NULL);
+ NULL
+ > SELECT _FUNC_('AbCD123-@$#', NULL, NULL, NULL, NULL);
+ AbCD123-@$#
+ """,
+ since = "3.4.0",
+ group = "string_funcs")
+// scalastyle:on line.size.limit
+object MaskExpressionBuilder extends ExpressionBuilder {
Review Comment:
super nit: if we put `MaskExpressionBuilder` right before `case class Mask`,
the git code diff can be smaller.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]