Github user ueshin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21246#discussion_r187839186
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MaskExpressionsSuite.scala
 ---
    @@ -0,0 +1,236 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.catalyst.expressions
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.types.{IntegerType, StringType}
    +
    +class MaskExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper 
{
    +
    +  test("mask") {
    +    checkEvaluation(Mask(Literal("abcd-EFGH-8765-4321"), "U", "l", "#"), 
"llll-UUUU-####-####")
    +    checkEvaluation(
    +      new Mask(Literal("abcd-EFGH-8765-4321"), Literal("U"), Literal("l"), 
Literal("#")),
    +      "llll-UUUU-####-####")
    +    checkEvaluation(new Mask(Literal("abcd-EFGH-8765-4321"), Literal("U"), 
Literal("l")),
    +      "llll-UUUU-nnnn-nnnn")
    +    checkEvaluation(new Mask(Literal("abcd-EFGH-8765-4321"), 
Literal("U")), "xxxx-UUUU-nnnn-nnnn")
    +    checkEvaluation(new Mask(Literal("abcd-EFGH-8765-4321")), 
"xxxx-XXXX-nnnn-nnnn")
    +    checkEvaluation(new Mask(Literal(null, StringType)), null)
    +    checkEvaluation(Mask(Literal("abcd-EFGH-8765-4321"), null, "l", "#"), 
"llll-XXXX-####-####")
    +    checkEvaluation(new Mask(
    +      Literal("abcd-EFGH-8765-4321"),
    +      Literal(null, StringType),
    +      Literal(null, StringType),
    +      Literal(null, StringType)), "xxxx-XXXX-nnnn-nnnn")
    +    checkEvaluation(new Mask(Literal("abcd-EFGH-8765-4321"), 
Literal("Upper")),
    +      "xxxx-UUUU-nnnn-nnnn")
    +    checkEvaluation(new Mask(Literal("")), "")
    +    checkEvaluation(new Mask(Literal("abcd-EFGH-8765-4321"), Literal("")), 
"xxxx-XXXX-nnnn-nnnn")
    +    checkEvaluation(Mask(Literal("abcd-EFGH-8765-4321"), "", "", ""), 
"xxxx-XXXX-nnnn-nnnn")
    +    // scalastyle:off nonascii
    +    checkEvaluation(Mask(Literal("Ul9U"), "\u2200", null, null), 
"\u2200xn\u2200")
    +    checkEvaluation(new Mask(Literal("Hello World, こんにちは, ð 
€‹"), Literal("あ"), Literal("𡈽")),
    +      "あ𡈽𡈽𡈽𡈽 あ𡈽𡈽𡈽𡈽, こんにちは, 𠀋")
    +    // scalastyle:on nonascii
    +    intercept[AnalysisException] {
    +      checkEvaluation(new Mask(Literal(""), Literal(1)), "")
    +    }
    +  }
    +
    +  test("mask_first_n") {
    +    checkEvaluation(MaskFirstN(Literal("abcd-EFGH-8765-4321"), 6, "U", 
"l", "#"),
    --- End diff --
    
    Can you include upper/lower/number/other letters in the first N letters to 
check the mask is working?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to