Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -581,20 +581,20 @@ public void test() throws Exception {

opHandle = serviceClient.executeStatement(sessHandle, "select * from INFORMATION_SCHEMA.SCHEMATA", confOverlay);
rowSet = serviceClient.fetchResults(opHandle);
Assert.assertEquals(rowSet.numRows(), 5);
Assert.assertTrue(rowSet.numRows() > 2);

opHandle = serviceClient.executeStatement(sessHandle, "select * from INFORMATION_SCHEMA.TABLES", confOverlay);
rowSet = serviceClient.fetchResults(opHandle);
Assert.assertTrue(rowSet.numRows() > 50);
Assert.assertTrue(rowSet.numRows() > 10);

opHandle = serviceClient.executeStatement(sessHandle, "select * from INFORMATION_SCHEMA.TABLE_PRIVILEGES",
confOverlay);
rowSet = serviceClient.fetchResults(opHandle);
Assert.assertTrue(rowSet.numRows() > 200);
Assert.assertEquals(rowSet.numRows(), 7);

opHandle = serviceClient.executeStatement(sessHandle, "select * from INFORMATION_SCHEMA.COLUMNS", confOverlay);
rowSet = serviceClient.fetchResults(opHandle);
Assert.assertTrue(rowSet.numRows() > 350);
Assert.assertTrue(rowSet.numRows() > 10);

opHandle = serviceClient.executeStatement(sessHandle, "select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES",
confOverlay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public MiniLlapLocalCliConfig() {
includesFrom(testConfigProps, "minillaplocal.shared.query.files");
excludeQuery("bucket_map_join_tez1.q"); // Disabled in HIVE-19509
excludeQuery("special_character_in_tabnames_1.q"); // Disabled in HIVE-19509
excludeQuery("sysdb.q"); // Disabled in HIVE-19509
excludeQuery("tez_smb_1.q"); // Disabled in HIVE-19509
excludeQuery("union_fast_stats.q"); // Disabled in HIVE-19509
excludeQuery("schema_evol_orc_acidvec_part.q"); // Disabled in HIVE-19509
Expand Down
78 changes: 47 additions & 31 deletions metastore/scripts/upgrade/hive/hive-schema-3.1.0.hive.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1080,10 +1080,11 @@ SELECT DISTINCT
cast(null as string),
`DB_LOCATION_URI`
FROM
`sys`.`DBS` D LEFT JOIN `sys`.`TBLS` T ON (D.`DB_ID` = T.`DB_ID`)
LEFT JOIN `sys`.`TBL_PRIVS` P ON (T.`TBL_ID` = P.`TBL_ID`)
`sys`.`DBS` D, `sys`.`TBLS` T, `sys`.`TBL_PRIVS` P
WHERE
NOT restrict_information_schema() OR P.`TBL_ID` IS NOT NULL
NOT restrict_information_schema() OR
D.`DB_ID` = T.`DB_ID`
AND T.`TBL_ID` = P.`TBL_ID`
AND (P.`PRINCIPAL_NAME`=current_user() AND P.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P.`PRINCIPAL_NAME`) OR P.`PRINCIPAL_NAME` = 'public') AND P.`PRINCIPAL_TYPE`='GROUP'))
AND current_authorizer() = P.`AUTHORIZER`;
Expand Down Expand Up @@ -1117,12 +1118,12 @@ SELECT DISTINCT
'NO',
cast(null as string)
FROM
`sys`.`TBLS` T JOIN `sys`.`DBS` D ON (D.`DB_ID` = T.`DB_ID`)
LEFT JOIN `sys`.`TBL_PRIVS` P ON (T.`TBL_ID` = P.`TBL_ID`)
`sys`.`TBLS` T, `sys`.`DBS` D, `sys`.`TBL_PRIVS` P
WHERE
NOT restrict_information_schema() OR P.`TBL_ID` IS NOT NULL
D.`DB_ID` = T.`DB_ID`
AND (NOT restrict_information_schema() OR T.`TBL_ID` = P.`TBL_ID`
AND (P.`PRINCIPAL_NAME`=current_user() AND P.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P.`PRINCIPAL_NAME`) OR P.`PRINCIPAL_NAME` = 'public') AND P.`PRINCIPAL_TYPE`='GROUP'))
OR ((array_contains(current_groups(), P.`PRINCIPAL_NAME`) OR P.`PRINCIPAL_NAME` = 'public') AND P.`PRINCIPAL_TYPE`='GROUP')))
AND P.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer();

