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 a6b18d80b [core] AddPartitionCommitCallback should only be created for
partitioned table (#1828)
a6b18d80b is described below
commit a6b18d80bf18f1940d3825609f4f0d3d37c403a9
Author: tsreaper <[email protected]>
AuthorDate: Wed Aug 16 15:19:51 2023 +0800
[core] AddPartitionCommitCallback should only be created for partitioned
table (#1828)
---
.../apache/paimon/table/AbstractFileStoreTable.java | 3 ++-
.../org/apache/paimon/hive/HiveCatalogITCaseBase.java | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
index 8309d0f80..a6ef0a07a 100644
---
a/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
+++
b/paimon-core/src/main/java/org/apache/paimon/table/AbstractFileStoreTable.java
@@ -270,7 +270,8 @@ public abstract class AbstractFileStoreTable implements
FileStoreTable {
private List<CommitCallback> createCommitCallbacks() {
List<CommitCallback> callbacks = new
ArrayList<>(loadCommitCallbacks());
if (coreOptions().partitionedTableInMetastore()
- && catalogEnvironment.metastoreClientFactory() != null) {
+ && catalogEnvironment.metastoreClientFactory() != null
+ && tableSchema.partitionKeys().size() > 0) {
callbacks.add(
new AddPartitionCommitCallback(
catalogEnvironment.metastoreClientFactory().create()));
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 4ebf21136..4da2a2381 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
@@ -831,6 +831,24 @@ public abstract class HiveCatalogITCaseBase {
"ptb=3b/pta=3");
}
+ @Test
+ public void testAddPartitionsToMetastoreForUnpartitionedTable() throws
Exception {
+ tEnv.executeSql(
+ String.join(
+ "\n",
+ "CREATE TABLE t (",
+ " k INT,",
+ " v BIGINT,",
+ " PRIMARY KEY (k) NOT ENFORCED",
+ ") WITH (",
+ " 'bucket' = '2',",
+ " 'metastore.partitioned-table' = 'true'",
+ ")"));
+ tEnv.executeSql("INSERT INTO t VALUES (1, 10), (2, 20)").await();
+ assertThat(hiveShell.executeQuery("SELECT * FROM t ORDER BY k"))
+ .containsExactlyInAnyOrder("1\t10", "2\t20");
+ }
+
protected List<Row> collect(String sql) throws Exception {
List<Row> result = new ArrayList<>();
try (CloseableIterator<Row> it = tEnv.executeSql(sql).collect()) {