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/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new baff5050d5 [hive] Add configuration to skip updating Hive stats (#5694)
baff5050d5 is described below
commit baff5050d51486716ee2e6bfd70cd06ae9a29fdf
Author: Sina Siadat <[email protected]>
AuthorDate: Thu Jun 5 15:48:34 2025 +0100
[hive] Add configuration to skip updating Hive stats (#5694)
---
docs/content/iceberg/hive-catalog.md | 6 ++++++
docs/layouts/shortcodes/generated/iceberg_configuration.html | 6 ++++++
.../main/java/org/apache/paimon/iceberg/IcebergOptions.java | 6 ++++++
.../java/org/apache/paimon/hive/HiveAlterTableUtils.java | 6 +++++-
.../apache/paimon/iceberg/IcebergHiveMetadataCommitter.java | 12 ++++++++++--
.../iceberg/IcebergHiveMetadataCommitterITCaseBase.java | 2 ++
6 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/docs/content/iceberg/hive-catalog.md
b/docs/content/iceberg/hive-catalog.md
index b12d4c5b8c..c39c981291 100644
--- a/docs/content/iceberg/hive-catalog.md
+++ b/docs/content/iceberg/hive-catalog.md
@@ -85,6 +85,12 @@ you also need to set some (or all) of the following table
options when creating
<td>Boolean</td>
<td>Skip archive for AWS Glue catalog.</td>
</tr>
+ <tr>
+ <td><h5>metadata.iceberg.hive-skip-update-stats</h5></td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>Skip updating Hive stats.</td>
+ </tr>
</tbody>
</table>
diff --git a/docs/layouts/shortcodes/generated/iceberg_configuration.html
b/docs/layouts/shortcodes/generated/iceberg_configuration.html
index 634f622d71..30c05ef9b5 100644
--- a/docs/layouts/shortcodes/generated/iceberg_configuration.html
+++ b/docs/layouts/shortcodes/generated/iceberg_configuration.html
@@ -80,6 +80,12 @@ under the License.
<td>String</td>
<td>hive-conf-dir for Iceberg Hive catalog.</td>
</tr>
+ <tr>
+ <td><h5>metadata.iceberg.hive-skip-update-stats</h5></td>
+ <td style="word-wrap: break-word;">false</td>
+ <td>Boolean</td>
+ <td>Skip updating Hive stats.</td>
+ </tr>
<tr>
<td><h5>metadata.iceberg.manifest-compression</h5></td>
<td style="word-wrap: break-word;">"snappy"</td>
diff --git
a/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergOptions.java
b/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergOptions.java
index a817364973..2fe9abba26 100644
--- a/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergOptions.java
+++ b/paimon-core/src/main/java/org/apache/paimon/iceberg/IcebergOptions.java
@@ -141,6 +141,12 @@ public class IcebergOptions {
.defaultValue(false)
.withDescription("Skip archive for AWS Glue catalog.");
+ public static final ConfigOption<Boolean> HIVE_SKIP_UPDATE_STATS =
+ key("metadata.iceberg.hive-skip-update-stats")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription("Skip updating Hive stats.");
+
/** Where to store Iceberg metadata. */
public enum StorageType implements DescribedEnum {
DISABLED("disabled", "Disable Iceberg compatibility support."),
diff --git
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveAlterTableUtils.java
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveAlterTableUtils.java
index 8f77499486..06a0df9cff 100644
---
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveAlterTableUtils.java
+++
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveAlterTableUtils.java
@@ -40,9 +40,13 @@ public class HiveAlterTableUtils {
private static void alterTableWithEnv(
IMetaStoreClient client, Identifier identifier, Table table)
throws TException {
+ boolean skipHiveUpdateStats =
+ Boolean.parseBoolean(
+
table.getParameters().get(StatsSetupConst.DO_NOT_UPDATE_STATS));
EnvironmentContext environmentContext = new EnvironmentContext();
environmentContext.putToProperties(StatsSetupConst.CASCADE, "true");
-
environmentContext.putToProperties(StatsSetupConst.DO_NOT_UPDATE_STATS,
"false");
+ environmentContext.putToProperties(
+ StatsSetupConst.DO_NOT_UPDATE_STATS,
Boolean.toString(skipHiveUpdateStats));
client.alter_table_with_environmentContext(
identifier.getDatabaseName(), identifier.getTableName(),
table, environmentContext);
}
diff --git
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitter.java
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitter.java
index 754da1e6a1..6bfe86ad29 100644
---
a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitter.java
+++
b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitter.java
@@ -154,12 +154,17 @@ public class IcebergHiveMetadataCommitter implements
IcebergMetadataCommitter {
.collect(Collectors.toList()));
Options options = new Options(table.options());
- boolean skipAWSGlueArchive =
options.get(IcebergOptions.GLUE_SKIP_ARCHIVE);
EnvironmentContext environmentContext = new EnvironmentContext();
environmentContext.putToProperties(StatsSetupConst.CASCADE,
StatsSetupConst.TRUE);
+
+ boolean skipAWSGlueArchive =
options.get(IcebergOptions.GLUE_SKIP_ARCHIVE);
environmentContext.putToProperties(
"skipAWSGlueArchive", Boolean.toString(skipAWSGlueArchive));
+ boolean skipHiveUpdateStats =
options.get(IcebergOptions.HIVE_SKIP_UPDATE_STATS);
+ environmentContext.putToProperties(
+ StatsSetupConst.DO_NOT_UPDATE_STATS,
Boolean.toString(skipHiveUpdateStats));
+
clients.execute(
client ->
client.alter_table_with_environmentContext(
@@ -207,7 +212,10 @@ public class IcebergHiveMetadataCommitter implements
IcebergMetadataCommitter {
null,
"EXTERNAL_TABLE");
- hiveTable.getParameters().put("DO_NOT_UPDATE_STATS", "true");
+ Options options = new Options(table.options());
+ boolean skipHiveUpdateStats =
options.get(IcebergOptions.HIVE_SKIP_UPDATE_STATS);
+
+ hiveTable.getParameters().put("DO_NOT_UPDATE_STATS",
Boolean.toString(skipHiveUpdateStats));
hiveTable.getParameters().put("EXTERNAL", "TRUE");
hiveTable.getParameters().put("table_type", "ICEBERG");
diff --git
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitterITCaseBase.java
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitterITCaseBase.java
index e783abba88..80d7dcc16e 100644
---
a/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitterITCaseBase.java
+++
b/paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/iceberg/IcebergHiveMetadataCommitterITCaseBase.java
@@ -174,6 +174,7 @@ public abstract class
IcebergHiveMetadataCommitterITCaseBase {
tEnv.executeSql(
"CREATE TABLE my_paimon.test_db.t ( pt INT, id INT, data
STRING ) PARTITIONED BY (pt) WITH "
+ "( 'metadata.iceberg.storage' = 'hive-catalog',
'metadata.iceberg.uri' = '', 'file.format' = 'avro',"
+ + " 'metadata.iceberg.hive-skip-update-stats' =
'true',"
+ " 'metadata.iceberg.glue.skip-archive' = 'true' )");
tEnv.executeSql(
"INSERT INTO my_paimon.test_db.t VALUES "
@@ -261,6 +262,7 @@ public abstract class
IcebergHiveMetadataCommitterITCaseBase {
+ "'metadata.iceberg.storage' =
'hive-catalog', "
+ "'metadata.iceberg.uri' = '', "
+ "'file.format' = 'avro', "
+ + "'metadata.iceberg.hive-skip-update-stats' =
'true', "
+ "'metadata.iceberg.hive-client-class' =
'%s')",
createFailHiveMetaStoreClient()));
assertThrows(