CREATE OR REPLACE VIEW `TABLE_PRIVILEGES`
Expand All @@ -1146,15 +1147,18 @@ SELECT DISTINCT
IF (P.`GRANT_OPTION` == 0, 'NO', 'YES'),
'NO'
FROM
`sys`.`TBL_PRIVS` P JOIN `sys`.`TBLS` T ON (P.`TBL_ID` = T.`TBL_ID`)
JOIN `sys`.`DBS` D ON (T.`DB_ID` = D.`DB_ID`)
LEFT JOIN `sys`.`TBL_PRIVS` P2 ON (P.`TBL_ID` = P2.`TBL_ID`)
`sys`.`TBL_PRIVS` P,
`sys`.`TBLS` T,
`sys`.`DBS` D,
`sys`.`TBL_PRIVS` P2
WHERE
NOT restrict_information_schema() OR
(P2.`TBL_ID` IS NOT NULL AND P.`PRINCIPAL_NAME` = P2.`PRINCIPAL_NAME` AND P.`PRINCIPAL_TYPE` = P2.`PRINCIPAL_TYPE`
P.`TBL_ID` = T.`TBL_ID`
AND T.`DB_ID` = D.`DB_ID`
AND (NOT restrict_information_schema() OR
P.`TBL_ID` = P2.`TBL_ID` AND P.`PRINCIPAL_NAME` = P2.`PRINCIPAL_NAME` AND P.`PRINCIPAL_TYPE` = P2.`PRINCIPAL_TYPE`
AND (P2.`PRINCIPAL_NAME`=current_user() AND P2.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P2.`PRINCIPAL_NAME`) OR P2.`PRINCIPAL_NAME` = 'public') AND P2.`PRINCIPAL_TYPE`='GROUP'))
AND P2.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER` = current_authorizer() AND P2.`AUTHORIZER` = current_authorizer());
OR ((array_contains(current_groups(), P2.`PRINCIPAL_NAME`) OR P2.`PRINCIPAL_NAME` = 'public') AND P2.`PRINCIPAL_TYPE`='GROUP')))
AND P2.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER` = current_authorizer() AND P2.`AUTHORIZER` = current_authorizer();

CREATE OR REPLACE VIEW `COLUMNS`
(
Expand Down Expand Up @@ -1295,16 +1299,21 @@ SELECT DISTINCT
WHEN lower(C.TYPE_NAME) like 'numeric%' THEN 10
ELSE null END
FROM
`sys`.`COLUMNS_V2` C JOIN `sys`.`SDS` S ON (C.`CD_ID` = S.`CD_ID`)
JOIN `sys`.`TBLS` T ON (S.`SD_ID` = T.`SD_ID`)
JOIN `sys`.`DBS` D ON (T.`DB_ID` = D.`DB_ID`)
LEFT JOIN `sys`.`TBL_COL_PRIVS` P ON (T.`TBL_ID` = P.`TBL_ID`)
`sys`.`COLUMNS_V2` C,
`sys`.`SDS` S,
`sys`.`TBLS` T,
`sys`.`DBS` D,
`sys`.`TBL_COL_PRIVS` P
WHERE
NOT restrict_information_schema() OR P.`TBL_ID` IS NOT NULL
S.`SD_ID` = T.`SD_ID`
AND T.`DB_ID` = D.`DB_ID`
AND C.`CD_ID` = S.`CD_ID`
AND (NOT restrict_information_schema() OR
T.`TBL_ID` = P.`TBL_ID`
AND C.`COLUMN_NAME` = P.`COLUMN_NAME`
AND (P.`PRINCIPAL_NAME`=current_user() AND P.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P.`PRINCIPAL_NAME`) OR P.`PRINCIPAL_NAME` = 'public') AND P.`PRINCIPAL_TYPE`='GROUP'))
AND P.`TBL_COL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer();
AND P.`TBL_COL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer());

