http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/queries/clientpositive/materialized_view_authorization_sqlstd.q
----------------------------------------------------------------------
diff --git 
a/ql/src/test/queries/clientpositive/materialized_view_authorization_sqlstd.q 
b/ql/src/test/queries/clientpositive/materialized_view_authorization_sqlstd.q
new file mode 100644
index 0000000..87a53e9
--- /dev/null
+++ 
b/ql/src/test/queries/clientpositive/materialized_view_authorization_sqlstd.q
@@ -0,0 +1,58 @@
+set hive.test.authz.sstd.hs2.mode=true;
+set 
hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest;
+set 
hive.security.authenticator.manager=org.apache.hadoop.hive.ql.security.SessionStateConfigUserAuthenticator;
+set hive.security.authorization.enabled=true;
+set user.name=user1;
+
+create table amvs_table (a int, b varchar(256), c decimal(10,2));
+
+insert into amvs_table values (1, 'alfred', 10.30),(2, 'bob', 3.14),(2, 
'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8);
+
+create materialized view amvs_mat_view as select a, c from amvs_table;
+
+show grant user user1 on table amvs_mat_view;
+
+grant select on amvs_mat_view to user user2;
+
+set user.name=user2;
+show grant user user2 on table amvs_mat_view;
+select * from amvs_mat_view;
+
+set user.name=user3;
+show grant user user3 on table amvs_mat_view;
+
+
+set user.name=hive_admin_user;
+set role admin;
+show grant on table amvs_mat_view;
+
+set user.name=user1;
+revoke select on table amvs_mat_view from user user2;
+set user.name=user2;
+show grant user user2 on table amvs_mat_view;
+
+set user.name=hive_admin_user;
+set role ADMIN;
+create role role_v;
+grant  role_v to user user4 ;
+show role grant user user4;
+show roles;
+
+grant all on table amvs_mat_view to role role_v;
+show grant role role_v on table amvs_mat_view;
+show grant user user4 on table amvs_mat_view;
+select * from amvs_mat_view;
+
+set user.name=user1;
+alter materialized view amvs_mat_view rebuild;
+
+grant select on table amvs_table to user user2 with grant option;
+set user.name=user2;
+create materialized view amvs_mat_view2 as select a, b from amvs_table;
+
+select * from amvs_mat_view2;
+
+drop materialized view amvs_mat_view2;
+
+set user.name=hive_admin_user;
+set role ADMIN;

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/queries/clientpositive/materialized_view_create.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/materialized_view_create.q 
b/ql/src/test/queries/clientpositive/materialized_view_create.q
new file mode 100644
index 0000000..57f8bb7
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/materialized_view_create.q
@@ -0,0 +1,31 @@
+create table cmv_basetable (a int, b varchar(256), c decimal(10,2));
+
+insert into cmv_basetable values (1, 'alfred', 10.30),(2, 'bob', 3.14),(2, 
'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8);
+
+create materialized view cmv_mat_view as select a, b, c from cmv_basetable;
+
+select * from cmv_mat_view;
+
+create materialized view if not exists cmv_mat_view2 as select a, c from 
cmv_basetable;
+
+select * from cmv_mat_view2;
+
+create materialized view if not exists cmv_mat_view3 as select * from 
cmv_basetable where a > 1;
+
+select * from cmv_mat_view3;
+
+create materialized view cmv_mat_view4 comment 'this is a comment' as select 
a, sum(c) from cmv_basetable group by a;
+
+select * from cmv_mat_view4;
+
+describe extended cmv_mat_view4;
+
+create table cmv_basetable2 (d int, e varchar(256), f decimal(10,2));
+
+insert into cmv_basetable2 values (4, 'alfred', 100.30),(4, 'bob', 
6133,14),(5, 'bonnie', 172.2),(6, 'calvin', 8.76),(17, 'charlie', 13144339.8);
+
+create materialized view cmv_mat_view5 tblproperties ('key'='value') as select 
a, b, d, c, f from cmv_basetable t1 join cmv_basetable2 t2 on (t1.b = t2.e);
+
+select * from cmv_mat_view5;
+
+show tblproperties cmv_mat_view5;

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/queries/clientpositive/materialized_view_drop.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/materialized_view_drop.q 
b/ql/src/test/queries/clientpositive/materialized_view_drop.q
new file mode 100644
index 0000000..8897159
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/materialized_view_drop.q
@@ -0,0 +1,7 @@
+create materialized view dmv_mat_view as select cint, cstring1 from 
alltypesorc where cint < 0;
+
+show table extended like dmv_mat_view;
+
+drop materialized view dmv_mat_view;
+
+show table extended like dmv_mat_view;

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/queries/clientpositive/materialized_view_rebuild.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/materialized_view_rebuild.q 
b/ql/src/test/queries/clientpositive/materialized_view_rebuild.q
new file mode 100644
index 0000000..c0a5530
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/materialized_view_rebuild.q
@@ -0,0 +1,13 @@
+create table rmv_table (cint int, cstring1 string);
+
+insert into rmv_table values(1, 'fred'), (10, 'wilma');
+
+create materialized view rmv_mat_view as select cint, cstring1 from rmv_table 
where cint < 10;
+
+select * from rmv_mat_view;
+
+insert into rmv_table values(2, 'barney'), (11, 'betty');
+
+alter materialized view rmv_mat_view rebuild;
+
+select * from rmv_mat_view;

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/queries/clientpositive/view_authorization_sqlstd.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/view_authorization_sqlstd.q 
b/ql/src/test/queries/clientpositive/view_authorization_sqlstd.q
new file mode 100644
index 0000000..64c5520
--- /dev/null
+++ b/ql/src/test/queries/clientpositive/view_authorization_sqlstd.q
@@ -0,0 +1,89 @@
+set hive.test.authz.sstd.hs2.mode=true;
+set 
hive.security.authorization.manager=org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactoryForTest;
+set 
hive.security.authenticator.manager=org.apache.hadoop.hive.ql.security.SessionStateConfigUserAuthenticator;
+set hive.security.authorization.enabled=true;
+set user.name=user1;
+
+-- Test view authorization , and 'show grant' variants
+
+create table t1(i int, j int, k int);
+grant select on t1 to user user2 with grant option;
+show grant user user1 on table t1;
+
+-- protecting certain columns
+create view vt1 as select i,k from t1;
+
+-- protecting certain rows
+create view vt2 as select * from t1 where i > 1;
+
+show grant user user1 on all;
+
+--view grant to user
+-- try with and without table keyword
+
+grant select on vt1 to user user2;
+grant insert on table vt1 to user user3;
+
+set user.name=user2;
+show grant user user2 on table vt1;
+create view vt3 as select i,k from t1;
+
+set user.name=user3;
+show grant user user3 on table vt1;
+
+
+set user.name=user2;
+
+explain authorization select * from vt1;
+select * from vt1;
+
+-- verify input objects required does not include table
+-- even if view is within a sub query
+select * from (select * from vt1) a;
+
+select * from vt1 union all select * from vt1;
+
+set user.name=user1;
+
+grant all on table vt2 to user user2;
+
+set user.name=user2;
+show grant user user2 on table vt2;
+show grant user user2 on all;
+set user.name=user1;
+
+revoke all on vt2 from user user2;
+
+set user.name=user2;
+show grant user user2 on table vt2;
+
+
+set user.name=hive_admin_user;
+set role admin;
+show grant on table vt2;
+
+set user.name=user1;
+revoke select on table vt1 from user user2;
+
+set user.name=user2;
+show grant user user2 on table vt1;
+show grant user user2 on all;
+
+set user.name=user3;
+-- grant privileges on roles for view, after next statement
+show grant user user3 on table vt1;
+
+set user.name=hive_admin_user;
+show current roles;
+set role ADMIN;
+create role role_v;
+grant  role_v to user user4 ;
+show role grant user user4;
+show roles;
+
+grant all on table vt2 to role role_v;
+show grant role role_v on table vt2;
+
+revoke delete on table vt2 from role role_v;
+show grant role role_v on table vt2;
+show grant on table vt2;

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_grant.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_grant.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_grant.q.out
new file mode 100644
index 0000000..8c6da0d
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_grant.q.out
@@ -0,0 +1,26 @@
+PREHOOK: query: create table amvcng_gtable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvcng_gtable
+POSTHOOK: query: create table amvcng_gtable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvcng_gtable
+PREHOOK: query: insert into amvcng_gtable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvcng_gtable
+POSTHOOK: query: insert into amvcng_gtable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvcng_gtable
+POSTHOOK: Lineage: amvcng_gtable.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvcng_gtable.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvcng_gtable.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: grant select on table amvcng_gtable to user user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@amvcng_gtable
+POSTHOOK: query: grant select on table amvcng_gtable to user user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@amvcng_gtable
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation 
CREATE_MATERIALIZED_VIEW [[SELECT with grant] on Object [type=TABLE_OR_VIEW, 
name=default.amvcng_gtable]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_select_perm.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_select_perm.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_select_perm.q.out
new file mode 100644
index 0000000..67d3474
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_create_no_select_perm.q.out
@@ -0,0 +1,20 @@
+PREHOOK: query: create table amvnsp_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvnsp_table
+POSTHOOK: query: create table amvnsp_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvnsp_table
+PREHOOK: query: insert into amvnsp_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvnsp_table
+POSTHOOK: query: insert into amvnsp_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvnsp_table
+POSTHOOK: Lineage: amvnsp_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvnsp_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvnsp_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation 
CREATE_MATERIALIZED_VIEW [[SELECT with grant] on Object [type=TABLE_OR_VIEW, 
name=default.amvnsp_table]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_drop_other.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_drop_other.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_drop_other.q.out
new file mode 100644
index 0000000..d1aff33
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_drop_other.q.out
@@ -0,0 +1,30 @@
+PREHOOK: query: create table amvdo_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvdo_table
+POSTHOOK: query: create table amvdo_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvdo_table
+PREHOOK: query: insert into amvdo_table values (1, 'alfred', 10.30),(2, 'bob', 
3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvdo_table
+POSTHOOK: query: insert into amvdo_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvdo_table
+POSTHOOK: Lineage: amvdo_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvdo_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvdo_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view amvdo_mat_view as select a, c from 
amvdo_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvdo_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvdo_mat_view
+POSTHOOK: query: create materialized view amvdo_mat_view as select a, c from 
amvdo_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvdo_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvdo_mat_view
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation DROPTABLE [[OBJECT 
OWNERSHIP] on Object [type=TABLE_OR_VIEW, name=default.amvdo_mat_view]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_no_select_perm.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_no_select_perm.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_no_select_perm.q.out
new file mode 100644
index 0000000..a3a3405
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_no_select_perm.q.out
@@ -0,0 +1,30 @@
+PREHOOK: query: create table amvnsp_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvnsp_table
+POSTHOOK: query: create table amvnsp_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvnsp_table
+PREHOOK: query: insert into amvnsp_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvnsp_table
+POSTHOOK: query: insert into amvnsp_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvnsp_table
+POSTHOOK: Lineage: amvnsp_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvnsp_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvnsp_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view amvnsp_mat_view as select a, c from 
amvnsp_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvnsp_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvnsp_mat_view
+POSTHOOK: query: create materialized view amvnsp_mat_view as select a, c from 
amvnsp_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvnsp_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvnsp_mat_view
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation QUERY [[SELECT] on 
Object [type=TABLE_OR_VIEW, name=default.amvnsp_mat_view]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_no_grant.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_no_grant.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_no_grant.q.out
new file mode 100644
index 0000000..dc7a58d
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_no_grant.q.out
@@ -0,0 +1,42 @@
+PREHOOK: query: create table amvrng_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvrng_table
+POSTHOOK: query: create table amvrng_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvrng_table
+PREHOOK: query: insert into amvrng_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvrng_table
+POSTHOOK: query: insert into amvrng_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvrng_table
+POSTHOOK: Lineage: amvrng_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvrng_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvrng_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: grant select on table amvrng_table to user user2 with grant 
option
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@amvrng_table
+POSTHOOK: query: grant select on table amvrng_table to user user2 with grant 
option
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@amvrng_table
+PREHOOK: query: create materialized view amvrng_mat_view as select a, c from 
amvrng_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvrng_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvrng_mat_view
+POSTHOOK: query: create materialized view amvrng_mat_view as select a, c from 
amvrng_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvrng_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvrng_mat_view
+PREHOOK: query: revoke grant option for select on table amvrng_table from user 
user2
+PREHOOK: type: REVOKE_PRIVILEGE
+PREHOOK: Output: default@amvrng_table
+POSTHOOK: query: revoke grant option for select on table amvrng_table from 
user user2
+POSTHOOK: type: REVOKE_PRIVILEGE
+POSTHOOK: Output: default@amvrng_table
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation 
CREATE_MATERIALIZED_VIEW [[SELECT with grant] on Object [type=TABLE_OR_VIEW, 
name=default.amvrng_table]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_other.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_other.q.out
 
b/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_other.q.out
new file mode 100644
index 0000000..9c25b52
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_authorization_rebuild_other.q.out
@@ -0,0 +1,30 @@
+PREHOOK: query: create table amvro_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvro_table
+POSTHOOK: query: create table amvro_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvro_table
+PREHOOK: query: insert into amvro_table values (1, 'alfred', 10.30),(2, 'bob', 
3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvro_table
+POSTHOOK: query: insert into amvro_table values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvro_table
+POSTHOOK: Lineage: amvro_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvro_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvro_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view amvro_mat_view as select a, c from 
amvro_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvro_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvro_mat_view
+POSTHOOK: query: create materialized view amvro_mat_view as select a, c from 
amvro_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvro_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvro_mat_view
+FAILED: HiveAccessControlException Permission denied: Principal [name=user2, 
type=USER] does not have following privileges for operation 
CREATE_MATERIALIZED_VIEW [[SELECT with grant] on Object [type=TABLE_OR_VIEW, 
name=default.amvro_table]]

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_delete.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/materialized_view_delete.q.out 
b/ql/src/test/results/clientnegative/materialized_view_delete.q.out
new file mode 100644
index 0000000..6013e1c
--- /dev/null
+++ b/ql/src/test/results/clientnegative/materialized_view_delete.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table dmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@dmv_basetable
+POSTHOOK: query: create table dmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@dmv_basetable
+PREHOOK: query: create materialized view dmv_mat_view as select a, b, c from 
dmv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@dmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@dmv_mat_view
+POSTHOOK: query: create materialized view dmv_mat_view as select a, b, c from 
dmv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@dmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@dmv_mat_view
+FAILED: SemanticException [Error 10304]: You cannot update or delete records 
in a view

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_insert.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/materialized_view_insert.q.out 
b/ql/src/test/results/clientnegative/materialized_view_insert.q.out
new file mode 100644
index 0000000..08b9a78
--- /dev/null
+++ b/ql/src/test/results/clientnegative/materialized_view_insert.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table imv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@imv_basetable
+POSTHOOK: query: create table imv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@imv_basetable
+PREHOOK: query: create materialized view imv_mat_view as select a, b, c from 
imv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@imv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@imv_mat_view
+POSTHOOK: query: create materialized view imv_mat_view as select a, b, c from 
imv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@imv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@imv_mat_view
+FAILED: SemanticException [Error 10090]: A view cannot be used as target table 
for LOAD or INSERT

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_load.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/materialized_view_load.q.out 
b/ql/src/test/results/clientnegative/materialized_view_load.q.out
new file mode 100644
index 0000000..4814365
--- /dev/null
+++ b/ql/src/test/results/clientnegative/materialized_view_load.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table lmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@lmv_basetable
+POSTHOOK: query: create table lmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@lmv_basetable
+PREHOOK: query: create materialized view lmv_mat_view as select a, b, c from 
lmv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@lmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@lmv_mat_view
+POSTHOOK: query: create materialized view lmv_mat_view as select a, b, c from 
lmv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@lmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@lmv_mat_view
+FAILED: SemanticException [Error 10090]: A view cannot be used as target table 
for LOAD or INSERT

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_replace_with_view.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientnegative/materialized_view_replace_with_view.q.out 
b/ql/src/test/results/clientnegative/materialized_view_replace_with_view.q.out
new file mode 100644
index 0000000..dac3538
--- /dev/null
+++ 
b/ql/src/test/results/clientnegative/materialized_view_replace_with_view.q.out
@@ -0,0 +1,30 @@
+PREHOOK: query: create table rmvwv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rmvwv_basetable
+POSTHOOK: query: create table rmvwv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rmvwv_basetable
+PREHOOK: query: insert into rmvwv_basetable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@rmvwv_basetable
+POSTHOOK: query: insert into rmvwv_basetable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@rmvwv_basetable
+POSTHOOK: Lineage: rmvwv_basetable.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: rmvwv_basetable.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: rmvwv_basetable.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view rmvwv_mat_view as select a, b, c from 
rmvwv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@rmvwv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rmvwv_mat_view
+POSTHOOK: query: create materialized view rmvwv_mat_view as select a, b, c 
from rmvwv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@rmvwv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rmvwv_mat_view
+FAILED: SemanticException [Error 10303]: Attempt to replace materialized view 
rmvwv_mat_view with view

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/materialized_view_update.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/materialized_view_update.q.out 
b/ql/src/test/results/clientnegative/materialized_view_update.q.out
new file mode 100644
index 0000000..bee63a8
--- /dev/null
+++ b/ql/src/test/results/clientnegative/materialized_view_update.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table umv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@umv_basetable
+POSTHOOK: query: create table umv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@umv_basetable
+PREHOOK: query: create materialized view umv_mat_view as select a, b, c from 
umv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@umv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@umv_mat_view
+POSTHOOK: query: create materialized view umv_mat_view as select a, b, c from 
umv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@umv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@umv_mat_view
+FAILED: SemanticException [Error 10304]: You cannot update or delete records 
in a view

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/view_delete.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/view_delete.q.out 
b/ql/src/test/results/clientnegative/view_delete.q.out
new file mode 100644
index 0000000..3e72344
--- /dev/null
+++ b/ql/src/test/results/clientnegative/view_delete.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table dv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@dv_basetable
+POSTHOOK: query: create table dv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@dv_basetable
+PREHOOK: query: create view dv_view as select a, b, c from dv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@dv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@dv_view
+POSTHOOK: query: create view dv_view as select a, b, c from dv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@dv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@dv_view
+FAILED: SemanticException [Error 10304]: You cannot update or delete records 
in a view

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientnegative/view_update.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientnegative/view_update.q.out 
b/ql/src/test/results/clientnegative/view_update.q.out
new file mode 100644
index 0000000..8a12665
--- /dev/null
+++ b/ql/src/test/results/clientnegative/view_update.q.out
@@ -0,0 +1,19 @@
+PREHOOK: query: create table uv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@uv_basetable
+POSTHOOK: query: create table uv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@uv_basetable
+PREHOOK: query: create view uv_view as select a, b, c from uv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@uv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@uv_view
+POSTHOOK: query: create view uv_view as select a, b, c from uv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@uv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@uv_view
+FAILED: SemanticException [Error 10304]: You cannot update or delete records 
in a view

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/authorization_view_sqlstd.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/authorization_view_sqlstd.q.out 
b/ql/src/test/results/clientpositive/authorization_view_sqlstd.q.out
deleted file mode 100644
index d2fab2f..0000000
--- a/ql/src/test/results/clientpositive/authorization_view_sqlstd.q.out
+++ /dev/null
@@ -1,269 +0,0 @@
-PREHOOK: query: -- Test view authorization , and 'show grant' variants
-
-create table t1(i int, j int, k int)
-PREHOOK: type: CREATETABLE
-PREHOOK: Output: database:default
-PREHOOK: Output: default@t1
-POSTHOOK: query: -- Test view authorization , and 'show grant' variants
-
-create table t1(i int, j int, k int)
-POSTHOOK: type: CREATETABLE
-POSTHOOK: Output: database:default
-POSTHOOK: Output: default@t1
-PREHOOK: query: show grant user user1 on table t1
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user1 on table t1
-POSTHOOK: type: SHOW_GRANT
-default        t1                      user1   USER    DELETE  true    -1      
user1
-default        t1                      user1   USER    INSERT  true    -1      
user1
-default        t1                      user1   USER    SELECT  true    -1      
user1
-default        t1                      user1   USER    UPDATE  true    -1      
user1
-PREHOOK: query: -- protecting certain columns
-create view vt1 as select i,k from t1
-PREHOOK: type: CREATEVIEW
-PREHOOK: Input: default@t1
-PREHOOK: Output: database:default
-PREHOOK: Output: default@vt1
-POSTHOOK: query: -- protecting certain columns
-create view vt1 as select i,k from t1
-POSTHOOK: type: CREATEVIEW
-POSTHOOK: Input: default@t1
-POSTHOOK: Output: database:default
-POSTHOOK: Output: default@vt1
-PREHOOK: query: -- protecting certain rows
-create view vt2 as select * from t1 where i > 1
-PREHOOK: type: CREATEVIEW
-PREHOOK: Input: default@t1
-PREHOOK: Output: database:default
-PREHOOK: Output: default@vt2
-POSTHOOK: query: -- protecting certain rows
-create view vt2 as select * from t1 where i > 1
-POSTHOOK: type: CREATEVIEW
-POSTHOOK: Input: default@t1
-POSTHOOK: Output: database:default
-POSTHOOK: Output: default@vt2
-PREHOOK: query: show grant user user1 on all
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user1 on all
-POSTHOOK: type: SHOW_GRANT
-default        t1                      user1   USER    DELETE  true    -1      
user1
-default        t1                      user1   USER    INSERT  true    -1      
user1
-default        t1                      user1   USER    SELECT  true    -1      
user1
-default        t1                      user1   USER    UPDATE  true    -1      
user1
-default        vt1                     user1   USER    DELETE  true    -1      
user1
-default        vt1                     user1   USER    INSERT  true    -1      
user1
-default        vt1                     user1   USER    SELECT  true    -1      
user1
-default        vt1                     user1   USER    UPDATE  true    -1      
user1
-default        vt2                     user1   USER    DELETE  true    -1      
user1
-default        vt2                     user1   USER    INSERT  true    -1      
user1
-default        vt2                     user1   USER    SELECT  true    -1      
user1
-default        vt2                     user1   USER    UPDATE  true    -1      
user1
-PREHOOK: query: --view grant to user
--- try with and without table keyword
-
-grant select on vt1 to user user2
-PREHOOK: type: GRANT_PRIVILEGE
-PREHOOK: Output: default@vt1
-POSTHOOK: query: --view grant to user
--- try with and without table keyword
-
-grant select on vt1 to user user2
-POSTHOOK: type: GRANT_PRIVILEGE
-POSTHOOK: Output: default@vt1
-PREHOOK: query: grant insert on table vt1 to user user3
-PREHOOK: type: GRANT_PRIVILEGE
-PREHOOK: Output: default@vt1
-POSTHOOK: query: grant insert on table vt1 to user user3
-POSTHOOK: type: GRANT_PRIVILEGE
-POSTHOOK: Output: default@vt1
-PREHOOK: query: show grant user user2 on table vt1
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on table vt1
-POSTHOOK: type: SHOW_GRANT
-default        vt1                     user2   USER    SELECT  false   -1      
user1
-PREHOOK: query: show grant user user3 on table vt1
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user3 on table vt1
-POSTHOOK: type: SHOW_GRANT
-default        vt1                     user3   USER    INSERT  false   -1      
user1
-PREHOOK: query: explain authorization select * from vt1
-PREHOOK: type: QUERY
-POSTHOOK: query: explain authorization select * from vt1
-POSTHOOK: type: QUERY
-INPUTS: 
-  default@vt1
-  default@t1
-OUTPUTS: 
-#### A masked pattern was here ####
-CURRENT_USER: 
-  user2
-OPERATION: 
-  QUERY
-PREHOOK: query: select * from vt1
-PREHOOK: type: QUERY
-PREHOOK: Input: default@t1
-PREHOOK: Input: default@vt1
-#### A masked pattern was here ####
-POSTHOOK: query: select * from vt1
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@t1
-POSTHOOK: Input: default@vt1
-#### A masked pattern was here ####
-PREHOOK: query: -- verify input objects required does not include table
--- even if view is within a sub query
-select * from (select * from vt1) a
-PREHOOK: type: QUERY
-PREHOOK: Input: default@t1
-PREHOOK: Input: default@vt1
-#### A masked pattern was here ####
-POSTHOOK: query: -- verify input objects required does not include table
--- even if view is within a sub query
-select * from (select * from vt1) a
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@t1
-POSTHOOK: Input: default@vt1
-#### A masked pattern was here ####
-PREHOOK: query: select * from vt1 union all select * from vt1
-PREHOOK: type: QUERY
-PREHOOK: Input: default@t1
-PREHOOK: Input: default@vt1
-#### A masked pattern was here ####
-POSTHOOK: query: select * from vt1 union all select * from vt1
-POSTHOOK: type: QUERY
-POSTHOOK: Input: default@t1
-POSTHOOK: Input: default@vt1
-#### A masked pattern was here ####
-PREHOOK: query: grant all on table vt2 to user user2
-PREHOOK: type: GRANT_PRIVILEGE
-PREHOOK: Output: default@vt2
-POSTHOOK: query: grant all on table vt2 to user user2
-POSTHOOK: type: GRANT_PRIVILEGE
-POSTHOOK: Output: default@vt2
-PREHOOK: query: show grant user user2 on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on table vt2
-POSTHOOK: type: SHOW_GRANT
-default        vt2                     user2   USER    DELETE  false   -1      
user1
-default        vt2                     user2   USER    INSERT  false   -1      
user1
-default        vt2                     user2   USER    SELECT  false   -1      
user1
-default        vt2                     user2   USER    UPDATE  false   -1      
user1
-PREHOOK: query: show grant user user2 on all
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on all
-POSTHOOK: type: SHOW_GRANT
-default        vt1                     user2   USER    SELECT  false   -1      
user1
-default        vt2                     user2   USER    DELETE  false   -1      
user1
-default        vt2                     user2   USER    INSERT  false   -1      
user1
-default        vt2                     user2   USER    SELECT  false   -1      
user1
-default        vt2                     user2   USER    UPDATE  false   -1      
user1
-PREHOOK: query: revoke all on vt2 from user user2
-PREHOOK: type: REVOKE_PRIVILEGE
-PREHOOK: Output: default@vt2
-POSTHOOK: query: revoke all on vt2 from user user2
-POSTHOOK: type: REVOKE_PRIVILEGE
-POSTHOOK: Output: default@vt2
-PREHOOK: query: show grant user user2 on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on table vt2
-POSTHOOK: type: SHOW_GRANT
-PREHOOK: query: set role admin
-PREHOOK: type: SHOW_ROLES
-POSTHOOK: query: set role admin
-POSTHOOK: type: SHOW_ROLES
-PREHOOK: query: show grant on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant on table vt2
-POSTHOOK: type: SHOW_GRANT
-default        vt2                     user1   USER    DELETE  true    -1      
user1
-default        vt2                     user1   USER    INSERT  true    -1      
user1
-default        vt2                     user1   USER    SELECT  true    -1      
user1
-default        vt2                     user1   USER    UPDATE  true    -1      
user1
-PREHOOK: query: revoke select on table vt1 from user user2
-PREHOOK: type: REVOKE_PRIVILEGE
-PREHOOK: Output: default@vt1
-POSTHOOK: query: revoke select on table vt1 from user user2
-POSTHOOK: type: REVOKE_PRIVILEGE
-POSTHOOK: Output: default@vt1
-PREHOOK: query: show grant user user2 on table vt1
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on table vt1
-POSTHOOK: type: SHOW_GRANT
-PREHOOK: query: show grant user user2 on all
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant user user2 on all
-POSTHOOK: type: SHOW_GRANT
-PREHOOK: query: -- grant privileges on roles for view, after next statement
-show grant user user3 on table vt1
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: -- grant privileges on roles for view, after next statement
-show grant user user3 on table vt1
-POSTHOOK: type: SHOW_GRANT
-default        vt1                     user3   USER    INSERT  false   -1      
user1
-PREHOOK: query: show current roles
-PREHOOK: type: SHOW_ROLES
-POSTHOOK: query: show current roles
-POSTHOOK: type: SHOW_ROLES
-public
-PREHOOK: query: set role ADMIN
-PREHOOK: type: SHOW_ROLES
-POSTHOOK: query: set role ADMIN
-POSTHOOK: type: SHOW_ROLES
-PREHOOK: query: create role role_v
-PREHOOK: type: CREATEROLE
-POSTHOOK: query: create role role_v
-POSTHOOK: type: CREATEROLE
-PREHOOK: query: grant  role_v to user user4
-PREHOOK: type: GRANT_ROLE
-POSTHOOK: query: grant  role_v to user user4
-POSTHOOK: type: GRANT_ROLE
-PREHOOK: query: show role grant user user4
-PREHOOK: type: SHOW_ROLE_GRANT
-POSTHOOK: query: show role grant user user4
-POSTHOOK: type: SHOW_ROLE_GRANT
-public false   -1      
-role_v false   -1      hive_admin_user
-PREHOOK: query: show roles
-PREHOOK: type: SHOW_ROLES
-POSTHOOK: query: show roles
-POSTHOOK: type: SHOW_ROLES
-admin
-public
-role_v
-PREHOOK: query: grant all on table vt2 to role role_v
-PREHOOK: type: GRANT_PRIVILEGE
-PREHOOK: Output: default@vt2
-POSTHOOK: query: grant all on table vt2 to role role_v
-POSTHOOK: type: GRANT_PRIVILEGE
-POSTHOOK: Output: default@vt2
-PREHOOK: query: show grant role role_v on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant role role_v on table vt2
-POSTHOOK: type: SHOW_GRANT
-default        vt2                     role_v  ROLE    DELETE  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
-PREHOOK: query: revoke delete on table vt2 from role role_v
-PREHOOK: type: REVOKE_PRIVILEGE
-PREHOOK: Output: default@vt2
-POSTHOOK: query: revoke delete on table vt2 from role role_v
-POSTHOOK: type: REVOKE_PRIVILEGE
-POSTHOOK: Output: default@vt2
-PREHOOK: query: show grant role role_v on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant role role_v on table vt2
-POSTHOOK: type: SHOW_GRANT
-default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
-PREHOOK: query: show grant on table vt2
-PREHOOK: type: SHOW_GRANT
-POSTHOOK: query: show grant on table vt2
-POSTHOOK: type: SHOW_GRANT
-default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
-default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
-default        vt2                     user1   USER    DELETE  true    -1      
user1
-default        vt2                     user1   USER    INSERT  true    -1      
user1
-default        vt2                     user1   USER    SELECT  true    -1      
user1
-default        vt2                     user1   USER    UPDATE  true    -1      
user1

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/materialized_view_authorization_sqlstd.q.out
----------------------------------------------------------------------
diff --git 
a/ql/src/test/results/clientpositive/materialized_view_authorization_sqlstd.q.out
 
b/ql/src/test/results/clientpositive/materialized_view_authorization_sqlstd.q.out
new file mode 100644
index 0000000..b167702
--- /dev/null
+++ 
b/ql/src/test/results/clientpositive/materialized_view_authorization_sqlstd.q.out
@@ -0,0 +1,195 @@
+PREHOOK: query: create table amvs_table (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvs_table
+POSTHOOK: query: create table amvs_table (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvs_table
+PREHOOK: query: insert into amvs_table values (1, 'alfred', 10.30),(2, 'bob', 
3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@amvs_table
+POSTHOOK: query: insert into amvs_table values (1, 'alfred', 10.30),(2, 'bob', 
3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@amvs_table
+POSTHOOK: Lineage: amvs_table.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvs_table.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: amvs_table.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view amvs_mat_view as select a, c from 
amvs_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvs_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvs_mat_view
+POSTHOOK: query: create materialized view amvs_mat_view as select a, c from 
amvs_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvs_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvs_mat_view
+PREHOOK: query: show grant user user1 on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user1 on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+default        amvs_mat_view                   user1   USER    DELETE  true    
-1      user1
+default        amvs_mat_view                   user1   USER    INSERT  true    
-1      user1
+default        amvs_mat_view                   user1   USER    SELECT  true    
-1      user1
+default        amvs_mat_view                   user1   USER    UPDATE  true    
-1      user1
+PREHOOK: query: grant select on amvs_mat_view to user user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@amvs_mat_view
+POSTHOOK: query: grant select on amvs_mat_view to user user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@amvs_mat_view
+PREHOOK: query: show grant user user2 on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+default        amvs_mat_view                   user2   USER    SELECT  false   
-1      user1
+PREHOOK: query: select * from amvs_mat_view
+PREHOOK: type: QUERY
+PREHOOK: Input: default@amvs_mat_view
+#### A masked pattern was here ####
+POSTHOOK: query: select * from amvs_mat_view
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@amvs_mat_view
+#### A masked pattern was here ####
+1      10.3
+2      3.14
+2      172342.2
+3      978.76
+3      9.8
+PREHOOK: query: show grant user user3 on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user3 on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+PREHOOK: query: set role admin
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: set role admin
+POSTHOOK: type: SHOW_ROLES
+PREHOOK: query: show grant on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+default        amvs_mat_view                   user1   USER    DELETE  true    
-1      user1
+default        amvs_mat_view                   user1   USER    INSERT  true    
-1      user1
+default        amvs_mat_view                   user1   USER    SELECT  true    
-1      user1
+default        amvs_mat_view                   user1   USER    UPDATE  true    
-1      user1
+default        amvs_mat_view                   user2   USER    SELECT  false   
-1      user1
+PREHOOK: query: revoke select on table amvs_mat_view from user user2
+PREHOOK: type: REVOKE_PRIVILEGE
+PREHOOK: Output: default@amvs_mat_view
+POSTHOOK: query: revoke select on table amvs_mat_view from user user2
+POSTHOOK: type: REVOKE_PRIVILEGE
+POSTHOOK: Output: default@amvs_mat_view
+PREHOOK: query: show grant user user2 on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+PREHOOK: query: set role ADMIN
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: set role ADMIN
+POSTHOOK: type: SHOW_ROLES
+PREHOOK: query: create role role_v
+PREHOOK: type: CREATEROLE
+POSTHOOK: query: create role role_v
+POSTHOOK: type: CREATEROLE
+PREHOOK: query: grant  role_v to user user4
+PREHOOK: type: GRANT_ROLE
+POSTHOOK: query: grant  role_v to user user4
+POSTHOOK: type: GRANT_ROLE
+PREHOOK: query: show role grant user user4
+PREHOOK: type: SHOW_ROLE_GRANT
+POSTHOOK: query: show role grant user user4
+POSTHOOK: type: SHOW_ROLE_GRANT
+public false   -1      
+role_v false   -1      hive_admin_user
+PREHOOK: query: show roles
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: show roles
+POSTHOOK: type: SHOW_ROLES
+admin
+public
+role_v
+PREHOOK: query: grant all on table amvs_mat_view to role role_v
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@amvs_mat_view
+POSTHOOK: query: grant all on table amvs_mat_view to role role_v
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@amvs_mat_view
+PREHOOK: query: show grant role role_v on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant role role_v on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+default        amvs_mat_view                   role_v  ROLE    DELETE  false   
-1      hive_admin_user
+default        amvs_mat_view                   role_v  ROLE    INSERT  false   
-1      hive_admin_user
+default        amvs_mat_view                   role_v  ROLE    SELECT  false   
-1      hive_admin_user
+default        amvs_mat_view                   role_v  ROLE    UPDATE  false   
-1      hive_admin_user
+PREHOOK: query: show grant user user4 on table amvs_mat_view
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user4 on table amvs_mat_view
+POSTHOOK: type: SHOW_GRANT
+PREHOOK: query: select * from amvs_mat_view
+PREHOOK: type: QUERY
+PREHOOK: Input: default@amvs_mat_view
+#### A masked pattern was here ####
+POSTHOOK: query: select * from amvs_mat_view
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@amvs_mat_view
+#### A masked pattern was here ####
+1      10.3
+2      3.14
+2      172342.2
+3      978.76
+3      9.8
+PREHOOK: query: alter materialized view amvs_mat_view rebuild
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvs_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvs_mat_view
+POSTHOOK: query: alter materialized view amvs_mat_view rebuild
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvs_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvs_mat_view
+PREHOOK: query: grant select on table amvs_table to user user2 with grant 
option
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@amvs_table
+POSTHOOK: query: grant select on table amvs_table to user user2 with grant 
option
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@amvs_table
+PREHOOK: query: create materialized view amvs_mat_view2 as select a, b from 
amvs_table
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@amvs_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@amvs_mat_view2
+POSTHOOK: query: create materialized view amvs_mat_view2 as select a, b from 
amvs_table
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@amvs_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@amvs_mat_view2
+PREHOOK: query: select * from amvs_mat_view2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@amvs_mat_view2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from amvs_mat_view2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@amvs_mat_view2
+#### A masked pattern was here ####
+1      alfred
+2      bob
+2      bonnie
+3      calvin
+3      charlie
+PREHOOK: query: drop materialized view amvs_mat_view2
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@amvs_mat_view2
+PREHOOK: Output: default@amvs_mat_view2
+POSTHOOK: query: drop materialized view amvs_mat_view2
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@amvs_mat_view2
+POSTHOOK: Output: default@amvs_mat_view2
+PREHOOK: query: set role ADMIN
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: set role ADMIN
+POSTHOOK: type: SHOW_ROLES

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/materialized_view_create.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/materialized_view_create.q.out 
b/ql/src/test/results/clientpositive/materialized_view_create.q.out
new file mode 100644
index 0000000..c51357d
--- /dev/null
+++ b/ql/src/test/results/clientpositive/materialized_view_create.q.out
@@ -0,0 +1,173 @@
+PREHOOK: query: create table cmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_basetable
+POSTHOOK: query: create table cmv_basetable (a int, b varchar(256), c 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_basetable
+PREHOOK: query: insert into cmv_basetable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@cmv_basetable
+POSTHOOK: query: insert into cmv_basetable values (1, 'alfred', 10.30),(2, 
'bob', 3.14),(2, 'bonnie', 172342.2),(3, 'calvin', 978.76),(3, 'charlie', 9.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@cmv_basetable
+POSTHOOK: Lineage: cmv_basetable.a EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: cmv_basetable.b EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: cmv_basetable.c EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view cmv_mat_view as select a, b, c from 
cmv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@cmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_mat_view
+POSTHOOK: query: create materialized view cmv_mat_view as select a, b, c from 
cmv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@cmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_mat_view
+PREHOOK: query: select * from cmv_mat_view
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cmv_mat_view
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cmv_mat_view
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cmv_mat_view
+#### A masked pattern was here ####
+1      alfred  10.3
+2      bob     3.14
+2      bonnie  172342.2
+3      calvin  978.76
+3      charlie 9.8
+PREHOOK: query: create materialized view if not exists cmv_mat_view2 as select 
a, c from cmv_basetable
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@cmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_mat_view2
+POSTHOOK: query: create materialized view if not exists cmv_mat_view2 as 
select a, c from cmv_basetable
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@cmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_mat_view2
+PREHOOK: query: select * from cmv_mat_view2
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cmv_mat_view2
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cmv_mat_view2
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cmv_mat_view2
+#### A masked pattern was here ####
+1      10.3
+2      3.14
+2      172342.2
+3      978.76
+3      9.8
+PREHOOK: query: create materialized view if not exists cmv_mat_view3 as select 
* from cmv_basetable where a > 1
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@cmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_mat_view3
+POSTHOOK: query: create materialized view if not exists cmv_mat_view3 as 
select * from cmv_basetable where a > 1
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@cmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_mat_view3
+PREHOOK: query: select * from cmv_mat_view3
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cmv_mat_view3
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cmv_mat_view3
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cmv_mat_view3
+#### A masked pattern was here ####
+2      bob     3.14
+2      bonnie  172342.2
+3      calvin  978.76
+3      charlie 9.8
+PREHOOK: query: create materialized view cmv_mat_view4 comment 'this is a 
comment' as select a, sum(c) from cmv_basetable group by a
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@cmv_basetable
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_mat_view4
+POSTHOOK: query: create materialized view cmv_mat_view4 comment 'this is a 
comment' as select a, sum(c) from cmv_basetable group by a
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@cmv_basetable
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_mat_view4
+PREHOOK: query: select * from cmv_mat_view4
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cmv_mat_view4
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cmv_mat_view4
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cmv_mat_view4
+#### A masked pattern was here ####
+1      10.3
+2      172345.34
+3      988.56
+PREHOOK: query: describe extended cmv_mat_view4
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@cmv_mat_view4
+POSTHOOK: query: describe extended cmv_mat_view4
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@cmv_mat_view4
+a                      int                                         
+_c1                    decimal(20,2)                               
+                
+#### A masked pattern was here ####
+PREHOOK: query: create table cmv_basetable2 (d int, e varchar(256), f 
decimal(10,2))
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_basetable2
+POSTHOOK: query: create table cmv_basetable2 (d int, e varchar(256), f 
decimal(10,2))
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_basetable2
+PREHOOK: query: insert into cmv_basetable2 values (4, 'alfred', 100.30),(4, 
'bob', 6133,14),(5, 'bonnie', 172.2),(6, 'calvin', 8.76),(17, 'charlie', 
13144339.8)
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__2
+PREHOOK: Output: default@cmv_basetable2
+POSTHOOK: query: insert into cmv_basetable2 values (4, 'alfred', 100.30),(4, 
'bob', 6133,14),(5, 'bonnie', 172.2),(6, 'calvin', 8.76),(17, 'charlie', 
13144339.8)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__2
+POSTHOOK: Output: default@cmv_basetable2
+POSTHOOK: Lineage: cmv_basetable2.d EXPRESSION 
[(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: cmv_basetable2.e EXPRESSION 
[(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+POSTHOOK: Lineage: cmv_basetable2.f EXPRESSION 
[(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col3, 
type:string, comment:), ]
+PREHOOK: query: create materialized view cmv_mat_view5 tblproperties 
('key'='value') as select a, b, d, c, f from cmv_basetable t1 join 
cmv_basetable2 t2 on (t1.b = t2.e)
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@cmv_basetable
+PREHOOK: Input: default@cmv_basetable2
+PREHOOK: Output: database:default
+PREHOOK: Output: default@cmv_mat_view5
+POSTHOOK: query: create materialized view cmv_mat_view5 tblproperties 
('key'='value') as select a, b, d, c, f from cmv_basetable t1 join 
cmv_basetable2 t2 on (t1.b = t2.e)
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@cmv_basetable
+POSTHOOK: Input: default@cmv_basetable2
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@cmv_mat_view5
+PREHOOK: query: select * from cmv_mat_view5
+PREHOOK: type: QUERY
+PREHOOK: Input: default@cmv_mat_view5
+#### A masked pattern was here ####
+POSTHOOK: query: select * from cmv_mat_view5
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@cmv_mat_view5
+#### A masked pattern was here ####
+1      alfred  4       10.3    100.3
+2      bob     4       3.14    6133
+2      bonnie  5       172342.2        172.2
+3      calvin  6       978.76  8.76
+3      charlie 17      9.8     13144339.8
+PREHOOK: query: show tblproperties cmv_mat_view5
+PREHOOK: type: SHOW_TBLPROPERTIES
+POSTHOOK: query: show tblproperties cmv_mat_view5
+POSTHOOK: type: SHOW_TBLPROPERTIES
+COLUMN_STATS_ACCURATE  false
+key    value
+numFiles       1
+numRows        -1
+rawDataSize    -1
+totalSize      730
+#### A masked pattern was here ####

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/materialized_view_drop.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/materialized_view_drop.q.out 
b/ql/src/test/results/clientpositive/materialized_view_drop.q.out
new file mode 100644
index 0000000..ed99a09
--- /dev/null
+++ b/ql/src/test/results/clientpositive/materialized_view_drop.q.out
@@ -0,0 +1,39 @@
+PREHOOK: query: create materialized view dmv_mat_view as select cint, cstring1 
from alltypesorc where cint < 0
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@alltypesorc
+PREHOOK: Output: database:default
+PREHOOK: Output: default@dmv_mat_view
+POSTHOOK: query: create materialized view dmv_mat_view as select cint, 
cstring1 from alltypesorc where cint < 0
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@alltypesorc
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@dmv_mat_view
+PREHOOK: query: show table extended like dmv_mat_view
+PREHOOK: type: SHOW_TABLESTATUS
+POSTHOOK: query: show table extended like dmv_mat_view
+POSTHOOK: type: SHOW_TABLESTATUS
+tableName:dmv_mat_view
+#### A masked pattern was here ####
+inputformat:org.apache.hadoop.hive.ql.io.orc.OrcInputFormat
+outputformat:org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat
+columns:struct columns { i32 cint, string cstring1}
+partitioned:false
+partitionColumns:
+totalNumberFiles:1
+totalFileSize:47146
+maxFileSize:47146
+minFileSize:47146
+#### A masked pattern was here ####
+
+PREHOOK: query: drop materialized view dmv_mat_view
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@dmv_mat_view
+PREHOOK: Output: default@dmv_mat_view
+POSTHOOK: query: drop materialized view dmv_mat_view
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@dmv_mat_view
+POSTHOOK: Output: default@dmv_mat_view
+PREHOOK: query: show table extended like dmv_mat_view
+PREHOOK: type: SHOW_TABLESTATUS
+POSTHOOK: query: show table extended like dmv_mat_view
+POSTHOOK: type: SHOW_TABLESTATUS

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/materialized_view_rebuild.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/materialized_view_rebuild.q.out 
b/ql/src/test/results/clientpositive/materialized_view_rebuild.q.out
new file mode 100644
index 0000000..9bede0d
--- /dev/null
+++ b/ql/src/test/results/clientpositive/materialized_view_rebuild.q.out
@@ -0,0 +1,67 @@
+PREHOOK: query: create table rmv_table (cint int, cstring1 string)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rmv_table
+POSTHOOK: query: create table rmv_table (cint int, cstring1 string)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rmv_table
+PREHOOK: query: insert into rmv_table values(1, 'fred'), (10, 'wilma')
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__1
+PREHOOK: Output: default@rmv_table
+POSTHOOK: query: insert into rmv_table values(1, 'fred'), (10, 'wilma')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__1
+POSTHOOK: Output: default@rmv_table
+POSTHOOK: Lineage: rmv_table.cint EXPRESSION 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: rmv_table.cstring1 SIMPLE 
[(values__tmp__table__1)values__tmp__table__1.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+PREHOOK: query: create materialized view rmv_mat_view as select cint, cstring1 
from rmv_table where cint < 10
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@rmv_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rmv_mat_view
+POSTHOOK: query: create materialized view rmv_mat_view as select cint, 
cstring1 from rmv_table where cint < 10
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@rmv_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rmv_mat_view
+PREHOOK: query: select * from rmv_mat_view
+PREHOOK: type: QUERY
+PREHOOK: Input: default@rmv_mat_view
+#### A masked pattern was here ####
+POSTHOOK: query: select * from rmv_mat_view
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@rmv_mat_view
+#### A masked pattern was here ####
+1      fred
+PREHOOK: query: insert into rmv_table values(2, 'barney'), (11, 'betty')
+PREHOOK: type: QUERY
+PREHOOK: Input: default@values__tmp__table__2
+PREHOOK: Output: default@rmv_table
+POSTHOOK: query: insert into rmv_table values(2, 'barney'), (11, 'betty')
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@values__tmp__table__2
+POSTHOOK: Output: default@rmv_table
+POSTHOOK: Lineage: rmv_table.cint EXPRESSION 
[(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col1, 
type:string, comment:), ]
+POSTHOOK: Lineage: rmv_table.cstring1 SIMPLE 
[(values__tmp__table__2)values__tmp__table__2.FieldSchema(name:tmp_values_col2, 
type:string, comment:), ]
+PREHOOK: query: alter materialized view rmv_mat_view rebuild
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@rmv_table
+PREHOOK: Output: database:default
+PREHOOK: Output: default@rmv_mat_view
+POSTHOOK: query: alter materialized view rmv_mat_view rebuild
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@rmv_table
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@rmv_mat_view
+PREHOOK: query: select * from rmv_mat_view
+PREHOOK: type: QUERY
+PREHOOK: Input: default@rmv_mat_view
+#### A masked pattern was here ####
+POSTHOOK: query: select * from rmv_mat_view
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@rmv_mat_view
+#### A masked pattern was here ####
+1      fred
+2      barney

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/ql/src/test/results/clientpositive/view_authorization_sqlstd.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/view_authorization_sqlstd.q.out 
b/ql/src/test/results/clientpositive/view_authorization_sqlstd.q.out
new file mode 100644
index 0000000..122ca4e
--- /dev/null
+++ b/ql/src/test/results/clientpositive/view_authorization_sqlstd.q.out
@@ -0,0 +1,295 @@
+PREHOOK: query: -- Test view authorization , and 'show grant' variants
+
+create table t1(i int, j int, k int)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t1
+POSTHOOK: query: -- Test view authorization , and 'show grant' variants
+
+create table t1(i int, j int, k int)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t1
+PREHOOK: query: grant select on t1 to user user2 with grant option
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@t1
+POSTHOOK: query: grant select on t1 to user user2 with grant option
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@t1
+PREHOOK: query: show grant user user1 on table t1
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user1 on table t1
+POSTHOOK: type: SHOW_GRANT
+default        t1                      user1   USER    DELETE  true    -1      
user1
+default        t1                      user1   USER    INSERT  true    -1      
user1
+default        t1                      user1   USER    SELECT  true    -1      
user1
+default        t1                      user1   USER    UPDATE  true    -1      
user1
+PREHOOK: query: -- protecting certain columns
+create view vt1 as select i,k from t1
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@t1
+PREHOOK: Output: database:default
+PREHOOK: Output: default@vt1
+POSTHOOK: query: -- protecting certain columns
+create view vt1 as select i,k from t1
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@t1
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@vt1
+PREHOOK: query: -- protecting certain rows
+create view vt2 as select * from t1 where i > 1
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@t1
+PREHOOK: Output: database:default
+PREHOOK: Output: default@vt2
+POSTHOOK: query: -- protecting certain rows
+create view vt2 as select * from t1 where i > 1
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@t1
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@vt2
+PREHOOK: query: show grant user user1 on all
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user1 on all
+POSTHOOK: type: SHOW_GRANT
+default        t1                      user1   USER    DELETE  true    -1      
user1
+default        t1                      user1   USER    INSERT  true    -1      
user1
+default        t1                      user1   USER    SELECT  true    -1      
user1
+default        t1                      user1   USER    UPDATE  true    -1      
user1
+default        vt1                     user1   USER    DELETE  true    -1      
user1
+default        vt1                     user1   USER    INSERT  true    -1      
user1
+default        vt1                     user1   USER    SELECT  true    -1      
user1
+default        vt1                     user1   USER    UPDATE  true    -1      
user1
+default        vt2                     user1   USER    DELETE  true    -1      
user1
+default        vt2                     user1   USER    INSERT  true    -1      
user1
+default        vt2                     user1   USER    SELECT  true    -1      
user1
+default        vt2                     user1   USER    UPDATE  true    -1      
user1
+PREHOOK: query: --view grant to user
+-- try with and without table keyword
+
+grant select on vt1 to user user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@vt1
+POSTHOOK: query: --view grant to user
+-- try with and without table keyword
+
+grant select on vt1 to user user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@vt1
+PREHOOK: query: grant insert on table vt1 to user user3
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@vt1
+POSTHOOK: query: grant insert on table vt1 to user user3
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@vt1
+PREHOOK: query: show grant user user2 on table vt1
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table vt1
+POSTHOOK: type: SHOW_GRANT
+default        vt1                     user2   USER    SELECT  false   -1      
user1
+PREHOOK: query: create view vt3 as select i,k from t1
+PREHOOK: type: CREATEVIEW
+PREHOOK: Input: default@t1
+PREHOOK: Output: database:default
+PREHOOK: Output: default@vt3
+POSTHOOK: query: create view vt3 as select i,k from t1
+POSTHOOK: type: CREATEVIEW
+POSTHOOK: Input: default@t1
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@vt3
+PREHOOK: query: show grant user user3 on table vt1
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user3 on table vt1
+POSTHOOK: type: SHOW_GRANT
+default        vt1                     user3   USER    INSERT  false   -1      
user1
+PREHOOK: query: explain authorization select * from vt1
+PREHOOK: type: QUERY
+POSTHOOK: query: explain authorization select * from vt1
+POSTHOOK: type: QUERY
+INPUTS: 
+  default@vt1
+  default@t1
+OUTPUTS: 
+#### A masked pattern was here ####
+CURRENT_USER: 
+  user2
+OPERATION: 
+  QUERY
+PREHOOK: query: select * from vt1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t1
+PREHOOK: Input: default@vt1
+#### A masked pattern was here ####
+POSTHOOK: query: select * from vt1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t1
+POSTHOOK: Input: default@vt1
+#### A masked pattern was here ####
+PREHOOK: query: -- verify input objects required does not include table
+-- even if view is within a sub query
+select * from (select * from vt1) a
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t1
+PREHOOK: Input: default@vt1
+#### A masked pattern was here ####
+POSTHOOK: query: -- verify input objects required does not include table
+-- even if view is within a sub query
+select * from (select * from vt1) a
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t1
+POSTHOOK: Input: default@vt1
+#### A masked pattern was here ####
+PREHOOK: query: select * from vt1 union all select * from vt1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t1
+PREHOOK: Input: default@vt1
+#### A masked pattern was here ####
+POSTHOOK: query: select * from vt1 union all select * from vt1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t1
+POSTHOOK: Input: default@vt1
+#### A masked pattern was here ####
+PREHOOK: query: grant all on table vt2 to user user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@vt2
+POSTHOOK: query: grant all on table vt2 to user user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@vt2
+PREHOOK: query: show grant user user2 on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table vt2
+POSTHOOK: type: SHOW_GRANT
+default        vt2                     user2   USER    DELETE  false   -1      
user1
+default        vt2                     user2   USER    INSERT  false   -1      
user1
+default        vt2                     user2   USER    SELECT  false   -1      
user1
+default        vt2                     user2   USER    UPDATE  false   -1      
user1
+PREHOOK: query: show grant user user2 on all
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on all
+POSTHOOK: type: SHOW_GRANT
+default        t1                      user2   USER    SELECT  true    -1      
user1
+default        vt1                     user2   USER    SELECT  false   -1      
user1
+default        vt2                     user2   USER    DELETE  false   -1      
user1
+default        vt2                     user2   USER    INSERT  false   -1      
user1
+default        vt2                     user2   USER    SELECT  false   -1      
user1
+default        vt2                     user2   USER    UPDATE  false   -1      
user1
+default        vt3                     user2   USER    DELETE  true    -1      
user1
+default        vt3                     user2   USER    INSERT  true    -1      
user1
+default        vt3                     user2   USER    SELECT  true    -1      
user1
+default        vt3                     user2   USER    UPDATE  true    -1      
user1
+PREHOOK: query: revoke all on vt2 from user user2
+PREHOOK: type: REVOKE_PRIVILEGE
+PREHOOK: Output: default@vt2
+POSTHOOK: query: revoke all on vt2 from user user2
+POSTHOOK: type: REVOKE_PRIVILEGE
+POSTHOOK: Output: default@vt2
+PREHOOK: query: show grant user user2 on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table vt2
+POSTHOOK: type: SHOW_GRANT
+PREHOOK: query: set role admin
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: set role admin
+POSTHOOK: type: SHOW_ROLES
+PREHOOK: query: show grant on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant on table vt2
+POSTHOOK: type: SHOW_GRANT
+default        vt2                     user1   USER    DELETE  true    -1      
user1
+default        vt2                     user1   USER    INSERT  true    -1      
user1
+default        vt2                     user1   USER    SELECT  true    -1      
user1
+default        vt2                     user1   USER    UPDATE  true    -1      
user1
+PREHOOK: query: revoke select on table vt1 from user user2
+PREHOOK: type: REVOKE_PRIVILEGE
+PREHOOK: Output: default@vt1
+POSTHOOK: query: revoke select on table vt1 from user user2
+POSTHOOK: type: REVOKE_PRIVILEGE
+POSTHOOK: Output: default@vt1
+PREHOOK: query: show grant user user2 on table vt1
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on table vt1
+POSTHOOK: type: SHOW_GRANT
+PREHOOK: query: show grant user user2 on all
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant user user2 on all
+POSTHOOK: type: SHOW_GRANT
+default        t1                      user2   USER    SELECT  true    -1      
user1
+default        vt3                     user2   USER    DELETE  true    -1      
user1
+default        vt3                     user2   USER    INSERT  true    -1      
user1
+default        vt3                     user2   USER    SELECT  true    -1      
user1
+default        vt3                     user2   USER    UPDATE  true    -1      
user1
+PREHOOK: query: -- grant privileges on roles for view, after next statement
+show grant user user3 on table vt1
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: -- grant privileges on roles for view, after next statement
+show grant user user3 on table vt1
+POSTHOOK: type: SHOW_GRANT
+default        vt1                     user3   USER    INSERT  false   -1      
user1
+PREHOOK: query: show current roles
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: show current roles
+POSTHOOK: type: SHOW_ROLES
+public
+PREHOOK: query: set role ADMIN
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: set role ADMIN
+POSTHOOK: type: SHOW_ROLES
+PREHOOK: query: create role role_v
+PREHOOK: type: CREATEROLE
+POSTHOOK: query: create role role_v
+POSTHOOK: type: CREATEROLE
+PREHOOK: query: grant  role_v to user user4
+PREHOOK: type: GRANT_ROLE
+POSTHOOK: query: grant  role_v to user user4
+POSTHOOK: type: GRANT_ROLE
+PREHOOK: query: show role grant user user4
+PREHOOK: type: SHOW_ROLE_GRANT
+POSTHOOK: query: show role grant user user4
+POSTHOOK: type: SHOW_ROLE_GRANT
+public false   -1      
+role_v false   -1      hive_admin_user
+PREHOOK: query: show roles
+PREHOOK: type: SHOW_ROLES
+POSTHOOK: query: show roles
+POSTHOOK: type: SHOW_ROLES
+admin
+public
+role_v
+PREHOOK: query: grant all on table vt2 to role role_v
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@vt2
+POSTHOOK: query: grant all on table vt2 to role role_v
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@vt2
+PREHOOK: query: show grant role role_v on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant role role_v on table vt2
+POSTHOOK: type: SHOW_GRANT
+default        vt2                     role_v  ROLE    DELETE  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
+PREHOOK: query: revoke delete on table vt2 from role role_v
+PREHOOK: type: REVOKE_PRIVILEGE
+PREHOOK: Output: default@vt2
+POSTHOOK: query: revoke delete on table vt2 from role role_v
+POSTHOOK: type: REVOKE_PRIVILEGE
+POSTHOOK: Output: default@vt2
+PREHOOK: query: show grant role role_v on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant role role_v on table vt2
+POSTHOOK: type: SHOW_GRANT
+default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
+PREHOOK: query: show grant on table vt2
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant on table vt2
+POSTHOOK: type: SHOW_GRANT
+default        vt2                     role_v  ROLE    INSERT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    SELECT  false   -1      
hive_admin_user
+default        vt2                     role_v  ROLE    UPDATE  false   -1      
hive_admin_user
+default        vt2                     user1   USER    DELETE  true    -1      
user1
+default        vt2                     user1   USER    INSERT  true    -1      
user1
+default        vt2                     user1   USER    SELECT  true    -1      
user1
+default        vt2                     user1   USER    UPDATE  true    -1      
user1

http://git-wip-us.apache.org/repos/asf/hive/blob/438109cb/service/src/java/org/apache/hive/service/cli/operation/ClassicTableTypeMapping.java
----------------------------------------------------------------------
diff --git 
a/service/src/java/org/apache/hive/service/cli/operation/ClassicTableTypeMapping.java
 
b/service/src/java/org/apache/hive/service/cli/operation/ClassicTableTypeMapping.java
index 5f8cc1e..86417a4 100644
--- 
a/service/src/java/org/apache/hive/service/cli/operation/ClassicTableTypeMapping.java
+++ 
b/service/src/java/org/apache/hive/service/cli/operation/ClassicTableTypeMapping.java
@@ -47,6 +47,7 @@ public class ClassicTableTypeMapping implements 
TableTypeMapping {
   public enum ClassicTableTypes {
     TABLE,
     VIEW,
+    MATERIALIZED_VIEW,
   }
 
   private final Map<String, String> hiveToClientMap = new HashMap<String, 
String>();
@@ -56,10 +57,14 @@ public class ClassicTableTypeMapping implements 
TableTypeMapping {
     hiveToClientMap.put(TableType.MANAGED_TABLE.name(), 
ClassicTableTypes.TABLE.name());
     hiveToClientMap.put(TableType.EXTERNAL_TABLE.name(), 
ClassicTableTypes.TABLE.name());
     hiveToClientMap.put(TableType.VIRTUAL_VIEW.name(), 
ClassicTableTypes.VIEW.name());
+    hiveToClientMap.put(TableType.MATERIALIZED_VIEW.toString(),
+            ClassicTableTypes.MATERIALIZED_VIEW.toString());
 
     clientToHiveMap.putAll(ClassicTableTypes.TABLE.name(), Arrays.asList(
         TableType.MANAGED_TABLE.name(), TableType.EXTERNAL_TABLE.name()));
     clientToHiveMap.put(ClassicTableTypes.VIEW.name(), 
TableType.VIRTUAL_VIEW.name());
+    clientToHiveMap.put(ClassicTableTypes.MATERIALIZED_VIEW.toString(),
+            TableType.MATERIALIZED_VIEW.toString());
   }
 
   @Override

Reply via email to