You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2021/01/15 23:35:14 UTC
[impala] branch master updated: IMPALA-10387: Add missing overloads
of mask functions used in Ranger default masking policies
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 9bb7157 IMPALA-10387: Add missing overloads of mask functions used in Ranger default masking policies
9bb7157 is described below
commit 9bb7157bf014282c95ab3e233b80d77e00c95b52
Author: stiga-huang <hu...@gmail.com>
AuthorDate: Thu Jan 7 16:13:12 2021 +0800
IMPALA-10387: Add missing overloads of mask functions used in Ranger default masking policies
The mask functions in Hive are implemented through GenericUDFs which can
accept an infinite number of function signatures. Impala currently don't
support GenericUDFs. So we provide builtin mask functions with limited
overloads.
This patch adds some missing overloads that could be used by Ranger
default masking policies, e.g. MASK_HASH, MASK_SHOW_LAST_4,
MASK_DATE_SHOW_YEAR, etc.
Tests:
- Add test coverage on all default masking policies applied on all
supported types.
Change-Id: Icf3e70fd7aa9f3b6d6b508b776696e61ec1fcc2e
Reviewed-on: http://gerrit.cloudera.org:8080/16930
Reviewed-by: Quanlong Huang <hu...@gmail.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/exprs/mask-functions-ir.cc | 59 ++++++++++++++++++++++
be/src/exprs/mask-functions.h | 38 ++++++++++++++
common/function-registry/impala_functions.py | 58 ++++++++++++++++++++-
.../queries/QueryTest/ranger_alltypes_mask.test | 58 +++++++++++++++++++++
.../ranger_alltypes_mask_date_show_year.test | 58 +++++++++++++++++++++
.../QueryTest/ranger_alltypes_mask_hash.test | 58 +++++++++++++++++++++
.../QueryTest/ranger_alltypes_mask_none.test | 58 +++++++++++++++++++++
.../QueryTest/ranger_alltypes_mask_null.test | 58 +++++++++++++++++++++
.../ranger_alltypes_mask_show_first_4.test | 58 +++++++++++++++++++++
.../ranger_alltypes_mask_show_last_4.test | 58 +++++++++++++++++++++
tests/authorization/test_ranger.py | 49 ++++++++++++++++++
11 files changed, 609 insertions(+), 1 deletion(-)
diff --git a/be/src/exprs/mask-functions-ir.cc b/be/src/exprs/mask-functions-ir.cc
index 6034501..2bbde4e 100644
--- a/be/src/exprs/mask-functions-ir.cc
+++ b/be/src/exprs/mask-functions-ir.cc
@@ -345,6 +345,15 @@ BigIntVal MaskFunctions::MaskShowFirstN(FunctionContext* ctx, const BigIntVal& v
return {MaskShowFirstNImpl(val, char_count.val, number_char.val)};
}
+DateVal MaskFunctions::MaskShowFirstN(FunctionContext* ctx, const DateVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char) {
+ // Currently we follow Hive's behavior to always mask date values to '0001-01-01'.
+ // TODO: Implement this after HIVE-24641 is resolved.
+ return Mask(ctx, val);
+}
+
/// MaskShowLastN overloads for string value
StringVal MaskFunctions::MaskShowLastN(FunctionContext* ctx, const StringVal& val) {
return MaskShowLastNImpl(ctx, val, CHAR_COUNT, MASKED_UPPERCASE, MASKED_LOWERCASE,
@@ -701,6 +710,36 @@ BigIntVal MaskFunctions::Mask(FunctionContext* ctx, const BigIntVal& val,
const IntVal& month_value, const IntVal& year_value) {
return {MaskShowFirstNImpl(val, 0, number_char.val)};
}
+BooleanVal MaskFunctions::Mask(FunctionContext* ctx, const BooleanVal& val) {
+ return BooleanVal::null();
+}
+BooleanVal MaskFunctions::Mask(FunctionContext* ctx, const BooleanVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value) {
+ return BooleanVal::null();
+}
+DoubleVal MaskFunctions::Mask(FunctionContext* ctx, const DoubleVal& val) {
+ return DoubleVal::null();
+}
+DoubleVal MaskFunctions::Mask(FunctionContext* ctx, const DoubleVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value) {
+ return DoubleVal::null();
+}
+TimestampVal MaskFunctions::Mask(FunctionContext* ctx, const TimestampVal& val) {
+ return TimestampVal::null();
+}
+TimestampVal MaskFunctions::Mask(FunctionContext* ctx, const TimestampVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value) {
+ return TimestampVal::null();
+}
StringVal MaskFunctions::MaskHash(FunctionContext* ctx, const StringVal& val) {
// Hive hash the value by sha256 and encoding it into a lower case hex string in
@@ -733,3 +772,23 @@ TimestampVal MaskFunctions::MaskHash(FunctionContext* ctx, const TimestampVal& v
DateVal MaskFunctions::MaskHash(FunctionContext* ctx, const DateVal& val) {
return DateVal::null();
}
+
+/// Nullify overloads for other types
+BooleanVal MaskFunctions::MaskNull(FunctionContext* ctx, const BooleanVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char) {
+ return BooleanVal::null();
+}
+DoubleVal MaskFunctions::MaskNull(FunctionContext* ctx, const DoubleVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char) {
+ return DoubleVal::null();
+}
+TimestampVal MaskFunctions::MaskNull(FunctionContext* ctx, const TimestampVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char) {
+ return TimestampVal::null();
+}
diff --git a/be/src/exprs/mask-functions.h b/be/src/exprs/mask-functions.h
index 0d3d830..c01aea7 100644
--- a/be/src/exprs/mask-functions.h
+++ b/be/src/exprs/mask-functions.h
@@ -121,6 +121,11 @@ class MaskFunctions {
static BigIntVal MaskShowFirstN(FunctionContext* ctx, const BigIntVal& val,
const IntVal& char_count, const IntVal& upper_char, const IntVal& lower_char,
const IntVal& digit_char, const IntVal& other_char, const IntVal& number_char);
+ /// Overload used by the default MASK_SHOW_FIRST_4 policy on date type
+ static DateVal MaskShowFirstN(FunctionContext* ctx, const DateVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char);
/// Declarations of mask_show_last_n()
/// Overloads for masking a string value
@@ -327,6 +332,25 @@ class MaskFunctions {
const IntVal& upper_char, const IntVal& lower_char, const IntVal& digit_char,
const IntVal& other_char, const IntVal& number_char, const IntVal& day_value,
const IntVal& month_value, const IntVal& year_value);
+ /// Other overloads
+ static BooleanVal Mask(FunctionContext* ctx, const BooleanVal& val);
+ static BooleanVal Mask(FunctionContext* ctx, const BooleanVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value);
+ static DoubleVal Mask(FunctionContext* ctx, const DoubleVal& val);
+ static DoubleVal Mask(FunctionContext* ctx, const DoubleVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value);
+ static TimestampVal Mask(FunctionContext* ctx, const TimestampVal& val);
+ static TimestampVal Mask(FunctionContext* ctx, const TimestampVal& val,
+ const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char, const IntVal& day_value, const IntVal& month_value,
+ const IntVal& year_value);
/// Declarations of mask_hash()
static StringVal MaskHash(FunctionContext* ctx, const StringVal& val);
@@ -335,6 +359,20 @@ class MaskFunctions {
static BooleanVal MaskHash(FunctionContext* ctx, const BooleanVal& val);
static TimestampVal MaskHash(FunctionContext* ctx, const TimestampVal& val);
static DateVal MaskHash(FunctionContext* ctx, const DateVal& val);
+
+ /// Nullify overloads
+ static BooleanVal MaskNull(FunctionContext* ctx, const BooleanVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char);
+ static DoubleVal MaskNull(FunctionContext* ctx, const DoubleVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char);
+ static TimestampVal MaskNull(FunctionContext* ctx, const TimestampVal& val,
+ const IntVal& char_count, const StringVal& upper_char, const StringVal& lower_char,
+ const StringVal& digit_char, const IntVal& other_char,
+ const StringVal& number_char);
};
} // namespace impala
diff --git a/common/function-registry/impala_functions.py b/common/function-registry/impala_functions.py
index a576854..77e057e 100644
--- a/common/function-registry/impala_functions.py
+++ b/common/function-registry/impala_functions.py
@@ -811,7 +811,7 @@ visible_functions = [
[['shiftright'], 'INT', ['INT', 'INT'], 'impala::BitByteFunctions::ShiftRight'],
[['shiftright'], 'BIGINT', ['BIGINT', 'INT'], 'impala::BitByteFunctions::ShiftRight'],
- # Mask functions
+ # Overloads of mask_show_first_n
[['mask_show_first_n'], 'STRING', ['STRING'], 'impala::MaskFunctions::MaskShowFirstN'],
[['mask_show_first_n'], 'STRING', ['STRING', 'INT'], 'impala::MaskFunctions::MaskShowFirstN'],
[['mask_show_first_n'], 'STRING', ['STRING', 'INT', 'STRING', 'STRING', 'STRING', 'STRING'],
@@ -830,6 +830,16 @@ visible_functions = [
'impala::MaskFunctions::MaskShowFirstN'],
[['mask_show_first_n'], 'BIGINT', ['BIGINT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT'],
'impala::MaskFunctions::MaskShowFirstN'],
+ [['mask_show_first_n'], 'DATE', ['DATE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskShowFirstN'],
+ # mask_show_first_n always return null for other types
+ [['mask_show_first_n'], 'BOOLEAN', ['BOOLEAN', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_show_first_n'], 'DOUBLE', ['DOUBLE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_show_first_n'], 'TIMESTAMP', ['TIMESTAMP', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ # Overloads of mask_show_last_n
[['mask_show_last_n'], 'STRING', ['STRING'], 'impala::MaskFunctions::MaskShowLastN'],
[['mask_show_last_n'], 'STRING', ['STRING', 'INT'], 'impala::MaskFunctions::MaskShowLastN'],
[['mask_show_last_n'], 'STRING', ['STRING', 'INT', 'STRING', 'STRING', 'STRING', 'STRING'],
@@ -848,6 +858,18 @@ visible_functions = [
'impala::MaskFunctions::MaskShowLastN'],
[['mask_show_last_n'], 'BIGINT', ['BIGINT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT'],
'impala::MaskFunctions::MaskShowLastN'],
+ # Reuse the implementation of mask_show_first_n on date type.
+ # TODO: implement this after HIVE-24641 is resolved.
+ [['mask_show_last_n'], 'DATE', ['DATE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskShowFirstN'],
+ # mask_show_last_n always return null for other types
+ [['mask_show_last_n'], 'BOOLEAN', ['BOOLEAN', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_show_last_n'], 'DOUBLE', ['DOUBLE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_show_last_n'], 'TIMESTAMP', ['TIMESTAMP', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ # Overloads of mask_first_n
[['mask_first_n'], 'STRING', ['STRING'], 'impala::MaskFunctions::MaskFirstN'],
[['mask_first_n'], 'STRING', ['STRING', 'INT'], 'impala::MaskFunctions::MaskFirstN'],
[['mask_first_n'], 'STRING', ['STRING', 'INT', 'STRING', 'STRING', 'STRING', 'STRING'],
@@ -866,6 +888,18 @@ visible_functions = [
'impala::MaskFunctions::MaskFirstN'],
[['mask_first_n'], 'BIGINT', ['BIGINT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT'],
'impala::MaskFunctions::MaskFirstN'],
+ # Reuse the implementation of mask_show_first_n on date type.
+ # TODO: implement this after HIVE-24641 is resolved.
+ [['mask_first_n'], 'DATE', ['DATE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskShowFirstN'],
+ # mask_first_n always return null for other types
+ [['mask_first_n'], 'BOOLEAN', ['BOOLEAN', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_first_n'], 'DOUBLE', ['DOUBLE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_first_n'], 'TIMESTAMP', ['TIMESTAMP', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ # Overloads of mask_last_n
[['mask_last_n'], 'STRING', ['STRING'], 'impala::MaskFunctions::MaskLastN'],
[['mask_last_n'], 'STRING', ['STRING', 'INT'], 'impala::MaskFunctions::MaskLastN'],
[['mask_last_n'], 'STRING', ['STRING', 'INT', 'STRING', 'STRING', 'STRING', 'STRING'],
@@ -884,6 +918,18 @@ visible_functions = [
'impala::MaskFunctions::MaskLastN'],
[['mask_last_n'], 'BIGINT', ['BIGINT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT'],
'impala::MaskFunctions::MaskLastN'],
+ # Reuse the implementation of mask_show_first_n on date type.
+ # TODO: implement this after HIVE-24641 is resolved.
+ [['mask_last_n'], 'DATE', ['DATE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskShowFirstN'],
+ # mask_last_n always return null for other types
+ [['mask_last_n'], 'BOOLEAN', ['BOOLEAN', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_last_n'], 'DOUBLE', ['DOUBLE', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ [['mask_last_n'], 'TIMESTAMP', ['TIMESTAMP', 'INT', 'STRING', 'STRING', 'STRING', 'INT', 'STRING'],
+ 'impala::MaskFunctions::MaskNull'],
+ # Overloads of mask
[['mask'], 'STRING', ['STRING'], 'impala::MaskFunctions::Mask'],
[['mask'], 'STRING', ['STRING', 'STRING', 'STRING', 'STRING', 'STRING'],
'impala::MaskFunctions::Mask'],
@@ -923,6 +969,16 @@ visible_functions = [
'impala::MaskFunctions::Mask'],
[['mask'], 'DATE', ['DATE', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT', 'INT'],
'impala::MaskFunctions::Mask'],
+ [['mask'], 'BOOLEAN', ['BOOLEAN'], 'impala::MaskFunctions::Mask'],
+ [['mask'], 'BOOLEAN', ['BOOLEAN', 'STRING', 'STRING', 'STRING', 'INT', 'STRING', 'INT', 'INT', 'INT'],
+ 'impala::MaskFunctions::Mask'],
+ [['mask'], 'DOUBLE', ['DOUBLE'], 'impala::MaskFunctions::Mask'],
+ [['mask'], 'DOUBLE', ['DOUBLE', 'STRING', 'STRING', 'STRING', 'INT', 'STRING', 'INT', 'INT', 'INT'],
+ 'impala::MaskFunctions::Mask'],
+ [['mask'], 'TIMESTAMP', ['TIMESTAMP'], 'impala::MaskFunctions::Mask'],
+ [['mask'], 'TIMESTAMP', ['TIMESTAMP', 'STRING', 'STRING', 'STRING', 'INT', 'STRING', 'INT', 'INT', 'INT'],
+ 'impala::MaskFunctions::Mask'],
+ # Overloads of mask_hash
[['mask_hash'], 'STRING', ['STRING'], 'impala::MaskFunctions::MaskHash'],
[['mask_hash'], 'BIGINT', ['BIGINT'], 'impala::MaskFunctions::MaskHash'],
[['mask_hash'], 'DOUBLE', ['DOUBLE'], 'impala::MaskFunctions::MaskHash'],
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask.test
new file mode 100644
index 0000000..2e59d6c
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,1,1,1,1,NULL,NULL,'nn/nn/nn','n',NULL,1111,1
+1,NULL,1,1,1,11,NULL,NULL,'nn/nn/nn','n',NULL,1111,1
+2,NULL,1,1,1,1,NULL,NULL,'nn/nn/nn','n',NULL,1111,2
+3,NULL,1,1,1,11,NULL,NULL,'nn/nn/nn','n',NULL,1111,2
+4,NULL,1,1,1,1,NULL,NULL,'nn/nn/nn','n',NULL,1111,3
+5,NULL,1,1,1,11,NULL,NULL,'nn/nn/nn','n',NULL,1111,3
+6,NULL,1,1,1,1,NULL,NULL,'nn/nn/nn','n',NULL,1111,4
+7,NULL,1,1,1,11,NULL,NULL,'nn/nn/nn','n',NULL,1111,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,0001-01-01,0001-01-01
+1,0001-01-01,0001-01-01
+2,0001-01-01,0001-01-01
+3,0001-01-01,0001-01-01
+4,0001-01-01,0001-01-01
+5,0001-01-01,0001-01-01
+6,NULL,0001-01-01
+10,0001-01-01,0001-01-01
+11,NULL,0001-01-01
+12,0001-01-01,0001-01-01
+20,0001-01-01,0001-01-01
+21,0001-01-01,0001-01-01
+22,0001-01-01,0001-01-01
+23,0001-01-01,0001-01-01
+24,0001-01-01,0001-01-01
+25,0001-01-01,0001-01-01
+26,0001-01-01,0001-01-01
+27,0001-01-01,0001-01-01
+28,0001-01-01,0001-01-01
+29,0001-01-01,0001-01-01
+30,0001-01-01,0001-01-01
+31,0001-01-01,0001-01-01
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'nxxxx','nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','nxxxx'
+'nxxxx','nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','nxxxxxx'
+'nxxx ','nxxxxx ','nxxx'
+'nxx ','nxxxx ','nxx'
+'nx ','nxxx ','nx'
+'NULL','NULL','NULL'
+'nx ','nx ','nx'
+'nx ','nx ','nx'
+'x ','x ','x'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_date_show_year.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_date_show_year.test
new file mode 100644
index 0000000..2926859
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_date_show_year.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,1,1,1,1,NULL,NULL,'xx/xx/xx','x',NULL,1111,1
+1,NULL,1,1,1,11,NULL,NULL,'xx/xx/xx','x',NULL,1111,1
+2,NULL,1,1,1,1,NULL,NULL,'xx/xx/xx','x',NULL,1111,2
+3,NULL,1,1,1,11,NULL,NULL,'xx/xx/xx','x',NULL,1111,2
+4,NULL,1,1,1,1,NULL,NULL,'xx/xx/xx','x',NULL,1111,3
+5,NULL,1,1,1,11,NULL,NULL,'xx/xx/xx','x',NULL,1111,3
+6,NULL,1,1,1,1,NULL,NULL,'xx/xx/xx','x',NULL,1111,4
+7,NULL,1,1,1,11,NULL,NULL,'xx/xx/xx','x',NULL,1111,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,0001-01-01,0001-01-01
+1,0001-01-01,0001-01-01
+2,0002-01-01,0001-01-01
+3,1399-01-01,0001-01-01
+4,2017-01-01,0001-01-01
+5,9999-01-01,0001-01-01
+6,NULL,0001-01-01
+10,2017-01-01,1399-01-01
+11,NULL,1399-01-01
+12,2018-01-01,1399-01-01
+20,0001-01-01,2017-01-01
+21,0001-01-01,2017-01-01
+22,0001-01-01,2017-01-01
+23,0001-01-01,2017-01-01
+24,0001-01-01,2017-01-01
+25,0001-01-01,2017-01-01
+26,0001-01-01,2017-01-01
+27,0001-01-01,2017-01-01
+28,0001-01-01,2017-01-01
+29,2017-01-01,2017-01-01
+30,9999-01-01,9999-01-01
+31,9999-01-01,9999-01-01
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'xxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','xxxxx'
+'xxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','xxxxxxx'
+'xxxx ','xxxxxx ','xxxx'
+'xxx ','xxxxx ','xxx'
+'xx ','xxxx ','xx'
+'NULL','NULL','NULL'
+'xx ','xx ','xx'
+'xx ','xx ','xx'
+'x ','x ','x'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_hash.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_hash.test
new file mode 100644
index 0000000..de5fd0e
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_hash.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'67dae49e6e99b74e95857579068fad1965ab1fca2835a838dbfa4179eed1a8c2','5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9',NULL,NULL,1
+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'67dae49e6e99b74e95857579068fad1965ab1fca2835a838dbfa4179eed1a8c2','6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b',NULL,NULL,1
+2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'d8b7b45719bfb8d67a3188961ef2a9b3080392c38ed0b2800d212448df85a2c0','5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9',NULL,NULL,2
+3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'d8b7b45719bfb8d67a3188961ef2a9b3080392c38ed0b2800d212448df85a2c0','6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b',NULL,NULL,2
+4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'13c344c063974ea1312cc9358700190b7951fe9ad04a5c124a94b99b46bf3b7b','5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9',NULL,NULL,3
+5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'13c344c063974ea1312cc9358700190b7951fe9ad04a5c124a94b99b46bf3b7b','6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b',NULL,NULL,3
+6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'ed904f5edfa43abef4b420d661af0321db4e1f149de01a769c46a7a5687ff7b8','5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9',NULL,NULL,4
+7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'ed904f5edfa43abef4b420d661af0321db4e1f149de01a769c46a7a5687ff7b8','6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b',NULL,NULL,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,NULL,NULL
+1,NULL,NULL
+2,NULL,NULL
+3,NULL,NULL
+4,NULL,NULL
+5,NULL,NULL
+6,NULL,NULL
+10,NULL,NULL
+11,NULL,NULL
+12,NULL,NULL
+20,NULL,NULL
+21,NULL,NULL
+22,NULL,NULL
+23,NULL,NULL
+24,NULL,NULL
+25,NULL,NULL
+26,NULL,NULL
+27,NULL,NULL
+28,NULL,NULL
+29,NULL,NULL
+30,NULL,NULL
+31,NULL,NULL
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'af872','13b612c1bbc6102a0c061e8ac26db661e6f2b0bcf8916d698f6a48f0584bc24b ','f4414d9d90ebd333d51355d1b987fb11'
+'f4f05','ded997a98d3dba01b80d96f599ccfc6e8734c4bfda95198ea7c05e3663563f3c ','d11f79239eb18fd3fc118590b6e41444'
+'4d365','ba1dcef5f745da23be43af751fc5561f2429120d44df70334554f758c4fd6800 ','a15f88c2af0897ddea9c81685d7fe968'
+'cb490','dee8fd648827dc7f24c21248d3f1ce633bccb1df34e93a2c32ddb14b55e2eff4 ','478117e90c2d2eb98aa8a200e97cc569'
+'90aaa','b2921214116ba777975a5d0285a941d0566c4901e86c53d315df6d612f34c306 ','f4df435df41a53e0ed8d0e16397d0287'
+'e3b0c','e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ','e3b0c44298fc1c149afbf4c8996fb924'
+'f6143','15d7b5a91472ed555dc4c442081a7d8a2fffd20f84856e9739127354edb9dfdb ','7356887119fd6ed53332f3e902cb547e'
+'f6143','15d7b5a91472ed555dc4c442081a7d8a2fffd20f84856e9739127354edb9dfdb ','7356887119fd6ed53332f3e902cb547e'
+'95e4a','c8fcce134c7d85f738457e0b1aa3b82090cb981de4ed54840a25e3e49a623900 ','2e7d2c03a9507ae265ecf5b5356885a5'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_none.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_none.test
new file mode 100644
index 0000000..ef8c72a
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_none.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,true,0,0,0,0,0,0,'01/01/09','0',2009-01-01 00:00:00,2009,1
+1,false,1,1,1,10,1.100000023841858,10.1,'01/01/09','1',2009-01-01 00:01:00,2009,1
+2,true,0,0,0,0,0,0,'02/01/09','0',2009-02-01 00:00:00,2009,2
+3,false,1,1,1,10,1.100000023841858,10.1,'02/01/09','1',2009-02-01 00:01:00,2009,2
+4,true,0,0,0,0,0,0,'03/01/09','0',2009-03-01 00:00:00,2009,3
+5,false,1,1,1,10,1.100000023841858,10.1,'03/01/09','1',2009-03-01 00:01:00,2009,3
+6,true,0,0,0,0,0,0,'04/01/09','0',2009-04-01 00:00:00,2009,4
+7,false,1,1,1,10,1.100000023841858,10.1,'04/01/09','1',2009-04-01 00:01:00,2009,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,0001-01-01,0001-01-01
+1,0001-12-31,0001-01-01
+2,0002-01-01,0001-01-01
+3,1399-12-31,0001-01-01
+4,2017-11-28,0001-01-01
+5,9999-12-31,0001-01-01
+6,NULL,0001-01-01
+10,2017-11-28,1399-06-27
+11,NULL,1399-06-27
+12,2018-12-31,1399-06-27
+20,0001-06-21,2017-11-27
+21,0001-06-22,2017-11-27
+22,0001-06-23,2017-11-27
+23,0001-06-24,2017-11-27
+24,0001-06-25,2017-11-27
+25,0001-06-26,2017-11-27
+26,0001-06-27,2017-11-27
+27,0001-06-28,2017-11-27
+28,0001-06-29,2017-11-27
+29,2017-11-28,2017-11-27
+30,9999-12-01,9999-12-31
+31,9999-12-31,9999-12-31
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'1aaaa','1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb','1cccc'
+'2aaaa','2bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb','2cccccc'
+'3aaa ','3bbbbb ','3ccc'
+'4aa ','4bbbb ','4cc'
+'5a ','5bbb ','5c'
+'NULL','NULL','NULL'
+'6a ','6b ','6c'
+'6a ','6b ','6c'
+'a ','b ','c'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_null.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_null.test
new file mode 100644
index 0000000..29cb94d
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_null.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,1
+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,1
+2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,2
+3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,2
+4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,3
+5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,3
+6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,4
+7,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'NULL','NULL',NULL,NULL,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,NULL,NULL
+1,NULL,NULL
+2,NULL,NULL
+3,NULL,NULL
+4,NULL,NULL
+5,NULL,NULL
+6,NULL,NULL
+10,NULL,NULL
+11,NULL,NULL
+12,NULL,NULL
+20,NULL,NULL
+21,NULL,NULL
+22,NULL,NULL
+23,NULL,NULL
+24,NULL,NULL
+25,NULL,NULL
+26,NULL,NULL
+27,NULL,NULL
+28,NULL,NULL
+29,NULL,NULL
+30,NULL,NULL
+31,NULL,NULL
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+'NULL','NULL','NULL'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_first_4.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_first_4.test
new file mode 100644
index 0000000..89818b2
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_first_4.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,0,0,0,0,NULL,NULL,'01/0x/xx','0',NULL,2009,1
+1,NULL,1,1,1,10,NULL,NULL,'01/0x/xx','1',NULL,2009,1
+2,NULL,0,0,0,0,NULL,NULL,'02/0x/xx','0',NULL,2009,2
+3,NULL,1,1,1,10,NULL,NULL,'02/0x/xx','1',NULL,2009,2
+4,NULL,0,0,0,0,NULL,NULL,'03/0x/xx','0',NULL,2009,3
+5,NULL,1,1,1,10,NULL,NULL,'03/0x/xx','1',NULL,2009,3
+6,NULL,0,0,0,0,NULL,NULL,'04/0x/xx','0',NULL,2009,4
+7,NULL,1,1,1,10,NULL,NULL,'04/0x/xx','1',NULL,2009,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,0001-01-01,0001-01-01
+1,0001-01-01,0001-01-01
+2,0001-01-01,0001-01-01
+3,0001-01-01,0001-01-01
+4,0001-01-01,0001-01-01
+5,0001-01-01,0001-01-01
+6,NULL,0001-01-01
+10,0001-01-01,0001-01-01
+11,NULL,0001-01-01
+12,0001-01-01,0001-01-01
+20,0001-01-01,0001-01-01
+21,0001-01-01,0001-01-01
+22,0001-01-01,0001-01-01
+23,0001-01-01,0001-01-01
+24,0001-01-01,0001-01-01
+25,0001-01-01,0001-01-01
+26,0001-01-01,0001-01-01
+27,0001-01-01,0001-01-01
+28,0001-01-01,0001-01-01
+29,0001-01-01,0001-01-01
+30,0001-01-01,0001-01-01
+31,0001-01-01,0001-01-01
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'1aaax','1bbbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','1cccx'
+'2aaax','2bbbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','2cccxxx'
+'3aaa ','3bbbxx ','3ccc'
+'4aa ','4bbbx ','4cc'
+'5a ','5bbb ','5c'
+'NULL','NULL','NULL'
+'6a ','6b ','6c'
+'6a ','6b ','6c'
+'a ','b ','c'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_last_4.test b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_last_4.test
new file mode 100644
index 0000000..6972996
--- /dev/null
+++ b/testdata/workloads/functional-query/queries/QueryTest/ranger_alltypes_mask_show_last_4.test
@@ -0,0 +1,58 @@
+====
+---- QUERY
+select * from functional.alltypestiny
+---- RESULTS
+0,NULL,0,0,0,0,NULL,NULL,'xx/x1/09','0',NULL,2009,1
+1,NULL,1,1,1,10,NULL,NULL,'xx/x1/09','1',NULL,2009,1
+2,NULL,0,0,0,0,NULL,NULL,'xx/x1/09','0',NULL,2009,2
+3,NULL,1,1,1,10,NULL,NULL,'xx/x1/09','1',NULL,2009,2
+4,NULL,0,0,0,0,NULL,NULL,'xx/x1/09','0',NULL,2009,3
+5,NULL,1,1,1,10,NULL,NULL,'xx/x1/09','1',NULL,2009,3
+6,NULL,0,0,0,0,NULL,NULL,'xx/x1/09','0',NULL,2009,4
+7,NULL,1,1,1,10,NULL,NULL,'xx/x1/09','1',NULL,2009,4
+---- TYPES
+INT,BOOLEAN,TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,STRING,STRING,TIMESTAMP,INT,INT
+====
+---- QUERY
+select * from functional.date_tbl
+---- RESULTS
+0,0001-01-01,0001-01-01
+1,0001-01-01,0001-01-01
+2,0001-01-01,0001-01-01
+3,0001-01-01,0001-01-01
+4,0001-01-01,0001-01-01
+5,0001-01-01,0001-01-01
+6,NULL,0001-01-01
+10,0001-01-01,0001-01-01
+11,NULL,0001-01-01
+12,0001-01-01,0001-01-01
+20,0001-01-01,0001-01-01
+21,0001-01-01,0001-01-01
+22,0001-01-01,0001-01-01
+23,0001-01-01,0001-01-01
+24,0001-01-01,0001-01-01
+25,0001-01-01,0001-01-01
+26,0001-01-01,0001-01-01
+27,0001-01-01,0001-01-01
+28,0001-01-01,0001-01-01
+29,0001-01-01,0001-01-01
+30,0001-01-01,0001-01-01
+31,0001-01-01,0001-01-01
+---- TYPES
+INT,DATE,DATE
+====
+---- QUERY
+select * from functional.chars_tiny
+---- RESULTS
+'xaaaa','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbbbb','xcccc'
+'xaaaa','xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbbbb','xxxcccc'
+'xaaa ','xxxxxx ','3ccc'
+'xaa ','xxxxx ','4cc'
+'xa ','xxxx ','5c'
+'NULL','NULL','NULL'
+'xa ','xx ','6c'
+'xa ','xx ','6c'
+'x ','x ','c'
+---- TYPES
+CHAR,CHAR,STRING
+====
diff --git a/tests/authorization/test_ranger.py b/tests/authorization/test_ranger.py
index b3052e0..74940e6 100644
--- a/tests/authorization/test_ranger.py
+++ b/tests/authorization/test_ranger.py
@@ -21,6 +21,7 @@ import os
import grp
import json
import pytest
+import logging
import requests
from subprocess import check_call
@@ -45,6 +46,9 @@ LOCAL_CATALOG_IMPALAD_ARGS = "--server-name=server1 --ranger_service_type=hive "
LOCAL_CATALOG_CATALOGD_ARGS = "--server-name=server1 --ranger_service_type=hive " \
"--ranger_app_id=impala --authorization_provider=ranger --catalog_topic_mode=minimal"
+LOG = logging.getLogger('impala_test_suite')
+
+
class TestRanger(CustomClusterTestSuite):
"""
Tests for Apache Ranger integration with Apache Impala.
@@ -995,6 +999,51 @@ class TestRanger(CustomClusterTestSuite):
TestRanger._remove_column_masking_policy(unique_name + str(i))
@pytest.mark.execute_serially
+ @CustomClusterTestSuite.with_args(
+ impalad_args=IMPALAD_ARGS, catalogd_args=CATALOGD_ARGS)
+ def test_masking_overload_coverage(self, vector, unique_name):
+ """Test that we have cover all the overloads of the masking functions that could
+ appear in using default policies."""
+ user = getuser()
+ policy_names = []
+ # Create another client for admin user since current user doesn't have privileges to
+ # create/drop databases or refresh authorization.
+ admin_client = self.create_impala_client()
+ try:
+ for mask_type in ["MASK", "MASK_SHOW_LAST_4", "MASK_SHOW_FIRST_4", "MASK_HASH",
+ "MASK_NULL", "MASK_NONE", "MASK_DATE_SHOW_YEAR"]:
+ LOG.info("Testing default mask type " + mask_type)
+ # Add masking policies on functional.alltypestiny
+ for col in ["bool_col", "tinyint_col", "smallint_col", "int_col", "bigint_col",
+ "float_col", "double_col", "date_string_col", "string_col",
+ "timestamp_col", "year"]:
+ policy_name = "_".join((unique_name, col, mask_type))
+ TestRanger._add_column_masking_policy(
+ policy_name, user, "functional", "alltypestiny", col, mask_type)
+ policy_names.append(policy_name)
+ # Add masking policies on functional.date_tbl
+ for col in ["date_col", "date_part"]:
+ policy_name = "_".join((unique_name, col, mask_type))
+ TestRanger._add_column_masking_policy(
+ policy_name, user, "functional", "date_tbl", col, mask_type)
+ policy_names.append(policy_name)
+ # Add masking policies on functional.chars_tiny
+ for col in ["cs", "cl", "vc"]:
+ policy_name = "_".join((unique_name, col, mask_type))
+ TestRanger._add_column_masking_policy(
+ policy_name, user, "functional", "chars_tiny", col, mask_type)
+ policy_names.append(policy_name)
+
+ self.execute_query_expect_success(admin_client, "refresh authorization",
+ user=ADMIN)
+ self.run_test_case("QueryTest/ranger_alltypes_" + mask_type.lower(), vector)
+ while policy_names:
+ TestRanger._remove_column_masking_policy(policy_names.pop())
+ finally:
+ while policy_names:
+ TestRanger._remove_column_masking_policy(policy_names.pop())
+
+ @pytest.mark.execute_serially
@SkipIfABFS.hive
@SkipIfADLS.hive
@SkipIfIsilon.hive