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

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

commit a89489cbc8c8a4b4a9222e0de318ae0d0d8ad26e
Author: stiga-huang <huangquanl...@gmail.com>
AuthorDate: Mon Apr 6 11:26:27 2020 +0800

    IMPALA-9604: Add TPCH-nested tests for column masking
    
    Add tests for TPCH-nested queries with column masking policies on the
    PII columns (phone, name, address). Some queries have the same results
    as without the column masking policies so we reuse their test files.
    
    Change-Id: I4a6c9fc480923369952e8e215f4a90b2f6448028
    Reviewed-on: http://gerrit.cloudera.org:8080/15655
    Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
 .../queries/masked-tpch_nested-q10.test            |  58 ++++++++
 .../queries/masked-tpch_nested-q15.test            |  38 ++++++
 .../queries/masked-tpch_nested-q18.test            |  81 ++++++++++++
 .../tpch_nested/queries/masked-tpch_nested-q2.test | 147 +++++++++++++++++++++
 .../queries/masked-tpch_nested-q20.test            |  42 ++++++
 .../queries/masked-tpch_nested-q21.test            |  47 +++++++
 .../tpch_nested/queries/masked-tpch_nested-q9.test |  37 ++++++
 tests/authorization/test_ranger.py                 |  55 ++++++++
 8 files changed, 505 insertions(+)

diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q10.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q10.test
new file mode 100644
index 0000000..2da39ee
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q10.test
@@ -0,0 +1,58 @@
+====
+---- QUERY: TPCH-Q10
+# Q10 - Returned Item Reporting Query
+# Converted select from multiple tables to joins
+select
+  c_custkey,
+  c_name,
+  sum(l_extendedprice * (1 - l_discount)) as revenue,
+  c_acctbal,
+  n_name,
+  c_address,
+  c_phone,
+  c_comment
+from
+  customer c,
+  c.c_orders o,
+  o.o_lineitems l,
+  region.r_nations n
+where
+  o_orderdate >= '1993-10-01'
+  and o_orderdate < '1994-01-01'
+  and l_returnflag = 'R'
+  and c_nationkey = n_nationkey
+group by
+  c_custkey,
+  c_name,
+  c_acctbal,
+  c_phone,
+  n_name,
+  c_address,
+  c_comment
+order by
+  revenue desc
+limit 20
+---- RESULTS
+57040,'Xxxxxxxx#nnnnnnnnn',734235.2455,632.87,'JAPAN','Xxxxxxxnxx','22-8xx-xxx-xxxx','sits.
 slyly regular requests sleep alongside of the regular inst'
+143347,'Xxxxxxxx#nnnnnnnnn',721002.6948,2557.47,'EGYPT','nxXxXXx,Xxn','14-7xx-xxx-xxxx','ggle
 carefully enticing requests. final deposits use bold, bold pinto beans. 
ironic, idle re'
+60838,'Xxxxxxxx#nnnnnnnnn',679127.3077,2454.77,'BRAZIL','nnXxXnxXXXXXxXXxXxxxXxnXXxXX','12-9xx-xxx-xxxx','
 need to boost against the slyly regular account'
+101998,'Xxxxxxxx#nnnnnnnnn',637029.5667,3790.89,'UNITED 
KINGDOM','nnxnXXXxXxxXXXxXx','33-5xx-xxx-xxxx','ress foxes wake slyly after the 
bold excuses. ironic platelets are furiously carefully bold theodolites'
+125341,'Xxxxxxxx#nnnnnnnnn',633508.0860,4983.51,'GERMANY','XnnXXXnxxxXnXXxxXXxxxXxX','17-5xx-xxx-xxxx','arefully
 even depths. blithely even excuses sleep furiously. foxes use except the 
dependencies. ca'
+25501,'Xxxxxxxx#nnnnnnnnn',620269.7849,7725.04,'ETHIOPIA','  
XnnnXXxxxxXXXXxxXX,XxnXnXXXXxxXnXX','15-8xx-xxx-xxxx','he pending instructions 
wake carefully at the pinto beans. regular, final instructions along the slyly 
fina'
+115831,'Xxxxxxxx#nnnnnnnnn',596423.8672,5098.10,'FRANCE','xXxXxXXxx xx 
xxnxXnxXxxxxnxXnnxXnxxxXxXx','16-7xx-xxx-xxxx','l somas sleep. furiously final 
deposits wake blithely regular pinto b'
+84223,'Xxxxxxxx#nnnnnnnnn',594998.0239,528.65,'UNITED KINGDOM','xXXXXxnXxXxx 
xxXnnX nxXxxxnXXxxxxX','33-4xx-xxx-xxxx',' slyly final deposits haggle regular, 
pending dependencies. pending escapades wake '
+54289,'Xxxxxxxx#nnnnnnnnn',585603.3918,5583.02,'IRAN','xXXxxXxXnXxxnXXX 
,xxxxX','20-8xx-xxx-xxxx','ely special foxes are quickly finally ironic p'
+39922,'Xxxxxxxx#nnnnnnnnn',584878.1134,7321.11,'GERMANY','XxxnxnnxnXXXnxXXXXXnxnnnxXxnX','17-1xx-xxx-xxxx','y
 final requests. furiously final foxes cajole blithely special platelets. f'
+6226,'Xxxxxxxx#nnnnnnnnn',576783.7606,2230.09,'UNITED 
KINGDOM','nxXxn,XXXxxxXXnxxXXXXXXXXx,xxXnx,','33-6xx-xxx-xxxx','ending 
platelets along the express deposits cajole carefully final '
+922,'Xxxxxxxx#nnnnnnnnn',576767.5333,3869.25,'GERMANY','XxnXXxxxnXxXxxnxXXnXxXxXxxnxXxx','17-9xx-xxx-xxxx','luffily
 fluffy deposits. packages c'
+147946,'Xxxxxxxx#nnnnnnnnn',576455.1320,2030.13,'ALGERIA','xXXxXXxxxxxnXxxxnxXxXxxX','10-8xx-xxx-xxxx','ithely
 ironic deposits haggle blithely ironic requests. quickly regu'
+115640,'Xxxxxxxx#nnnnnnnnn',569341.1933,6436.10,'ARGENTINA','XxxxxxnxX 
nXxXxxxXnX','11-4xx-xxx-xxxx','ost slyly along the patterns; pinto be'
+73606,'Xxxxxxxx#nnnnnnnnn',568656.8578,1785.67,'JAPAN','xxXnXxxnxXxXxXXxxxxnxx','22-4xx-xxx-xxxx','he
 furiously regular ideas. slowly'
