-
Notifications
You must be signed in to change notification settings - Fork 2k
[Spark] Translate old property ucTableId to io.unitycatalog.tableId when creating a new table. #5609
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
[Spark] Translate old property ucTableId to io.unitycatalog.tableId when creating a new table. #5609
Changes from all commits
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 |
|---|---|---|
|
|
@@ -25,6 +25,8 @@ import scala.collection.JavaConverters._ | |
| import scala.collection.immutable.ListMap | ||
| import scala.collection.mutable | ||
|
|
||
| import io.delta.storage.commit.uccommitcoordinator.UCCommitCoordinatorClient.UC_TABLE_ID_KEY | ||
| import io.delta.storage.commit.uccommitcoordinator.UCCommitCoordinatorClient.UC_TABLE_ID_KEY_OLD | ||
| import org.apache.spark.sql.delta.skipping.clustering.ClusteredTableUtils | ||
| import org.apache.spark.sql.delta.skipping.clustering.temp.{ClusterBy, ClusterBySpec} | ||
| import org.apache.spark.sql.delta.skipping.clustering.temp.{ClusterByTransform => TempClusterByTransform} | ||
|
|
@@ -42,7 +44,6 @@ import org.apache.spark.sql.delta.stats.StatisticsCollection | |
| import org.apache.spark.sql.delta.tablefeatures.DropFeature | ||
| import org.apache.spark.sql.delta.util.{Utils => DeltaUtils} | ||
| import org.apache.spark.sql.delta.util.PartitionUtils | ||
| import org.apache.spark.sql.util.ScalaExtensions._ | ||
| import org.apache.hadoop.fs.Path | ||
|
|
||
| import org.apache.spark.SparkException | ||
|
|
@@ -378,11 +379,12 @@ class AbstractDeltaCatalog extends DelegatingCatalogExtension | |
| if (DeltaSourceUtils.isDeltaDataSourceName(getProvider(properties))) { | ||
| // TODO: we should extract write options from table properties for all the cases. We | ||
| // can remove the UC check when we have confidence. | ||
| val respectOptions = isUnityCatalog || properties.containsKey("test.simulateUC") | ||
|
Collaborator
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. What's the original intention for the
Collaborator
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. Yes it's just for testing purpose in test |
||
| val (props, writeOptions) = if (respectOptions) { | ||
| val isUC = isUnityCatalog || properties.containsKey("test.simulateUC") | ||
| val (props, writeOptions) = if (isUC) { | ||
| val (props, writeOptions) = getTablePropsAndWriteOptions(properties) | ||
| expandTableProps(props, writeOptions, spark.sessionState.conf) | ||
| props.remove("test.simulateUC") | ||
| translateUCTableIdProperty(props) | ||
| (props, writeOptions) | ||
| } else { | ||
| (properties, Map.empty[String, String]) | ||
|
|
@@ -602,6 +604,18 @@ class AbstractDeltaCatalog extends DelegatingCatalogExtension | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * The UC table ID property was renamed from an old name. In a transition period we need to | ||
| * translate the old UC table ID property name set by caller to new one. And in case both the new | ||
| * and old properties are set, remove the old one. Later in UC server it might throw error if it | ||
| * sees both. | ||
| * TODO: clean up once callers are migrated. | ||
|
Collaborator
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. Do we need to explain what are the version that we need to keep this for the compatibility issue ?
Collaborator
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. Primarily for UC-Spark 0.3.1. But it doesn't exist yet so I hesitated to put the specific number in comment. |
||
| */ | ||
| private def translateUCTableIdProperty(props: util.Map[String, String]): Unit = { | ||
| val oldTableIdProperty = Option(props.remove(UC_TABLE_ID_KEY_OLD)) | ||
| oldTableIdProperty.foreach(props.putIfAbsent(UC_TABLE_ID_KEY, _)) | ||
| } | ||
|
|
||
| /** | ||
| * A staged delta table, which creates a HiveMetaStore entry and appends data if this was a | ||
| * CTAS/RTAS command. We have a ugly way of using this API right now, but it's the best way to | ||
|
|
||
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.
I will invite @cloud-fan to help co-review this PR, since he left this TODO comments.