CREATE OR REPLACE VIEW `COLUMN_PRIVILEGES`
(
Expand All @@ -1327,16 +1336,20 @@ SELECT DISTINCT
P.`TBL_COL_PRIV`,
IF (P.`GRANT_OPTION` == 0, 'NO', 'YES')
FROM
`sys`.`TBL_COL_PRIVS` P JOIN `sys`.`TBLS` T ON (P.`TBL_ID` = T.`TBL_ID`)
JOIN `sys`.`DBS` D ON (T.`DB_ID` = D.`DB_ID`)
JOIN `sys`.`SDS` S ON (S.`SD_ID` = T.`SD_ID`)
LEFT JOIN `sys`.`TBL_PRIVS` P2 ON (P.`TBL_ID` = P2.`TBL_ID`)
`sys`.`TBL_COL_PRIVS` P,
`sys`.`TBLS` T,
`sys`.`DBS` D,
`sys`.`SDS` S,
`sys`.`TBL_PRIVS` P2
WHERE
NOT restrict_information_schema() OR P2.`TBL_ID` IS NOT NULL
AND P.`PRINCIPAL_NAME` = P2.`PRINCIPAL_NAME` AND P.`PRINCIPAL_TYPE` = P2.`PRINCIPAL_TYPE`
S.`SD_ID` = T.`SD_ID`
AND T.`DB_ID` = D.`DB_ID`
AND P.`TBL_ID` = T.`TBL_ID`
AND (NOT restrict_information_schema() OR
P.`TBL_ID` = P2.`TBL_ID` AND P.`PRINCIPAL_NAME` = P2.`PRINCIPAL_NAME` AND P.`PRINCIPAL_TYPE` = P2.`PRINCIPAL_TYPE`
AND (P2.`PRINCIPAL_NAME`=current_user() AND P2.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P2.`PRINCIPAL_NAME`) OR P2.`PRINCIPAL_NAME` = 'public') AND P2.`PRINCIPAL_TYPE`='GROUP'))
AND P2.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer() AND P2.`AUTHORIZER`=current_authorizer();
AND P2.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer() AND P2.`AUTHORIZER`=current_authorizer());