+110246,'Xxxxxxxx#nnnnnnnnn',566842.9815,7763.35,'VIETNAM','nXxxxxX 
XXXxnxXxX','31-9xx-xxx-xxxx','egular deposits serve blithely above the fl'
+142549,'Xxxxxxxx#nnnnnnnnn',563537.2368,5085.99,'INDONESIA','XxxXxXnnXxxxxXxxXXxnxXxxXxxxxn','19-9xx-xxx-xxxx','sleep
 pending courts. ironic deposits against the carefully unusual platelets cajole 
carefully express accounts.'
+146149,'Xxxxxxxx#nnnnnnnnn',557254.9865,1791.55,'ROMANIA','xnnxxxXXxX','29-7xx-xxx-xxxx','
 of the slyly silent accounts. quickly final accounts across the '
+52528,'Xxxxxxxx#nnnnnnnnn',556397.3509,551.79,'ARGENTINA','XXxxxXXXnnXXX','11-2xx-xxx-xxxx','
 deposits hinder. blithely pending asymptotes breach slyly regular re'
+23431,'Xxxxxxxx#nnnnnnnnn',554269.5360,3381.86,'ROMANIA','XxxXnxxxxxXxnxxxXxXxx','29-9xx-xxx-xxxx','nusual,
 even instructions: furiously stealthy n'
+---- TYPES
+bigint, string, decimal, decimal, string, string, string, string
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q15.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q15.test
new file mode 100644
index 0000000..387c342
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q15.test
@@ -0,0 +1,38 @@
+====
+---- QUERY: TPCH-Q15
+# Q15 - Top Supplier Query
+with revenue_view as (
+  select
+    l_suppkey as supplier_no,
+    sum(l_extendedprice * (1 - l_discount)) as total_revenue
+  from
+    customer.c_orders.o_lineitems l
+  where
+    l_shipdate >= '1996-01-01'
+    and l_shipdate < '1996-04-01'
+  group by
+    l_suppkey)
+select
+  s_suppkey,
+  s_name,
+  s_address,
+  s_phone,
+  total_revenue
+from
+  supplier,
+  revenue_view
+where
+  s_suppkey = supplier_no
+  and total_revenue = (
+    select
+      max(total_revenue)
+    from
+      revenue_view
+    )
+order by
+  s_suppkey
+---- RESULTS
+8449,'Xxxxxxxx#nnnnnnnnn','XxnnxxxnxXXxXxxxX','20-4xx-xxx-xxxx',1772627.2087
+---- TYPES
+BIGINT, STRING, STRING, STRING, DECIMAL
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q18.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q18.test
new file mode 100644
index 0000000..714e78e
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q18.test
@@ -0,0 +1,81 @@
+====
+---- QUERY: TPCH-Q18
+# Q18 - Large Value Customer Query
+select
+  c_name,
+  c_custkey,
+  o_orderkey,
+  o_orderdate,
+  o_totalprice,
+  sum_quantity
+from
+  customer c,
+  c.c_orders o,
+  (select sum(l_quantity) sum_quantity from o.o_lineitems) l
+where
+  sum_quantity > 300
+order by
+  o_totalprice desc,
+  o_orderdate
+limit 100
+---- RESULTS
+'Xxxxxxxx#nnnnnnnnn',128120,4722021,'1994-04-07',544089.09,323.00
+'Xxxxxxxx#nnnnnnnnn',144617,3043270,'1997-02-12',530604.44,317.00
+'Xxxxxxxx#nnnnnnnnn',13940,2232932,'1997-04-13',522720.61,304.00
+'Xxxxxxxx#nnnnnnnnn',66790,2199712,'1996-09-30',515531.82,327.00
+'Xxxxxxxx#nnnnnnnnn',46435,4745607,'1997-07-03',508047.99,309.00
+'Xxxxxxxx#nnnnnnnnn',15272,3883783,'1993-07-28',500241.33,302.00
+'Xxxxxxxx#nnnnnnnnn',146608,3342468,'1994-06-12',499794.58,303.00
+'Xxxxxxxx#nnnnnnnnn',96103,5984582,'1992-03-16',494398.79,312.00
+'Xxxxxxxx#nnnnnnnnn',24341,1474818,'1992-11-15',491348.26,302.00
+'Xxxxxxxx#nnnnnnnnn',137446,5489475,'1997-05-23',487763.25,311.00
+'Xxxxxxxx#nnnnnnnnn',107590,4267751,'1994-11-04',485141.38,301.00
+'Xxxxxxxx#nnnnnnnnn',50008,2366755,'1996-12-09',483891.26,302.00
+'Xxxxxxxx#nnnnnnnnn',15619,3767271,'1996-08-07',480083.96,318.00
+'Xxxxxxxx#nnnnnnnnn',77260,1436544,'1992-09-12',479499.43,307.00
+'Xxxxxxxx#nnnnnnnnn',109379,5746311,'1996-10-10',478064.11,302.00
+'Xxxxxxxx#nnnnnnnnn',54602,5832321,'1997-02-09',471220.08,307.00
+'Xxxxxxxx#nnnnnnnnn',105995,2096705,'1994-07-03',469692.58,307.00
+'Xxxxxxxx#nnnnnnnnn',148885,2942469,'1992-05-31',469630.44,313.00
+'Xxxxxxxx#nnnnnnnnn',114586,551136,'1993-05-19',469605.59,308.00
+'Xxxxxxxx#nnnnnnnnn',105260,5296167,'1996-09-06',469360.57,303.00
+'Xxxxxxxx#nnnnnnnnn',147197,1263015,'1997-02-02',467149.67,320.00
+'Xxxxxxxx#nnnnnnnnn',64483,2745894,'1996-07-04',466991.35,304.00
+'Xxxxxxxx#nnnnnnnnn',136573,2761378,'1996-05-31',461282.73,301.00
+'Xxxxxxxx#nnnnnnnnn',16384,502886,'1994-04-12',458378.92,312.00
+'Xxxxxxxx#nnnnnnnnn',117919,2869152,'1996-06-20',456815.92,317.00
+'Xxxxxxxx#nnnnnnnnn',12251,735366,'1993-11-24',455107.26,309.00
+'Xxxxxxxx#nnnnnnnnn',120098,1971680,'1995-06-14',453451.23,308.00
+'Xxxxxxxx#nnnnnnnnn',66098,5007490,'1992-08-07',453436.16,304.00
+'Xxxxxxxx#nnnnnnnnn',117076,4290656,'1997-02-05',449545.85,301.00
+'Xxxxxxxx#nnnnnnnnn',129379,4720454,'1997-06-07',448665.79,303.00
+'Xxxxxxxx#nnnnnnnnn',126865,4702759,'1994-11-07',447606.65,320.00
+'Xxxxxxxx#nnnnnnnnn',88876,983201,'1993-12-30',446717.46,304.00
+'Xxxxxxxx#nnnnnnnnn',36619,4806726,'1995-01-17',446704.09,328.00
+'Xxxxxxxx#nnnnnnnnn',141823,2806245,'1996-12-29',446269.12,310.00
+'Xxxxxxxx#nnnnnnnnn',53029,2662214,'1993-08-13',446144.49,302.00
+'Xxxxxxxx#nnnnnnnnn',18188,3037414,'1995-01-25',443807.22,308.00
+'Xxxxxxxx#nnnnnnnnn',66533,29158,'1995-10-21',443576.50,305.00
+'Xxxxxxxx#nnnnnnnnn',37729,4134341,'1995-06-29',441082.97,309.00
+'Xxxxxxxx#nnnnnnnnn',3566,2329187,'1998-01-04',439803.36,304.00
+'Xxxxxxxx#nnnnnnnnn',45538,4527553,'1994-05-22',436275.31,305.00
+'Xxxxxxxx#nnnnnnnnn',81581,4739650,'1995-11-04',435405.90,305.00
+'Xxxxxxxx#nnnnnnnnn',119989,1544643,'1997-09-20',434568.25,320.00
+'Xxxxxxxx#nnnnnnnnn',3680,3861123,'1998-07-03',433525.97,301.00
+'Xxxxxxxx#nnnnnnnnn',113131,967334,'1995-12-15',432957.75,301.00
+'Xxxxxxxx#nnnnnnnnn',141098,565574,'1995-09-24',430986.69,301.00
+'Xxxxxxxx#nnnnnnnnn',93392,5200102,'1997-01-22',425487.51,304.00
+'Xxxxxxxx#nnnnnnnnn',15631,1845057,'1994-05-12',419879.59,302.00
+'Xxxxxxxx#nnnnnnnnn',112987,4439686,'1996-09-17',418161.49,305.00
+'Xxxxxxxx#nnnnnnnnn',12599,4259524,'1998-02-12',415200.61,304.00
+'Xxxxxxxx#nnnnnnnnn',105410,4478371,'1996-03-05',412754.51,302.00
+'Xxxxxxxx#nnnnnnnnn',149842,5156581,'1994-05-30',411329.35,302.00
+'Xxxxxxxx#nnnnnnnnn',10129,5849444,'1994-03-21',409129.85,309.00
+'Xxxxxxxx#nnnnnnnnn',69904,1742403,'1996-10-19',408513.00,305.00
+'Xxxxxxxx#nnnnnnnnn',17746,6882,'1997-04-09',408446.93,303.00
+'Xxxxxxxx#nnnnnnnnn',13072,1481925,'1998-03-15',399195.47,301.00
+'Xxxxxxxx#nnnnnnnnn',82441,857959,'1994-02-07',382579.74,305.00
+'Xxxxxxxx#nnnnnnnnn',88703,2995076,'1994-01-30',363812.12,302.00
+---- TYPES
+STRING, BIGINT, BIGINT, STRING, DECIMAL, DECIMAL
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q2.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q2.test
new file mode 100644
index 0000000..e3f86ee
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q2.test
@@ -0,0 +1,147 @@
+====
+---- QUERY: TPCH-Q2
+# Q2 - Minimum Cost Supplier Query
+select
+  s_acctbal,
+  s_name,
+  n_name,
+  p_partkey,
+  p_mfgr,
+  s_address,
+  s_phone,
+  s_comment
+from
+  supplier s,
+  s.s_partsupps ps,
+  part p,
+  region r,
+  r.r_nations n
+where
+  p_partkey = ps_partkey
+  and p_size = 15
+  and p_type like '%BRASS'
+  and s_nationkey = n_nationkey
+  and r_name = 'EUROPE'
+  and ps_supplycost = (
+    select
+      min(ps_supplycost)
+    from
+      supplier s,
+      s.s_partsupps ps,
+      region r,
+      r.r_nations n
+    where
+      p_partkey = ps_partkey
+      and s_nationkey = n_nationkey
+      and r_name = 'EUROPE'
+    )
+order by
+  s_acctbal desc,
+  n_name,
+  s_name,
+  p_partkey
+limit 100
+---- RESULTS
+9938.53,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',185358,'Manufacturer#4','XXxXXx,xXXxxxnXXXXxXXxnn','33-4xx-xxx-xxxx','uriously
 regular requests hag'
