This is an automated email from the ASF dual-hosted git repository.
sbadhya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 5e5767a1f12 HIVE-28482: Iceberg: CTAS, CTLT query failure while
fetching URI for authorization (#5414) (Sourabh Badhya reviewed by Denys
Kuzmenko)
5e5767a1f12 is described below
commit 5e5767a1f125506912a65a7a4844c5c7b745d9db
Author: Sourabh Badhya <[email protected]>
AuthorDate: Fri Aug 30 15:48:27 2024 +0530
HIVE-28482: Iceberg: CTAS, CTLT query failure while fetching URI for
authorization (#5414) (Sourabh Badhya reviewed by Denys Kuzmenko)
---
.../apache/iceberg/mr/hive/TestHiveIcebergCTAS.java | 21 +++++++++++++++++++++
.../hadoop/hive/ql/parse/SemanticAnalyzer.java | 6 ++++++
2 files changed, 27 insertions(+)
diff --git
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCTAS.java
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCTAS.java
index 01589323347..4077fd66f0b 100644
---
a/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCTAS.java
+++
b/iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergCTAS.java
@@ -372,4 +372,25 @@ public class TestHiveIcebergCTAS extends
HiveIcebergStorageHandlerWithEngineBase
String ctas = "CREATE TABLE target STORED BY ICEBERG STORED AS orc AS
SELECT * FROM source";
shell.executeStatement(ctas);
}
+
+ @Test
+ public void testCTASAndCTLTWithAuth() {
+ shell.setHiveSessionValue("hive.security.authorization.enabled", true);
+ shell.setHiveSessionValue("hive.security.authorization.manager",
+ "org.apache.iceberg.mr.hive.CustomTestHiveAuthorizerFactory");
+
shell.setHiveSessionValue("hive.security.authorization.tables.on.storagehandlers",
true);
+ TableIdentifier identifier = TableIdentifier.of("default", "customers");
+ String query = String.format("CREATE EXTERNAL TABLE customers (" +
+ "customer_id BIGINT," +
+ "first_name STRING, " +
+ "last_name STRING," +
+ "primary key (customer_id, first_name) disable novalidate)
" +
+ "STORED BY ICEBERG %s TBLPROPERTIES ('%s'='%s')",
+ testTables.locationForCreateTableSQL(identifier),
+ InputFormatConfig.CATALOG_NAME,
+ testTables.catalogName());
+ shell.executeStatement(query);
+ shell.executeStatement("create table target_ctas stored by iceberg stored
as orc as select * from customers");
+ shell.executeStatement("create table target_ctlt like customers stored by
iceberg");
+ }
}
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index cd19ce753c9..506a431ac3d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -14329,6 +14329,8 @@ public class SemanticAnalyzer extends
BaseSemanticAnalyzer {
storageFormat.getInputFormat(), storageFormat.getOutputFormat(),
location,
storageFormat.getSerde(), storageFormat.getSerdeProps(), tblProps,
ifNotExists,
likeTableName, isUserStorageFormat);
+ tblLocation = getDefaultLocation(qualifiedTabName.getDb(),
qualifiedTabName.getTable(), isExt);
+ SessionStateUtil.addResource(conf, META_TABLE_LOCATION, tblLocation);
rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(),
crtTblLikeDesc)));
break;
@@ -14386,7 +14388,11 @@ public class SemanticAnalyzer extends
BaseSemanticAnalyzer {
} catch (IOException ioE) {
LOG.debug("Exception when validate folder", ioE);
}
+ tblLocation = location;
+ } else {
+ tblLocation = getDefaultLocation(qualifiedTabName.getDb(),
qualifiedTabName.getTable(), isExt);
}
+ SessionStateUtil.addResource(conf, META_TABLE_LOCATION, tblLocation);
if (!CollectionUtils.isEmpty(partCols)) {
throw new SemanticException(
"Partition columns can only declared using their names in CTAS
statements");