CREATE OR REPLACE VIEW `VIEWS`
(
Expand All @@ -1363,11 +1376,14 @@ SELECT DISTINCT
false,
false
FROM
`sys`.`DBS` D JOIN `sys`.`TBLS` T ON (D.`DB_ID` = T.`DB_ID`)
LEFT JOIN `sys`.`TBL_PRIVS` P ON (T.`TBL_ID` = P.`TBL_ID`)
`sys`.`DBS` D,
`sys`.`TBLS` T,
`sys`.`TBL_PRIVS` P
WHERE
length(T.VIEW_ORIGINAL_TEXT) > 0
AND (NOT restrict_information_schema() OR P.`TBL_ID` IS NOT NULL
D.`DB_ID` = T.`DB_ID`
AND length(T.VIEW_ORIGINAL_TEXT) > 0
AND (NOT restrict_information_schema() OR
T.`TBL_ID` = P.`TBL_ID`
AND (P.`PRINCIPAL_NAME`=current_user() AND P.`PRINCIPAL_TYPE`='USER'
OR ((array_contains(current_groups(), P.`PRINCIPAL_NAME`) OR P.`PRINCIPAL_NAME` = 'public') AND P.`PRINCIPAL_TYPE`='GROUP'))
AND P.`TBL_PRIV`='SELECT' AND P.`AUTHORIZER`=current_authorizer());
12 changes: 7 additions & 5 deletions ql/src/test/queries/clientpositive/sysdb.q
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--! qt:dataset:alltypesorc,alltypesparquet,part,src,src1,srcbucket,srcbucket2,src_cbo,src_json,src_sequencefile,src_thrift,srcpart,cbo_t1,cbo_t2,cbo_t3,lineitem

set hive.strict.checks.cartesian.product=false;

set hive.compute.query.using.stats=false;

set hive.support.concurrency=true;
set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

set hive.cbo.enable=false;

-- SORT_QUERY_RESULTS

create table src_buck (key int, value string) clustered by(value) into 2 buckets;
Expand All @@ -33,7 +33,7 @@ use sys;

select bucket_col_name, integer_idx from bucketing_cols order by bucket_col_name, integer_idx limit 5;

select t.tbl_name, c.column_name from tbls t join sds s on t.sd_id=s.sd_id join columns_v2 c on s.cd_id=c.cd_id order by t.tbl_name, c.column_name;
select count(*) from cds;

select column_name, type_name, integer_idx from columns_v2 order by column_name, integer_idx limit 5;

Expand Down Expand Up @@ -68,6 +68,8 @@ select count(*) from sds;

select param_key, param_value from sd_params order by param_key, param_value limit 5;

select sequence_name from sequence_table order by sequence_name limit 5;

select name, slib from serdes order by name, slib limit 5;

select param_key, param_value from serde_params order by param_key, param_value limit 5;
Expand Down Expand Up @@ -102,7 +104,7 @@ select func_name, func_type from funcs order by func_name, func_type limit 5;

select constraint_name from key_constraints order by constraint_name limit 5;

select COLUMN_STATS_ACCURATE, NUM_FILES, NUM_ROWS, RAW_DATA_SIZE, TOTAL_SIZE FROM TABLE_STATS_VIEW where COLUMN_STATS_ACCURATE is not null order by COLUMN_STATS_ACCURATE limit 5;
select COLUMN_STATS_ACCURATE, NUM_FILES, NUM_ROWS, RAW_DATA_SIZE, TOTAL_SIZE FROM TABLE_STATS_VIEW where COLUMN_STATS_ACCURATE is not null order by NUM_FILES, NUM_ROWS, RAW_DATA_SIZE limit 5;

select COLUMN_STATS_ACCURATE, NUM_FILES, NUM_ROWS, RAW_DATA_SIZE, TOTAL_SIZE FROM PARTITION_STATS_VIEW where COLUMN_STATS_ACCURATE is not null order by NUM_FILES, NUM_ROWS, RAW_DATA_SIZE limit 5;

Expand All @@ -120,7 +122,7 @@ select * from TABLES order by TABLE_SCHEMA, TABLE_NAME;

select * from TABLE_PRIVILEGES order by GRANTOR, GRANTEE, TABLE_SCHEMA, TABLE_NAME, PRIVILEGE_TYPE limit 10;

select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,is_nullable,data_type,character_maximum_length,character_octet_length,numeric_precision,numeric_precision_radix,numeric_scale,datetime_precision,interval_type,interval_precision,character_set_catalog,character_set_schema,character_set_name,collation_catalog,collation_schema,collation_name,udt_catalog,udt_schema,udt_name,scope_catalog,scope_schema,scope_name,maximum_cardinality,is_self_referencing,is_identity,identity_generation,identity_start,identity_increment,identity_maximum,identity_minimum,identity_cycle,is_generated,generation_expression,is_system_time_period_start,is_system_time_period_end,system_time_period_timestamp_generation,is_updatable,declared_data_type,declared_numeric_precision,declared_numeric_scale from COLUMNS where TABLE_NAME = 'alltypesorc' or TABLE_NAME = 'moretypes' order by TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION ;
select * from COLUMNS where TABLE_NAME = 'alltypesorc' or TABLE_NAME = 'moretypes' order by TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION ;

select * from COLUMN_PRIVILEGES order by GRANTOR, GRANTEE, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME limit 10;

Expand Down
Loading