+9937.84,'Xxxxxxxx#nnnnnnnnn','ROMANIA',108438,'Manufacturer#1','XXXXXXXXxx,xxxnnXxxnXXxnxxXxxxnXx','29-5xx-xxx-xxxx','efully
 express instructions. regular requests against the slyly fin'
+9936.22,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',249,'Manufacturer#4','XnxxxnxxXXxxnXxxnXX X','33-3xx-xxx-xxxx','etect 
about the furiously final accounts. slyly ironic pinto beans sleep inside the 
furiously'
+9923.77,'Xxxxxxxx#nnnnnnnnn','GERMANY',29821,'Manufacturer#4','xnXXnXxxXXXx','17-7xx-xxx-xxxx','ackages
 boost blithely. blithely regular deposits c'
+9871.22,'Xxxxxxxx#nnnnnnnnn','GERMANY',43868,'Manufacturer#5','XnxxXXxXxX','17-8xx-xxx-xxxx','etect
 blithely bold asymptotes. fluffily ironic platelets wake furiously; blit'
+9870.78,'Xxxxxxxx#nnnnnnnnn','GERMANY',81285,'Manufacturer#2','XXX,XnxxxXxnxXxxxnXxnxnXxXxnXXxxxxXXX','17-5xx-xxx-xxxx','
 regular accounts. furiously unusual courts above the fi'
+9870.78,'Xxxxxxxx#nnnnnnnnn','GERMANY',181285,'Manufacturer#4','XXX,XnxxxXxnxXxxxnXxnxnXxXxnXXxxxxXXX','17-5xx-xxx-xxxx','
 regular accounts. furiously unusual courts above the fi'
