You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2020/05/10 01:44:39 UTC

[hive] branch master updated: HIVE-22699 : Mask UDFs should mask numeric value 0 (Quanlong Huang via Madhan Neetiraj, Ashutosh Chauhan)

This is an automated email from the ASF dual-hosted git repository.

hashutosh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f1358d  HIVE-22699 : Mask UDFs should mask numeric value 0 (Quanlong Huang via Madhan Neetiraj, Ashutosh Chauhan)
3f1358d is described below

commit 3f1358d57d3a43894b912169a2d66cd6c77ce1d4
Author: Quanlong Huang <hu...@gmail.com>
AuthorDate: Sat May 9 18:43:26 2020 -0700

    HIVE-22699 : Mask UDFs should mask numeric value 0 (Quanlong Huang via Madhan Neetiraj, Ashutosh Chauhan)
    
    Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
---
 .../apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java    | 12 ++++++++++++
 .../hadoop/hive/ql/udf/generic/GenericUDFMaskFirstN.java     | 12 ++++++++++++
 .../hadoop/hive/ql/udf/generic/GenericUDFMaskLastN.java      | 12 ++++++++++++
 .../hadoop/hive/ql/udf/generic/GenericUDFMaskShowFirstN.java | 12 ++++++++++++
 .../hadoop/hive/ql/udf/generic/GenericUDFMaskShowLastN.java  | 12 ++++++++++++
 ql/src/test/queries/clientpositive/udf_mask.q                |  4 ++++
 ql/src/test/queries/clientpositive/udf_mask_first_n.q        |  3 +++
 ql/src/test/queries/clientpositive/udf_mask_last_n.q         |  3 +++
 ql/src/test/queries/clientpositive/udf_mask_show_first_n.q   |  3 +++
 ql/src/test/queries/clientpositive/udf_mask_show_last_n.q    |  3 +++
 ql/src/test/results/clientpositive/udf_mask.q.out            | 10 +++++++++-
 ql/src/test/results/clientpositive/udf_mask_first_n.q.out    |  8 +++++++-
 ql/src/test/results/clientpositive/udf_mask_last_n.q.out     |  8 +++++++-
 .../test/results/clientpositive/udf_mask_show_first_n.q.out  |  8 +++++++-
 .../test/results/clientpositive/udf_mask_show_last_n.q.out   |  8 +++++++-
 15 files changed, 113 insertions(+), 5 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java
