This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 288381d7d [hive] Open the cascade to update (#2721)
288381d7d is described below
commit 288381d7d893482b4a7cd8fe64e0a2961a78d543
Author: monster <[email protected]>
AuthorDate: Thu Jan 25 16:34:57 2024 +0800
[hive] Open the cascade to update (#2721)
---
.../java/org/apache/paimon/hive/HiveCatalog.java | 3 +-
.../paimon/hive/AlterFailHiveMetaStoreClient.java | 3 +-
.../paimon/hive/AlterFailHiveMetaStoreClient.java | 3 +-
.../apache/paimon/hive/HiveCatalogITCaseBase.java | 35 ++++++++++++++++++++++
4 files changed, 41 insertions(+), 3 deletions(-)
diff --git
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
index ecf624c70..69109e552 100644
---
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
+++
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java
@@ -439,7 +439,8 @@ public class HiveCatalog extends AbstractCatalog {
// sync to hive hms
Table table = client.getTable(identifier.getDatabaseName(),
identifier.getObjectName());
updateHmsTable(table, identifier, schema);
- client.alter_table(identifier.getDatabaseName(),
identifier.getObjectName(), table);
+ client.alter_table(
+ identifier.getDatabaseName(), identifier.getObjectName(),
table, true);
} catch (Exception te) {
schemaManager.deleteSchema(schema.id());
throw new RuntimeException(te);
diff --git
a/paimon-hive/paimon-hive-connector-2.3/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
b/paimon-hive/paimon-hive-connector-2.3/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
index a34785993..ebd4684ed 100644
---
a/paimon-hive/paimon-hive-connector-2.3/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
+++
b/paimon-hive/paimon-hive-connector-2.3/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
@@ -46,7 +46,8 @@ public class AlterFailHiveMetaStoreClient extends
HiveMetaStoreClient implements
}
@Override
- public void alter_table(String defaultDatabaseName, String tblName, Table
table)
+ public void alter_table(
+ String defaultDatabaseName, String tblName, Table table, boolean
cascade)
throws InvalidOperationException, MetaException, TException {
throw new TException();
}
diff --git
a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
index 6bdbb38ea..ae6a1bb85 100644
---
a/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
+++
b/paimon-hive/paimon-hive-connector-3.1/src/test/java/org/apache/paimon/hive/AlterFailHiveMetaStoreClient.java
@@ -46,7 +46,8 @@ public class AlterFailHiveMetaStoreClient extends
HiveMetaStoreClient implements
}
@Override
- public void alter_table(String defaultDatabaseName, String tblName, Table
table)
+ public void alter_table(
+ String defaultDatabaseName, String tblName, Table table, boolean
cascade)
throws InvalidOperationException, MetaException, TException {
throw new TException();
}
diff --git
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
index 874499856..051a23979 100644
---
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
+++
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java
@@ -935,6 +935,41 @@ public abstract class HiveCatalogITCaseBase {
"4\t40\t2023-10-17");
}
+ @Test
+ public void testHistoryPartitionsCascadeToUpdate() throws Exception {
+ tEnv.executeSql(
+ String.join(
+ "\n",
+ "CREATE TABLE t (",
+ " k INT,",
+ " v BIGINT,",
+ " PRIMARY KEY (k) NOT ENFORCED",
+ ") WITH (",
+ " 'bucket' = '2',",
+ " 'metastore.tag-to-partition' = 'dt'",
+ ")"));
+ tEnv.executeSql("INSERT INTO t VALUES (1, 10), (2, 20)").await();
+ tEnv.executeSql("CALL sys.create_tag('test_db.t', '2023-10-16', 1)");
+
+ assertThat(hiveShell.executeQuery("SHOW PARTITIONS t"))
+ .containsExactlyInAnyOrder("dt=2023-10-16");
+
+ assertThat(hiveShell.executeQuery("SELECT k, v FROM t WHERE
dt='2023-10-16'"))
+ .containsExactlyInAnyOrder("1\t10", "2\t20");
+
+ assertThat(hiveShell.executeQuery("SELECT * FROM t WHERE
dt='2023-10-16'"))
+ .containsExactlyInAnyOrder("1\t10\t2023-10-16",
"2\t20\t2023-10-16");
+
+ tEnv.executeSql("INSERT INTO t VALUES (3, 30), (4, 40)").await();
+ tEnv.executeSql("CALL sys.create_tag('test_db.t', '2023-10-17', 2)");
+
+ tEnv.executeSql("ALTER TABLE t ADD z INT");
+ tEnv.executeSql("INSERT INTO t VALUES (3, 30, 5), (4, 40, 6)").await();
+
+ assertThat(hiveShell.executeQuery("SELECT * FROM t WHERE
dt='2023-10-16'"))
+ .containsExactlyInAnyOrder("1\t10\tNULL\t2023-10-16",
"2\t20\tNULL\t2023-10-16");
+ }
+
@Test
public void testAddPartitionsForTagPreview() throws Exception {
tEnv.executeSql(