+9852.52,'Xxxxxxxx#nnnnnnnnn','RUSSIA',18972,'Manufacturer#2','xnXnnXxXXXXnx,XxnnxxXxXn','32-1xx-xxx-xxxx','rns
 wake final foxes. carefully unusual depende'
+9847.83,'Xxxxxxxx#nnnnnnnnn','RUSSIA',130557,'Manufacturer#2','xXxnnxxXnnXxxxXxX','32-3xx-xxx-xxxx','
 the special excuses. silent sentiments serve carefully final ac'
+9847.57,'Xxxxxxxx#nnnnnnnnn','FRANCE',86344,'Manufacturer#1','XXxnxxxnxXnnnxnxxnXxXXxxxXxXXXxXxXXXxx','16-8xx-xxx-xxxx','ges.
 slyly regular requests are. ruthless, express excuses cajole blithely across 
the unu'
+9847.57,'Xxxxxxxx#nnnnnnnnn','FRANCE',173827,'Manufacturer#2','XXxnxxxnxXnnnxnxxnXxXXxxxXxXXXxXxXXXxx','16-8xx-xxx-xxxx','ges.
 slyly regular requests are. ruthless, express excuses cajole blithely across 
the unu'
+9836.93,'Xxxxxxxx#nnnnnnnnn','RUSSIA',4841,'Manufacturer#4','XXxXnXn,nxxXXXXXx','32-3xx-xxx-xxxx','blithely
 carefully bold theodolites. fur'
+9817.10,'Xxxxxxxx#nnnnnnnnn','RUSSIA',124815,'Manufacturer#2','nXxxXXXxxxXxXXx 
XxxXxxXxnXnxXXx','32-5xx-xxx-xxxx','wake carefully alongside of the carefully 
final ex'
+9817.10,'Xxxxxxxx#nnnnnnnnn','RUSSIA',152351,'Manufacturer#3','nXxxXXXxxxXxXXx 
XxxXxxXxnXnxXXx','32-5xx-xxx-xxxx','wake carefully alongside of the carefully 
final ex'
+9739.86,'Xxxxxxxx#nnnnnnnnn','FRANCE',138357,'Manufacturer#2','x,XnxnXXxxxxX 
xnXnx nXnxxX,X','16-4xx-xxx-xxxx','s after the furiously bold packages sleep 
fluffily idly final requests: quickly final'
+9721.95,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',156241,'Manufacturer#3','XxxnXxXnxXn','33-8xx-xxx-xxxx','eep furiously 
sauternes; quickl'
+9681.33,'Xxxxxxxx#nnnnnnnnn','RUSSIA',78405,'Manufacturer#1',',xXxXxxxXx','32-1xx-xxx-xxxx','haggle
 slyly regular excuses. quic'
+9643.55,'Xxxxxxxx#nnnnnnnnn','ROMANIA',107617,'Manufacturer#1','xXnxxXXxxxnxnxnnx
 Xxnnn','29-2xx-xxx-xxxx','final excuses. final ideas boost quickly furiously 
speci'
+9624.82,'Xxxxxxxx#nnnnnnnnn','FRANCE',34306,'Manufacturer#3','xnxxxnnxXXXXxxXxxxxxXXxXxxXXxx','16-3xx-xxx-xxxx','e
 packages are around the special ideas. special, pending foxes us'
+9624.78,'Xxxxxxxx#nnnnnnnnn','ROMANIA',189657,'Manufacturer#1','xXnxXxXxXXnxxXxxxXxXXX,x','29-7xx-xxx-xxxx','ronic
 asymptotes wake bravely final'
+9612.94,'Xxxxxxxx#nnnnnnnnn','ROMANIA',120715,'Manufacturer#2','XXxxXXXnxXxnXXxxxxxnXxXXxx,xXX','29-3xx-xxx-xxxx','warhorses.
 quickly even deposits sublate daringly ironic instructions. slyly blithe t'
+9612.94,'Xxxxxxxx#nnnnnnnnn','ROMANIA',198189,'Manufacturer#4','XXxxXXXnxXxnXXxxxxxnXxXXxx,xXX','29-3xx-xxx-xxxx','warhorses.
 quickly even deposits sublate daringly ironic instructions. slyly blithe t'
+9571.83,'Xxxxxxxx#nnnnnnnnn','ROMANIA',179270,'Manufacturer#2','xXXXnXxXxxxxXXXXXnXx','29-9xx-xxx-xxxx','kly
 carefully express asymptotes. furiou'
+9558.10,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',88515,'Manufacturer#4','XXxxxxXxnnXXxXxXxxxxXXXxxXnxnxxxxXx','33-1xx-xxx-xxxx','
 foxes. quickly even excuses use. slyly special foxes nag bl'
+9492.79,'Xxxxxxxx#nnnnnnnnn','GERMANY',25974,'Manufacturer#5','XnxXxXXxnnxnxX','17-9xx-xxx-xxxx','arefully
 pending accounts. blithely regular excuses boost carefully carefully ironic p'
+9461.05,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',20033,'Manufacturer#1','nxxXxxxxX 
nXXnxXxxXxxxxxxxnxXxXxnXXX','33-5xx-xxx-xxxx','. slyly regular deposits wake 
slyly. furiously regular warthogs are.'
+9453.01,'Xxxxxxxx#nnnnnnnnn','ROMANIA',175767,'Manufacturer#1',',nXXXxnxxXXXxxXXxnXxnnXx','29-3xx-xxx-xxxx','gular
 frets. permanently special multipliers believe blithely alongs'
+9408.65,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',117771,'Manufacturer#4','XxXnXXX,xxxnxn','33-1xx-xxx-xxxx','nag 
against the final requests. furiously unusual packages cajole blit'
+9359.61,'Xxxxxxxx#nnnnnnnnn','ROMANIA',62349,'Manufacturer#5','XXxxxXnXx 
xxn','29-3xx-xxx-xxxx','y ironic theodolites. blithely sile'
+9357.45,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',138648,'Manufacturer#1','xnnn,xxXnxxXxnXx','33-5xx-xxx-xxxx','ously 
always regular packages. fluffily even accounts beneath the furiously final 
pack'
+9352.04,'Xxxxxxxx#nnnnnnnnn','GERMANY',170921,'Manufacturer#4','xXXXxxxXXxXXxxxX','17-1xx-xxx-xxxx','
 according to the carefully bold ideas'