index 27c3bf8..812b028 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java
@@ -121,6 +121,9 @@ class MaskTransformer extends AbstractTransformer {
 
   @Override
   Byte transform(final Byte value) {
+    if (value == 0) {
+      return (byte) maskedNumber;
+    }
     byte val = value;
 
     if(value < 0) {
@@ -145,6 +148,9 @@ class MaskTransformer extends AbstractTransformer {
 
   @Override
   Short transform(final Short value) {
+    if (value == 0) {
+      return (short) maskedNumber;
+    }
     short val = value;
 
     if(value < 0) {
@@ -169,6 +175,9 @@ class MaskTransformer extends AbstractTransformer {
 
   @Override
   Integer transform(final Integer value) {
+    if (value == 0) {
+      return maskedNumber;
+    }
     int val = value;
 
     if(value < 0) {
@@ -193,6 +202,9 @@ class MaskTransformer extends AbstractTransformer {
 
   @Override
   Long transform(final Long value) {
+    if (value == 0) {
+      return (long) maskedNumber;
+    }
     long val = value;
 
     if(value < 0) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskFirstN.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskFirstN.java
index 76ee292..c1ea157 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskFirstN.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskFirstN.java
@@ -81,6 +81,9 @@ class MaskFirstNTransformer extends MaskTransformer {
 
   @Override
   Byte transform(final Byte value) {
+    if (value == 0) {
+      return charCount > 0 ? (byte) maskedNumber : 0;
+    }
     byte val = value;
 
     if(value < 0) {
@@ -118,6 +121,9 @@ class MaskFirstNTransformer extends MaskTransformer {
 
   @Override
   Short transform(final Short value) {
+    if (value == 0) {
+      return charCount > 0 ? (short) maskedNumber : 0;
+    }
     short val = value;
 
     if(value < 0) {
@@ -155,6 +161,9 @@ class MaskFirstNTransformer extends MaskTransformer {
 
   @Override
   Integer transform(final Integer value) {
+    if (value == 0) {
+      return charCount > 0 ? maskedNumber : 0;
+    }
     int val = value;
 
     if(value < 0) {
@@ -192,6 +201,9 @@ class MaskFirstNTransformer extends MaskTransformer {
 
   @Override
   Long transform(final Long value) {
+    if (value == 0) {
+      return charCount > 0 ? maskedNumber : 0L;
+    }
     long val = value;
 
     if(value < 0) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskLastN.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskLastN.java
index c0c5c61..684c049 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskLastN.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskLastN.java
@@ -81,6 +81,9 @@ class MaskLastNTransformer extends MaskTransformer {
 
   @Override
   Byte transform(final Byte value) {
+    if (value == 0) {
+      return charCount > 0 ? (byte) maskedNumber : 0;
+    }
     byte val = value;
 
     if(value < 0) {
@@ -109,6 +112,9 @@ class MaskLastNTransformer extends MaskTransformer {
 
   @Override
   Short transform(final Short value) {
+    if (value == 0) {
+      return charCount > 0 ? (short) maskedNumber : 0;
+    }
     short val = value;
 
     if(value < 0) {
@@ -137,6 +143,9 @@ class MaskLastNTransformer extends MaskTransformer {
 
   @Override
   Integer transform(final Integer value) {
+    if (value == 0) {
+      return charCount > 0 ? maskedNumber : 0;
+    }
     int val = value;
 
     if(value < 0) {
@@ -165,6 +174,9 @@ class MaskLastNTransformer extends MaskTransformer {
 
   @Override
   Long transform(final Long value) {
+    if (value == 0) {
+      return charCount > 0 ? maskedNumber : 0L;
+    }
     long val = value;
 
     if(value < 0) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowFirstN.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowFirstN.java
index a8f70f2..48589a8 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowFirstN.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowFirstN.java
@@ -84,6 +84,9 @@ class MaskShowFirstNTransformer extends MaskTransformer {
 
   @Override
   Byte transform(final Byte value) {
+    if (value == 0) {
+      return charCount == 0 ? (byte) maskedNumber : 0;
+    }
     byte val = value;
 
     if(value < 0) {
@@ -125,6 +128,9 @@ class MaskShowFirstNTransformer extends MaskTransformer {
 
   @Override
   Short transform(final Short value) {
+    if (value == 0) {
+      return charCount == 0 ? (short) maskedNumber : 0;
+    }
     short val = value;
 
     if(value < 0) {
@@ -166,6 +172,9 @@ class MaskShowFirstNTransformer extends MaskTransformer {
 
   @Override
   Integer transform(final Integer value) {
+    if (value == 0) {
+      return charCount == 0 ? maskedNumber : 0;
+    }
     int val = value;
 
     if(value < 0) {
@@ -207,6 +216,9 @@ class MaskShowFirstNTransformer extends MaskTransformer {
 
   @Override
   Long transform(final Long value) {
+    if (value == 0) {
+      return charCount == 0 ? maskedNumber : 0L;
+    }
     long val = value;
 
     if(value < 0) {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowLastN.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowLastN.java
index c72d75e..978b28c 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowLastN.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMaskShowLastN.java
@@ -86,6 +86,9 @@ class MaskShowLastNTransformer extends MaskTransformer {
 
   @Override
   Byte transform(final Byte value) {
+    if (value == 0) {
+      return charCount == 0 ? (byte) maskedNumber : 0;
+    }
     byte val = value;
 
     if(value < 0) {
@@ -114,6 +117,9 @@ class MaskShowLastNTransformer extends MaskTransformer {
 
   @Override
   Short transform(final Short value) {
+    if (value == 0) {
+      return charCount == 0 ? (short) maskedNumber : 0;
+    }
     short val = value;
 
     if(value < 0) {
@@ -142,6 +148,9 @@ class MaskShowLastNTransformer extends MaskTransformer {
 
   @Override
   Integer transform(final Integer value) {
+    if (value == 0) {
+      return charCount == 0 ? maskedNumber : 0;
+    }
     int val = value;
 
     if(value < 0) {
@@ -170,6 +179,9 @@ class MaskShowLastNTransformer extends MaskTransformer {
 
   @Override
   Long transform(final Long value) {
+    if (value == 0) {
+      return charCount == 0 ? maskedNumber : 0L;
+    }
     long val = value;
 
     if(value < 0) {
diff --git a/ql/src/test/queries/clientpositive/udf_mask.q b/ql/src/test/queries/clientpositive/udf_mask.q
index 15f7d27..f6dac50 100644
--- a/ql/src/test/queries/clientpositive/udf_mask.q
+++ b/ql/src/test/queries/clientpositive/udf_mask.q
@@ -6,6 +6,10 @@ explain select mask('TestString-123', 'X', 'x', '0', '1');
 select mask('TestString-123', 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as varchar(24)), 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as char(24)), 'X', 'x', '0', ':'),
+       mask(cast(0 as tinyint), -1, -1, -1, -1, 4),
+       mask(cast(0 as smallint), -1, -1, -1, -1, 4),
+       mask(cast(0 as int), -1, -1, -1, -1, 4),
+       mask(cast(0 as bigint), -1, -1, -1, -1, 4),
        mask(cast(123 as tinyint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as smallint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as int), -1, -1, -1, -1, '5'),
diff --git a/ql/src/test/queries/clientpositive/udf_mask_first_n.q b/ql/src/test/queries/clientpositive/udf_mask_first_n.q
index 3cd3962..40060be 100644
--- a/ql/src/test/queries/clientpositive/udf_mask_first_n.q
+++ b/ql/src/test/queries/clientpositive/udf_mask_first_n.q
@@ -6,6 +6,9 @@ explain select mask_first_n('TestString-123', 4, 'X', 'x', '0', '1');
 select mask_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_first_n(0, 0),
+       mask_first_n(0, 1),
+       mask_first_n(0, 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
diff --git a/ql/src/test/queries/clientpositive/udf_mask_last_n.q b/ql/src/test/queries/clientpositive/udf_mask_last_n.q
index 89eb05d..4f88631 100644
--- a/ql/src/test/queries/clientpositive/udf_mask_last_n.q
+++ b/ql/src/test/queries/clientpositive/udf_mask_last_n.q
@@ -6,6 +6,9 @@ explain select mask_last_n('TestString-123', 4, 'X', 'x', '0', '1');
 select mask_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_last_n(0),
+       mask_last_n(0, 0),
+       mask_last_n(0, 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
diff --git a/ql/src/test/queries/clientpositive/udf_mask_show_first_n.q b/ql/src/test/queries/clientpositive/udf_mask_show_first_n.q
index 1425a82..5c9274f 100644
--- a/ql/src/test/queries/clientpositive/udf_mask_show_first_n.q
+++ b/ql/src/test/queries/clientpositive/udf_mask_show_first_n.q
@@ -6,6 +6,9 @@ explain select mask_show_first_n('TestString-123', 4, 'X', 'x', '0', '1');
 select mask_show_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_first_n(0),
+       mask_show_first_n(0, 0),
+       mask_show_first_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
diff --git a/ql/src/test/queries/clientpositive/udf_mask_show_last_n.q b/ql/src/test/queries/clientpositive/udf_mask_show_last_n.q
index c4d15fb..7b0d24f 100644
--- a/ql/src/test/queries/clientpositive/udf_mask_show_last_n.q
+++ b/ql/src/test/queries/clientpositive/udf_mask_show_last_n.q
@@ -6,6 +6,9 @@ explain select mask_show_last_n('TestString-123', 4, 'X', 'x', '0', '1');
 select mask_show_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_last_n(0),
+       mask_show_last_n(0, 0),
+       mask_show_last_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
diff --git a/ql/src/test/results/clientpositive/udf_mask.q.out b/ql/src/test/results/clientpositive/udf_mask.q.out
index ed01449..f3a5f26 100644
--- a/ql/src/test/results/clientpositive/udf_mask.q.out
+++ b/ql/src/test/results/clientpositive/udf_mask.q.out
@@ -55,6 +55,10 @@ STAGE PLANS:
 PREHOOK: query: select mask('TestString-123', 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as varchar(24)), 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as char(24)), 'X', 'x', '0', ':'),
+       mask(cast(0 as tinyint), -1, -1, -1, -1, 4),
+       mask(cast(0 as smallint), -1, -1, -1, -1, 4),
+       mask(cast(0 as int), -1, -1, -1, -1, 4),
+       mask(cast(0 as bigint), -1, -1, -1, -1, 4),
        mask(cast(123 as tinyint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as smallint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as int), -1, -1, -1, -1, '5'),
@@ -73,6 +77,10 @@ PREHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: query: select mask('TestString-123', 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as varchar(24)), 'X', 'x', '0', ':'),
        mask(cast('TestString-123' as char(24)), 'X', 'x', '0', ':'),
+       mask(cast(0 as tinyint), -1, -1, -1, -1, 4),
+       mask(cast(0 as smallint), -1, -1, -1, -1, 4),
+       mask(cast(0 as int), -1, -1, -1, -1, 4),
+       mask(cast(0 as bigint), -1, -1, -1, -1, 4),
        mask(cast(123 as tinyint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as smallint), -1, -1, -1, -1, '5'),
        mask(cast(12345 as int), -1, -1, -1, -1, '5'),
@@ -88,4 +96,4 @@ POSTHOOK: query: select mask('TestString-123', 'X', 'x', '0', ':'),
 POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
-XxxxXxxxxx:000	XxxxXxxxxx:000	XxxxXxxxxx:000::::::::::                                                                                                                                                                                                                                       	43	-9981	55555	55555	0001-01-01	0001-01-20	0001-04-01	2016-01-01	2016-04-01	2016-01-20	0001-04-20	2016-04-20
+XxxxXxxxxx:000	XxxxXxxxxx:000	XxxxXxxxxx:000::::::::::                                                                                                                                                                                                                                       	4	4	4	4	43	-9981	55555	55555	0001-01-01	0001-01-20	0001-04-01	2016-01-01	2016-04-01	2016-01-20	0001-04-20	2016-04-20
diff --git a/ql/src/test/results/clientpositive/udf_mask_first_n.q.out b/ql/src/test/results/clientpositive/udf_mask_first_n.q.out
index e33fb42..107461b 100644
--- a/ql/src/test/results/clientpositive/udf_mask_first_n.q.out
+++ b/ql/src/test/results/clientpositive/udf_mask_first_n.q.out
@@ -52,6 +52,9 @@ STAGE PLANS:
 PREHOOK: query: select mask_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_first_n(0, 0),
+       mask_first_n(0, 1),
+       mask_first_n(0, 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -63,6 +66,9 @@ PREHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: query: select mask_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_first_n(0, 0),
+       mask_first_n(0, 1),
+       mask_first_n(0, 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -71,4 +77,4 @@ POSTHOOK: query: select mask_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
 POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
-XxxxString-123	XxxxString-123	XxxxString-123                                                                                                                                                                                                                                                 	43	-9981	55555	55555	0001-01-01
+XxxxString-123	XxxxString-123	XxxxString-123                                                                                                                                                                                                                                                 	0	1	5	43	-9981	55555	55555	0001-01-01
diff --git a/ql/src/test/results/clientpositive/udf_mask_last_n.q.out b/ql/src/test/results/clientpositive/udf_mask_last_n.q.out
index 07a254f..2119084 100644
--- a/ql/src/test/results/clientpositive/udf_mask_last_n.q.out
+++ b/ql/src/test/results/clientpositive/udf_mask_last_n.q.out
@@ -52,6 +52,9 @@ STAGE PLANS:
 PREHOOK: query: select mask_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_last_n(0),
+       mask_last_n(0, 0),
+       mask_last_n(0, 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -63,6 +66,9 @@ PREHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: query: select mask_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_last_n(0),
+       mask_last_n(0, 0),
+       mask_last_n(0, 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -71,4 +77,4 @@ POSTHOOK: query: select mask_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
 POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
-TestString:000	TestString:000	TestString-123      ::::                                                                                                                                                                                                                                       	43	15555	15555	15555	0001-01-01
+TestString:000	TestString:000	TestString-123      ::::                                                                                                                                                                                                                                       	1	0	5	43	15555	15555	15555	0001-01-01
diff --git a/ql/src/test/results/clientpositive/udf_mask_show_first_n.q.out b/ql/src/test/results/clientpositive/udf_mask_show_first_n.q.out
index 3ec3270..918c5b8 100644
--- a/ql/src/test/results/clientpositive/udf_mask_show_first_n.q.out
+++ b/ql/src/test/results/clientpositive/udf_mask_show_first_n.q.out
@@ -52,6 +52,9 @@ STAGE PLANS:
 PREHOOK: query: select mask_show_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_first_n(0),
+       mask_show_first_n(0, 0),
+       mask_show_first_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -63,6 +66,9 @@ PREHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: query: select mask_show_first_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_first_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_first_n(0),
+       mask_show_first_n(0, 0),
+       mask_show_first_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_first_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -71,4 +77,4 @@ POSTHOOK: query: select mask_show_first_n('TestString-123', 4, 'X', 'x', '0', ':
 POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
-TestXxxxxx:000	TestXxxxxx:000	TestXxxxxx:000::::::::::                                                                                                                                                                                                                                       	123	12345	12345	12345	0001-01-01
+TestXxxxxx:000	TestXxxxxx:000	TestXxxxxx:000::::::::::                                                                                                                                                                                                                                       	0	1	5	123	12345	12345	12345	0001-01-01
diff --git a/ql/src/test/results/clientpositive/udf_mask_show_last_n.q.out b/ql/src/test/results/clientpositive/udf_mask_show_last_n.q.out
index 4dd42fd..af06ba7 100644
--- a/ql/src/test/results/clientpositive/udf_mask_show_last_n.q.out
+++ b/ql/src/test/results/clientpositive/udf_mask_show_last_n.q.out
@@ -52,6 +52,9 @@ STAGE PLANS:
 PREHOOK: query: select mask_show_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_last_n(0),
+       mask_show_last_n(0, 0),
+       mask_show_last_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -63,6 +66,9 @@ PREHOOK: Input: _dummy_database@_dummy_table
 POSTHOOK: query: select mask_show_last_n('TestString-123', 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as varchar(24)), 4, 'X', 'x', '0', ':'),
        mask_show_last_n(cast('TestString-123' as char(24)), 4, 'X', 'x', '0', ':'),
+       mask_show_last_n(0),
+       mask_show_last_n(0, 0),
+       mask_show_last_n(0, 0, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(123 as tinyint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as smallint), 4, -1, -1, -1, -1, '5'),
        mask_show_last_n(cast(12345 as int), 4, -1, -1, -1, -1, '5'),
@@ -71,4 +77,4 @@ POSTHOOK: query: select mask_show_last_n('TestString-123', 4, 'X', 'x', '0', ':'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: _dummy_database@_dummy_table
 #### A masked pattern was here ####
-XxxxXxxxxx-123	XxxxXxxxxx-123	XxxxXxxxxx:000::::::                                                                                                                                                                                                                                           	123	-13191	52345	52345	0001-01-01
+XxxxXxxxxx-123	XxxxXxxxxx-123	XxxxXxxxxx:000::::::                                                                                                                                                                                                                                           	0	1	5	123	-13191	52345	52345	0001-01-01