[
https://issues.apache.org/jira/browse/HIVE-26012?focusedWorklogId=799263&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-799263
]
ASF GitHub Bot logged work on HIVE-26012:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Aug/22 11:07
Start Date: 09/Aug/22 11:07
Worklog Time Spent: 10m
Work Description: dengzhhu653 commented on code in PR #3477:
URL: https://github.com/apache/hive/pull/3477#discussion_r941205221
##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java:
##########
@@ -3717,4 +3683,104 @@ public void testDropDataConnectorIfNotExistsTrue()
throws Exception {
// No such data connector, ignore NoSuchObjectException
client.dropDataConnector("no_such_data_connector", true, false);
}
+
+ @Test
+ public void testIfFSWritesIsSkippedForDatabase() throws Throwable {
+ // create a database, check if the directory is created or not
+ // with true, the directory is not created
+ // with false, the directory is created
+ try {
+ // clear up any existing databases
+ silentDropDatabase(TEST_DB1_NAME);
+
+ String dbLocation =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL) +
"/testdb1.db";
+ String mgdLocation =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) + "/testdb1.db";
+
+ CreateDatabaseRequest req = new CreateDatabaseRequest();
+ req.setSkipFSWrites(true);
+ Database db = new DatabaseBuilder()
+ .setName(TEST_DB1_NAME)
+ .setLocation(dbLocation)
+ .setManagedLocation(mgdLocation)
+ .build(conf);
+ req.setDatabase(db);
+ req.setDatabaseName(TEST_DB1_NAME);
+ req.setLocationUri(dbLocation);
+ req.setManagedLocationUri(mgdLocation);
+ client.createDatabase(req);
+
+ FileSystem fs = FileSystem.get(new Path(dbLocation).toUri(), conf);
+ assertFalse("Database's file system directory is skipped", fs.exists(new
Path(dbLocation)));
+ fs = FileSystem.get(new Path(mgdLocation).toUri(), conf);
+ assertFalse("Database's managed location is not skipped", fs.exists(new
Path(mgdLocation)));
+ } catch (Throwable e) {
+ System.err.println(StringUtils.stringifyException(e));
+ e.printStackTrace();
+ System.err.println("testIfFSWritesIsSkippedForDatabase() failed.");
+ throw e;
+ }
+ }
+
+ @Test
+ public void testIfFSWritesIsSkippedForTable() throws Throwable {
+ // create a database, check if the directory is created or not
+ // with true, the directory is not created
+ // with false, the directory is created
+ try {
+ // clear up any existing databases
+ silentDropDatabase(TEST_DB1_NAME);
+ String tableName1 = "test_table1";
+ String tableName2 = "test_table2";
+
+ String dbLocation =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL) +
"/testdb1.db";
+ String mgdLocation =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) + "/testdb1.db";
+
+ Database db = new DatabaseBuilder()
+ .setName(TEST_DB1_NAME)
+ .setLocation(dbLocation)
+ .setManagedLocation(mgdLocation)
+ .build(conf);
+ client.createDatabase(db);
+
+ Table tbl1 = new TableBuilder()
+ .setDbName(TEST_DB1_NAME)
+ .setTableName(tableName1)
+ .addCol("name", ColumnType.STRING_TYPE_NAME)
+ .addCol("income", ColumnType.INT_TYPE_NAME)
+ .create(client, conf);
+
+ Table tbl2 = new TableBuilder()
+ .setDbName(TEST_DB1_NAME)
+ .setTableName(tableName2)
+ .addCol("name", ColumnType.STRING_TYPE_NAME)
+ .addCol("income", ColumnType.INT_TYPE_NAME)
+ .create(client, conf);
+
+ CreateTableRequest tblReq1 = new CreateTableRequest();
+ tblReq1.setTable(tbl1);
+ tblReq1.setSkipFSWrites(true);
+ String tbl1Location =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL) +
"/testdb1.db/test_table1";
+
+ CreateTableRequest tblReq2 = new CreateTableRequest();
+ tblReq2.setTable(tbl2);
+ tblReq2.setSkipFSWrites(false);
+ String tbl2Location =
+ MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) +
"/testdb1.db/test_table2";
+
+ Path dbPath = new Path(db.getLocationUri());
+ FileSystem fs = FileSystem.get(new Path(dbLocation).toUri(), conf);
Review Comment:
Should check the table path?
Issue Time Tracking
-------------------
Worklog Id: (was: 799263)
Time Spent: 2h (was: 1h 50m)
> HMS APIs to be enhanced for metadata replication
> ------------------------------------------------
>
> Key: HIVE-26012
> URL: https://issues.apache.org/jira/browse/HIVE-26012
> Project: Hive
> Issue Type: Improvement
> Components: Metastore
> Affects Versions: 3.1.0
> Reporter: Naveen Gangam
> Assignee: Hongdan Zhu
> Priority: Major
> Labels: pull-request-available
> Attachments: HMS APIs to be enhanced for metadata replication.docx
>
> Time Spent: 2h
> Remaining Estimate: 0h
>
> HMS currently has APIs like these that automatically create/delete the
> directories on the associated DFS.
> [create/drop]_database
> [create/drop]_table*
> [add/append/drop]_partition*
> This is expected and should be this way when query processors use this APIs.
> However, when tools that replicate hive metadata use this APIs on the target
> cluster, creating these dirs on target side which cause the replication of
> DFS-snapshots to fail.
> So we if provide an option to bypass this creation of dirs, dfs replications
> will be smoother. In the future we will need to restrict users that can use
> these APIs. So we will have some sort of an authorization policy.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)