+9312.97,'Xxxxxxxx#nnnnnnnnn','RUSSIA',90279,'Manufacturer#5','xXXXXXxnXXXXnXXxXXxXX','32-6xx-xxx-xxxx','ecial
 packages among the pending, even requests use regula'
+9312.97,'Xxxxxxxx#nnnnnnnnn','RUSSIA',100276,'Manufacturer#5','xXXXXXxnXXXXnXXxXXxXX','32-6xx-xxx-xxxx','ecial
 packages among the pending, even requests use regula'
+9280.27,'Xxxxxxxx#nnnnnnnnn','ROMANIA',47193,'Manufacturer#3','xxXXXxXXxXXxXXXXxXxx
 xxXXXxxX','29-3xx-xxx-xxxx','o beans haggle after the furiously unusual 
deposits. carefully silent dolphins cajole carefully'
+9274.80,'Xxxxxxxx#nnnnnnnnn','RUSSIA',76346,'Manufacturer#3','nxxXxXXXnXnxXnxXxxxx
 XXxxxxnXxXx','32-5xx-xxx-xxxx','y. courts do wake slyly. carefully ironic 
platelets haggle above the slyly regular the'
+9249.35,'Xxxxxxxx#nnnnnnnnn','FRANCE',26466,'Manufacturer#1','xnnXxXxXnXxnXxXXX,XXxnxXxxXXXxXXXXxXXXn','16-7xx-xxx-xxxx','uests
 are furiously. regular tithes through the regular, final accounts cajole 
furiously above the q'
+9249.35,'Xxxxxxxx#nnnnnnnnn','FRANCE',33972,'Manufacturer#1','xnnXxXxXnXxnXxXXX,XXxnxXxxXXXxXXXXxXXXn','16-7xx-xxx-xxxx','uests
 are furiously. regular tithes through the regular, final accounts cajole 
furiously above the q'
+9208.70,'Xxxxxxxx#nnnnnnnnn','ROMANIA',40256,'Manufacturer#5','xxxxxxx nxnX 
XxnxX','29-9xx-xxx-xxxx','lites was quickly above the furiously ironic 
requests. slyly even foxes against the blithely bold '
+9201.47,'Xxxxxxxx#nnnnnnnnn','UNITED KINGDOM',67183,'Manufacturer#5','XX 
XxXXxxxnxxxXxnXn','33-1xx-xxx-xxxx','e even, even foxes. blithely ironic 
packages cajole regular packages. slyly final ide'
+9192.10,'Xxxxxxxx#nnnnnnnnn','UNITED KINGDOM',85098,'Manufacturer#3','xX 
nxnxnXx,xXn,nXxXXXXXXXXXxxX','33-5xx-xxx-xxxx','es across the carefully express 
accounts boost caref'
+9189.98,'Xxxxxxxx#nnnnnnnnn','GERMANY',21225,'Manufacturer#4','xxXXxXxXxXxxXXxxx','17-7xx-xxx-xxxx','
 deposits. blithely bold excuses about the slyly bold forges wake '
+9128.97,'Xxxxxxxx#nnnnnnnnn','RUSSIA',146768,'Manufacturer#5','XnXxxXxnXXXXxnnnXxxXXn','32-1xx-xxx-xxxx','refully.
 blithely unusual asymptotes haggle '
+9104.83,'Xxxxxxxx#nnnnnnnnn','GERMANY',150974,'Manufacturer#4','XxXXXxXnXX Xn 
xnnxXn,n','17-7xx-xxx-xxxx','ly about the blithely ironic depths. slyly final 
theodolites among the fluffily bold ideas print'
+9101.00,'Xxxxxxxx#nnnnnnnnn','ROMANIA',128254,'Manufacturer#5','xxxnxXX,xxXXXXxx,XnXXXxXnxX
 xnnxXXxXXX','29-5xx-xxx-xxxx','ts. notornis detect blithely above the 
carefully bold requests. blithely even package'
+9094.57,'Xxxxxxxx#nnnnnnnnn','RUSSIA',39575,'Manufacturer#1','XXnXxXXXnx,xxX 
x,xnXXxxxxnXXXXxXxXXx','32-5xx-xxx-xxxx','jole. regular accounts sleep blithely 
frets. final pinto beans play furiously past the '
+8996.87,'Xxxxxxxx#nnnnnnnnn','FRANCE',102191,'Manufacturer#5','nXXxXXnnxxx','16-8xx-xxx-xxxx','ickly
 final packages along the express plat'
+8996.14,'Xxxxxxxx#nnnnnnnnn','ROMANIA',139813,'Manufacturer#2','xxnXnxxnnxXXnXXXxXxxXXXxXXXxXXxXXXxX','29-9xx-xxx-xxxx','
 dependencies boost quickly across the furiously pending requests! unusual 
dolphins play sl'
+8968.42,'Xxxxxxxx#nnnnnnnnn','ROMANIA',119999,'Manufacturer#5','xXXXXxxXxXnX 
XXXxxnnnXXXxXxXXXnx','29-5xx-xxx-xxxx','ly regular foxes boost slyly. quickly 
special waters boost carefully ironi'
+8936.82,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',109512,'Manufacturer#1','XXxxxxXXxXxxXXnXnXxXXxxXXxxxXXxXXx,nXx','33-7xx-xxx-xxxx','efully
 regular courts. furiousl'
+8929.42,'Xxxxxxxx#nnnnnnnnn','FRANCE',173735,'Manufacturer#4','XnxXnnXxXxXXXn 
XxxxxXx','16-2xx-xxx-xxxx','cajole furiously unusual requests. quickly stealthy 
requests are. '
+8920.59,'Xxxxxxxx#nnnnnnnnn','ROMANIA',26460,'Manufacturer#1','xXxXXxnnXXn','29-1xx-xxx-xxxx','aters.
 express, pending instructions sleep. brave, r'
+8920.59,'Xxxxxxxx#nnnnnnnnn','ROMANIA',173966,'Manufacturer#2','xXxXXxnnXXn','29-1xx-xxx-xxxx','aters.
 express, pending instructions sleep. brave, r'
+8913.96,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',137063,'Manufacturer#2','XXxxxXXxnx,xxXxxXXxXXXxnXnnXXxxxXn','33-7xx-xxx-xxxx','
 haggle slyly above the furiously regular pinto beans. even '
+8877.82,'Xxxxxxxx#nnnnnnnnn','FRANCE',167966,'Manufacturer#5','XnxxnXXXXnxxnX,xxxXxXXX','16-4xx-xxx-xxxx','ously
 foxes. express, ironic requests im'
