vinodkc commented on code in PR #39449: URL: https://github.com/apache/spark/pull/39449#discussion_r1087342979
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/maskExpressions.scala: ########## @@ -23,9 +23,82 @@ import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch import org.apache.spark.sql.catalyst.expressions.codegen._ import org.apache.spark.sql.catalyst.expressions.codegen.Block._ import org.apache.spark.sql.errors.QueryErrorsBase -import org.apache.spark.sql.types.{AbstractDataType, DataType, StringType} +import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, StringType} import org.apache.spark.unsafe.types.UTF8String +/** + * This trait has common methods, which can be used by Classes implementing Masking udf functions + * Eg : Mask, MaskFirstN, etc + */ +private[sql] trait Maskable extends ExpectsInputTypes with QueryErrorsBase { + protected val upperCharExpr: Expression + protected val lowerCharExpr: Expression + protected val digitCharExpr: Expression + protected val otherCharExpr: Expression + + @transient Review Comment: Done ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/maskExpressions.scala: ########## @@ -23,9 +23,82 @@ import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch import org.apache.spark.sql.catalyst.expressions.codegen._ import org.apache.spark.sql.catalyst.expressions.codegen.Block._ import org.apache.spark.sql.errors.QueryErrorsBase -import org.apache.spark.sql.types.{AbstractDataType, DataType, StringType} +import org.apache.spark.sql.types.{AbstractDataType, DataType, IntegerType, StringType} import org.apache.spark.unsafe.types.UTF8String +/** + * This trait has common methods, which can be used by Classes implementing Masking udf functions + * Eg : Mask, MaskFirstN, etc + */ +private[sql] trait Maskable extends ExpectsInputTypes with QueryErrorsBase { + protected val upperCharExpr: Expression + protected val lowerCharExpr: Expression + protected val digitCharExpr: Expression + protected val otherCharExpr: Expression + + @transient + protected lazy val upperChar = upperCharExpr.eval() + @transient + protected lazy val lowerChar = lowerCharExpr.eval() + @transient + protected lazy val digitChar = digitCharExpr.eval() + @transient + protected lazy val otherChar = otherCharExpr.eval() + + protected def validateAdditionalFields(): Seq[Option[TypeCheckResult]] = Seq(None) Review Comment: Done -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org