-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-2990] Sync to HMS when deleting partitions #4291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5d6b8ae
550ba78
301d9ab
c556f44
6184de8
9326eac
1abf0cb
a1610f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,19 @@ | |
|
|
||
| package org.apache.spark.sql.hudi.command | ||
|
|
||
| import org.apache.hudi.{DataSourceWriteOptions, HoodieSparkSqlWriter} | ||
| import org.apache.hudi.DataSourceWriteOptions._ | ||
| import org.apache.hudi.common.util.PartitionPathEncodeUtils | ||
| import org.apache.hudi.config.HoodieWriteConfig.TBL_NAME | ||
|
|
||
| import org.apache.spark.sql.{AnalysisException, Row, SaveMode, SparkSession} | ||
| import org.apache.hudi.hive.MultiPartKeysValueExtractor | ||
| import org.apache.hudi.hive.ddl.HiveSyncMode | ||
| import org.apache.hudi.{DataSourceWriteOptions, HoodieSparkSqlWriter} | ||
| import org.apache.spark.sql.catalyst.TableIdentifier | ||
| import org.apache.spark.sql.catalyst.analysis.Resolver | ||
| import org.apache.spark.sql.catalyst.catalog.CatalogTypes.TablePartitionSpec | ||
| import org.apache.spark.sql.catalyst.catalog.HoodieCatalogTable | ||
| import org.apache.spark.sql.execution.command.{DDLUtils, RunnableCommand} | ||
| import org.apache.spark.sql.hudi.HoodieSqlUtils._ | ||
| import org.apache.spark.sql.{AnalysisException, Row, SaveMode, SparkSession} | ||
|
|
||
| case class AlterHoodieTableDropPartitionCommand( | ||
| tableIdentifier: TableIdentifier, | ||
|
|
@@ -67,7 +68,8 @@ extends RunnableCommand { | |
| val allPartitionPaths = hoodieCatalogTable.getAllPartitionPaths | ||
| val enableHiveStylePartitioning = isHiveStyledPartitioning(allPartitionPaths, table) | ||
| val enableEncodeUrl = isUrlEncodeEnabled(allPartitionPaths, table) | ||
| val partitionsToDelete = normalizedSpecs.map { spec => | ||
| val partitionFields = hoodieCatalogTable.partitionFields.mkString(",") | ||
| val partitionsToDrop = normalizedSpecs.map { spec => | ||
| hoodieCatalogTable.partitionFields.map{ partitionColumn => | ||
| val encodedPartitionValue = if (enableEncodeUrl) { | ||
| PartitionPathEncodeUtils.escapePathName(spec(partitionColumn)) | ||
|
|
@@ -82,16 +84,26 @@ extends RunnableCommand { | |
| }.mkString("/") | ||
| }.mkString(",") | ||
|
|
||
| val enableHive = isEnableHive(sparkSession) | ||
| withSparkConf(sparkSession, Map.empty) { | ||
| Map( | ||
| "path" -> hoodieCatalogTable.tableLocation, | ||
| TBL_NAME.key -> hoodieCatalogTable.tableName, | ||
| TABLE_TYPE.key -> hoodieCatalogTable.tableTypeName, | ||
| OPERATION.key -> DataSourceWriteOptions.DELETE_PARTITION_OPERATION_OPT_VAL, | ||
| PARTITIONS_TO_DELETE.key -> partitionsToDelete, | ||
| PARTITIONS_TO_DELETE.key -> partitionsToDrop, | ||
| RECORDKEY_FIELD.key -> hoodieCatalogTable.primaryKeys.mkString(","), | ||
| PRECOMBINE_FIELD.key -> hoodieCatalogTable.preCombineKey.getOrElse(""), | ||
| PARTITIONPATH_FIELD.key -> hoodieCatalogTable.partitionFields.mkString(",") | ||
| PARTITIONPATH_FIELD.key -> partitionFields, | ||
| HIVE_SYNC_ENABLED.key -> enableHive.toString, | ||
| META_SYNC_ENABLED.key -> enableHive.toString, | ||
| HIVE_SYNC_MODE.key -> HiveSyncMode.HMS.name(), | ||
| HIVE_USE_JDBC.key -> "false", | ||
| HIVE_DATABASE.key -> hoodieCatalogTable.table.identifier.database.getOrElse("default"), | ||
| HIVE_TABLE.key -> hoodieCatalogTable.table.identifier.table, | ||
| HIVE_SUPPORT_TIMESTAMP_TYPE.key -> "true", | ||
| HIVE_PARTITION_FIELDS.key -> partitionFields, | ||
| HIVE_PARTITION_EXTRACTOR_CLASS.key -> classOf[MultiPartKeysValueExtractor].getCanonicalName | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this hardcoding of configs okay? is the user still able to override these with properties supplied at the SQL statement itself?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Regarding this configuration, I need a pr to handle it uniformly. As you said, if spark sql has hive support enabled, you can replace this information from the sql configuration without hard configuration. |
||
| ) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,6 +287,11 @@ public void updatePartitionsToTable(String tableName, List<String> changedPartit | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void dropPartitionsToTable(String tableName, List<String> partitionsToDrop) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: just dropPartitions()? |
||
| throw new UnsupportedOperationException("Not support dropPartitionsToTable yet."); | ||
| } | ||
|
|
||
| public Map<List<String>, String> scanTablePartitions(String tableName) { | ||
| String sql = constructShowPartitionSQL(tableName); | ||
| Statement stmt = null; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we have a helper for this somewhere?