+8862.24,'Xxxxxxxx#nnnnnnnnn','ROMANIA',73322,'Manufacturer#3','Xn 
xXxxXnXxXxxnXxX','29-7xx-xxx-xxxx','ly pending ideas sleep about the furiously 
unu'
+8841.59,'Xxxxxxxx#nnnnnnnnn','ROMANIA',100729,'Manufacturer#5','XxxnxXxxnxnnxxXXnxnnxXXnXxxXnxXX','29-3xx-xxx-xxxx','gainst
 the pinto beans. fluffily unusual dependencies affix slyly even deposits.'
+8781.71,'Xxxxxxxx#nnnnnnnnn','ROMANIA',13120,'Manufacturer#5','xXxXxxxnnnXXXxxXx,nnx,xx
 nXxXXXnXxxnxX','29-7xx-xxx-xxxx','s wake quickly ironic ideas'
+8754.24,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',179406,'Manufacturer#4','XXXXxxxXxxnX','33-9xx-xxx-xxxx','e ironic 
requests. carefully even foxes above the furious'
+8691.06,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',126892,'Manufacturer#2','x,XXxxnXxxXXnXnXxx,xXxx','33-9xx-xxx-xxxx','efully
 express deposits kindle after the deposits. final '
+8655.99,'Xxxxxxxx#nnnnnnnnn','RUSSIA',193810,'Manufacturer#2','XxxxxXXxnxxXxnxnXxXXXXXx
 xXnXnXxxnXx','32-5xx-xxx-xxxx','symptotes use about the express dolphins. 
requests use after the express platelets. final, ex'
+8638.36,'Xxxxxxxx#nnnnnnnnn','RUSSIA',75398,'Manufacturer#1','XxnxnxxxxnX','32-1xx-xxx-xxxx','ly
 quickly ironic requests. even requests whithout t'
+8638.36,'Xxxxxxxx#nnnnnnnnn','RUSSIA',170402,'Manufacturer#3','XxnxnxxxxnX','32-1xx-xxx-xxxx','ly
 quickly ironic requests. even requests whithout t'
+8607.69,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',76002,'Manufacturer#2','XXnxXXxXxxxxXnXXnnxXxXxxx,nnXnXxXXXxX','33-4xx-xxx-xxxx','ar,
 pending accounts. pending depende'
+8569.52,'Xxxxxxxx#nnnnnnnnn','RUSSIA',5935,'Manufacturer#5','xXxXXnxxxXXXnxxXXXxxxxxnxXnxnXX','32-6xx-xxx-xxxx','.
 regular foxes nag carefully atop the regular, silent deposits. quickly regular 
packages '
+8564.12,'Xxxxxxxx#nnnnnnnnn','GERMANY',110032,'Manufacturer#1','xxxXxXxnnnnXnXXxxXXnXxnXxxnxnXXnxnX','17-1xx-xxx-xxxx','n
 sauternes along the regular asymptotes are regularly along the '
+8553.82,'Xxxxxxxx#nnnnnnnnn','ROMANIA',143978,'Manufacturer#4','XxxXxXXxXXXnxxxxXXxnXXXxn
 XxxxXXnXXXX','29-1xx-xxx-xxxx','ic requests wake against the blithely unusual 
accounts. fluffily r'
+8517.23,'Xxxxxxxx#nnnnnnnnn','RUSSIA',37025,'Manufacturer#5','xnnXnxnXXXXnxXxx','32-5xx-xxx-xxxx','ove
 the even courts. furiously special platelets '
+8517.23,'Xxxxxxxx#nnnnnnnnn','RUSSIA',59528,'Manufacturer#2','xnnXnxnXXXXnxXxx','32-5xx-xxx-xxxx','ove
 the even courts. furiously special platelets '
+8503.70,'Xxxxxxxx#nnnnnnnnn','RUSSIA',44325,'Manufacturer#4','XXnXXXXXXXxxXxxxX
 nX','32-1xx-xxx-xxxx','pades cajole. furious packages among the carefully 
express excuses boost furiously across th'
+8457.09,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',19455,'Manufacturer#1','nXXxXxnxXnxXxXnXxnnnXXx','33-8xx-xxx-xxxx','cing
 requests along the furiously unusual deposits promise among the furiously unus'
+8441.40,'Xxxxxxxx#nnnnnnnnn','FRANCE',141302,'Manufacturer#2','xXnxxnxXnn','16-3xx-xxx-xxxx','ely
 even ideas. ideas wake slyly furiously unusual instructions. pinto beans sleep 
ag'
+8432.89,'Xxxxxxxx#nnnnnnnnn','RUSSIA',191470,'Manufacturer#1','xxxXXxnXXxxxXXXXXXnnXxxxxxXXXXxxxxXxnx','32-8xx-xxx-xxxx','ep
 furiously. packages should have to haggle slyly across the deposits. furiously 
regu'
+8431.40,'Xxxxxxxx#nnnnnnnnn','ROMANIA',5174,'Manufacturer#1','XXXXxXxnXnXXXXxxXxxxxXxxxxXnxxnx','29-4xx-xxx-xxxx','ithely
 express pinto beans. blithely even foxes haggle. furiously regular theodol'
+8407.04,'Xxxxxxxx#nnnnnnnnn','RUSSIA',162889,'Manufacturer#4','xn 
xXXnXXnXXnXxxXX','32-6xx-xxx-xxxx','r the blithely regular packages. slyly 
ironic theodoli'
+8386.08,'Xxxxxxxx#nnnnnnnnn','FRANCE',36014,'Manufacturer#3','nxxxxxXXxnxxXXXX,xnxXxXXxxXXXXXxXxXXxxXX','16-6xx-xxx-xxxx','blithely
 bold pains are carefully platelets. finally regular pinto beans sleep 
carefully special'
+8376.52,'Xxxxxxxx#nnnnnnnnn','UNITED KINGDOM',190267,'Manufacturer#5','nxnXn 
XxXXxxXXXxnXXxx,XXnxxXxnnxXXxxxXxn','33-6xx-xxx-xxxx','ly final accounts sleep 
special, regular requests. furiously regular'
+8348.74,'Xxxxxxxx#nnnnnnnnn','FRANCE',66344,'Manufacturer#4','xXxxnXxXxxxxn','16-7xx-xxx-xxxx','
 boldly final deposits. regular, even instructions detect slyly. fluffily 
unusual pinto bea'
+8338.58,'Xxxxxxxx#nnnnnnnnn','FRANCE',17268,'Manufacturer#4','XxxXXxXXXxxXnn,n','16-2xx-xxx-xxxx','iously
 final accounts. even pinto beans cajole slyly regular'
+8328.46,'Xxxxxxxx#nnnnnnnnn','ROMANIA',69237,'Manufacturer#5','xXxnxXnnxn,XXXxnx,xXxXnXxx,xxn','29-3xx-xxx-xxxx','ep
 carefully-- even, careful packages are slyly along t'
+8307.93,'Xxxxxxxx#nnnnnnnnn','GERMANY',18139,'Manufacturer#1','xxxxxXnxXXXxxXxX','17-5xx-xxx-xxxx','olites
 wake furiously regular decoys. final requests nod '
+8231.61,'Xxxxxxxx#nnnnnnnnn','RUSSIA',192000,'Manufacturer#2','xxxxxx,xXnxXXXXXnxX','32-7xx-xxx-xxxx','
 foxes according to the furi'
+8152.61,'Xxxxxxxx#nnnnnnnnn','ROMANIA',15227,'Manufacturer#4',' 
xxxXXXxXnxx','29-8xx-xxx-xxxx',' special requests. even, regular warhorses 
affix among the final gr'
+8109.09,'Xxxxxxxx#nnnnnnnnn','FRANCE',99185,'Manufacturer#1','xxxxxxXXxxxnxXXXxxxxxXXXXXx','16-6xx-xxx-xxxx','tions
 haggle slyly about the sil'
+8102.62,'Xxxxxxxx#nnnnnnnnn','UNITED KINGDOM',18344,'Manufacturer#5','x 
XxXXnXnnx','33-4xx-xxx-xxxx','egrate with the slyly bold instructions. special 
foxes haggle silently among the'
+8046.07,'Xxxxxxxx#nnnnnnnnn','FRANCE',191222,'Manufacturer#3','XxxxxXnXXnxxx 
,XxnXxx','16-4xx-xxx-xxxx','onic platelets cajole after the regular 
instructions. permanently bold excuses'
+8042.09,'Xxxxxxxx#nnnnnnnnn','RUSSIA',135705,'Manufacturer#4','XxnXxxnnxxxxXXnXxXxXxnxnxXXXnxnX','32-8xx-xxx-xxxx','osits.
 packages cajole slyly. furiously regular deposits cajole slyly. q'
+8042.09,'Xxxxxxxx#nnnnnnnnn','RUSSIA',150729,'Manufacturer#1','XxnXxxnnxxxxXXnXxXxXxnxnxXXXnxnX','32-8xx-xxx-xxxx','osits.
 packages cajole slyly. furiously regular deposits cajole slyly. q'
+7992.40,'Xxxxxxxx#nnnnnnnnn','FRANCE',118574,'Manufacturer#1','nxXxxxXXxXxxXxXXnxn','16-9xx-xxx-xxxx','
 ironic ideas? fluffily even instructions wake. blithel'
+7980.65,'Xxxxxxxx#nnnnnnnnn','FRANCE',13784,'Manufacturer#4','xX,nXxXXxXx','16-6xx-xxx-xxxx','ully
 bold courts. escapades nag slyly. furiously fluffy theodo'
+7950.37,'Xxxxxxxx#nnnnnnnnn','GERMANY',33094,'Manufacturer#5','xxXxXnXxxxxXxXXX
 XXxxXXXXxxnXXxxx','17-6xx-xxx-xxxx','arefully unusual requests x-ray above the 
quickly final deposits. '
+7937.93,'Xxxxxxxx#nnnnnnnnn','ROMANIA',83995,'Manufacturer#2','xXxXxxX,XxnxnxxXxxxXXxxxXxxxx','29-2xx-xxx-xxxx','to
 the blithely ironic deposits nag sly'
+7914.45,'Xxxxxxxx#nnnnnnnnn','RUSSIA',125988,'Manufacturer#2','xxXxxxxxnXXXxXXxxxXXXxXXnxXxX','32-1xx-xxx-xxxx','
 busily bold packages are dolphi'
+7912.91,'Xxxxxxxx#nnnnnnnnn','GERMANY',159180,'Manufacturer#5','nxXXXxxXxxn,xnnXXxxXx,nXXxXXXXXXX','17-2xx-xxx-xxxx','ay
 furiously regular platelets. cou'
+7912.91,'Xxxxxxxx#nnnnnnnnn','GERMANY',184210,'Manufacturer#4','nxXXXxxXxxn,xnnXXxxXx,nXXxXXXXXXX','17-2xx-xxx-xxxx','ay
 furiously regular platelets. cou'
+7894.56,'Xxxxxxxx#nnnnnnnnn','GERMANY',85472,'Manufacturer#4','XXXnnxXXXXxxXX','17-9xx-xxx-xxxx','ic
 platelets affix after the furiously'
+7887.08,'Xxxxxxxx#nnnnnnnnn','GERMANY',164759,'Manufacturer#3','XnnXXXxXxxXnxXXxXnXnxXX
 XnXxXnXnXxx','17-9xx-xxx-xxxx','ckly around the carefully fluffy theodolites. 
slyly ironic pack'
+7871.50,'Xxxxxxxx#nnnnnnnnn','RUSSIA',104695,'Manufacturer#1','nx 
xXXxxXxxXxXnnxxXXxxX','32-4xx-xxx-xxxx','ironic requests. furiously final 
theodolites cajole. final, express packages sleep. quickly reg'
+7852.45,'Xxxxxxxx#nnnnnnnnn','RUSSIA',8363,'Manufacturer#4','XXXxXXXxXXxnx,x','32-4xx-xxx-xxxx','usly
 unusual pinto beans. brave ideas sleep carefully quickly ironi'
+7850.66,'Xxxxxxxx#nnnnnnnnn','UNITED 
KINGDOM',86501,'Manufacturer#1','XXxxnXXxXXXXX','33-7xx-xxx-xxxx','ifts haggle 
fluffily pending pai'
+7843.52,'Xxxxxxxx#nnnnnnnnn','FRANCE',11680,'Manufacturer#4','nXnXXxxxnnXnnxXXxXXxxxXxxxXxx','16-4xx-xxx-xxxx','
 express, final pinto beans x-ray slyly asymptotes. unusual, unusual'
+---- TYPES
+DECIMAL, STRING, STRING, BIGINT, STRING, STRING, STRING, STRING
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q20.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q20.test
new file mode 100644
index 0000000..b78045f
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q20.test
@@ -0,0 +1,42 @@
+====
+---- QUERY: TPCH-Q20
+# Q20 - Potential Part Promotion Query
+# Note: Tricky rewrite from the original to avoid mixing
+# correlated and uncorrelated table refs in a subquery.
+# No results since "p_name" is masked. Predicate "p_name like 'forest%'"
+# chooses nothing
+select distinct
+  s_name,
+  s_address
+from
+  supplier s,
+  s.s_partsupps ps,
+  region.r_nations n
+where
+  ps_partkey in (
+      select
+        p_partkey
+      from
+        part p
+      where
+        p_name like 'forest%'
+  )
+  and ps_availqty > (
+      select
+        0.5 * sum(l_quantity)
+      from
+        customer.c_orders.o_lineitems l
+      where
+        l_partkey = ps_partkey
+        and l_suppkey = s_suppkey
+        and l_shipdate >= '1994-01-01'
+        and l_shipdate < '1995-01-01'
+  )
+  and s_nationkey = n_nationkey
+  and n_name = 'CANADA'
+order by
+  s_name
+---- RESULTS
+---- TYPES
+string, string
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q21.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q21.test
new file mode 100644
index 0000000..4323720
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q21.test
@@ -0,0 +1,47 @@
+====
+---- QUERY: TPCH-Q21
+# Q21 - Suppliers Who Kept Orders Waiting Query
+# Note: s_name is masked to 'Xxxxxxxx#nnnnnnnnn' for all rows.
+select
+  s_name,
+  count(*) as numwait
+from
+  supplier s,
+  customer c,
+  c.c_orders o,
+  o.o_lineitems l1,
+  region.r_nations n
+where
+  s_suppkey = l1.l_suppkey
+  and o_orderstatus = 'F'
+  and l1.l_receiptdate > l1.l_commitdate
+  and exists (
+    select
+      *
+    from
+      o.o_lineitems l2
+    where
+      l2.l_suppkey <> l1.l_suppkey
+  )
+  and not exists (
+    select
+      *
+    from
+      o.o_lineitems l3
+    where
+      l3.l_suppkey <> l1.l_suppkey
+      and l3.l_receiptdate > l3.l_commitdate
+  )
+  and s_nationkey = n_nationkey
+  and n_name = 'SAUDI ARABIA'
+group by
+  s_name
+order by
+  numwait desc,
+  s_name
+limit 100
+---- RESULTS
+'Xxxxxxxx#nnnnnnnnn',4141
+---- TYPES
+string, bigint
+====
diff --git a/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q9.test 
b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q9.test
new file mode 100644
index 0000000..822ad0e
--- /dev/null
+++ b/testdata/workloads/tpch_nested/queries/masked-tpch_nested-q9.test
@@ -0,0 +1,37 @@
+====
+---- QUERY: TPCH-Q9
+# Q9 - Product Type Measure Query
+# Note: no results since "p_name" is masked.
+select
+  nation,
+  o_year,
+  sum(amount) as sum_profit
+from(
+  select
+    n_name as nation,
+    year(o_orderdate) as o_year,
+    l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
+  from
+    customer.c_orders o,
+    o.o_lineitems l,
+    supplier s,
+    s.s_partsupps ps,
+    part p,
+    region.r_nations n
+  where
+    s_suppkey = l_suppkey
+    and ps_partkey = l_partkey
+    and p_partkey = l_partkey
+    and s_nationkey = n_nationkey
+    and p_name like '%green%'
+  ) as profit
+group by
+  nation,
+  o_year
+order by
+  nation,
+  o_year desc
+---- RESULTS
+---- TYPES
+STRING, INT, DECIMAL
+====
diff --git a/tests/authorization/test_ranger.py 
b/tests/authorization/test_ranger.py
index 3f9cddd..ac4d821 100644
--- a/tests/authorization/test_ranger.py
+++ b/tests/authorization/test_ranger.py
@@ -963,3 +963,58 @@ class TestRanger(CustomClusterTestSuite):
     finally:
       check_call([script])
       TestRanger._remove_column_masking_policy("col_mask_for_hive")
+
+
+class TestRangerColumnMaskingTpchNested(CustomClusterTestSuite):
+  """
+  Tests for Apache Ranger column masking policies on tpch nested tables.
+  """
+
+  @classmethod
+  def get_workload(cls):
+    return 'tpch_nested'
+
+  @classmethod
+  def add_custom_cluster_constraints(cls):
+    # Do not call the super() implementation because this class needs to relax 
the
+    # set of constraints.
+    cls.ImpalaTestMatrix.add_constraint(
+      lambda v: v.get_value('table_format').file_format == 'parquet')
+
+  @CustomClusterTestSuite.with_args(
+    impalad_args=IMPALAD_ARGS, catalogd_args=CATALOGD_ARGS)
+  def test_tpch_nested_column_masking(self, vector):
+    """Test column masking on nested tables"""
+    user = getuser()
+    db = "tpch_nested_parquet"
+    # Mask PII columns: name, phone, address
+    tbl_cols = {
+      "customer": ["c_name", "c_phone", "c_address"],
+      "supplier": ["s_name", "s_phone", "s_address"],
+      "part": ["p_name"],
+    }
+    # 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 tbl in tbl_cols:
+        for col in tbl_cols[tbl]:
+          policy_name = "%s_%s_mask" % (tbl, col)
+          # Q22 requires showing the first 2 chars of the phone column.
+          mask_type = "MASK_SHOW_FIRST_4" if col.endswith("phone") else "MASK"
+          TestRanger._add_column_masking_policy(
+            policy_name, user, db, tbl, col, mask_type)
+      self.execute_query_expect_success(admin_client, "refresh authorization",
+                                        user=ADMIN)
+      same_result_queries = ["q1", "q3", "q4", "q5", "q6", "q7", "q8", "q11", 
"q12",
+                             "q13", "q14", "q16", "q17", "q19", "q22"]
+      result_masked_queries = ["q9", "q10", "q15", "q18", "q20", "q21", "q2"]
+      for q in same_result_queries:
+        self.run_test_case("tpch_nested-" + q, vector, use_db=db)
+      for q in result_masked_queries:
+        self.run_test_case("masked-tpch_nested-" + q, vector, use_db=db)
+    finally:
+      for tbl in tbl_cols:
+        for col in tbl_cols[tbl]:
+          policy_name = "%s_%s_mask" % (tbl, col)
+          TestRanger._remove_column_masking_policy(policy_name)

Reply via email to