-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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-37496][SQL] Migrate ReplaceTableAsSelectStatement to v2 command #34754
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 |
---|---|---|
|
@@ -23,10 +23,10 @@ import scala.collection.JavaConverters._ | |
|
||
import org.apache.spark.annotation.Stable | ||
import org.apache.spark.sql.catalyst.TableIdentifier | ||
import org.apache.spark.sql.catalyst.analysis.{EliminateSubqueryAliases, NoSuchTableException, UnresolvedRelation} | ||
import org.apache.spark.sql.catalyst.analysis.{EliminateSubqueryAliases, NoSuchTableException, UnresolvedDBObjectName, UnresolvedRelation} | ||
import org.apache.spark.sql.catalyst.catalog._ | ||
import org.apache.spark.sql.catalyst.expressions.Literal | ||
import org.apache.spark.sql.catalyst.plans.logical.{AppendData, CreateTableAsSelect, CreateTableAsSelectStatement, InsertIntoStatement, LogicalPlan, OverwriteByExpression, OverwritePartitionsDynamic, ReplaceTableAsSelectStatement} | ||
import org.apache.spark.sql.catalyst.plans.logical.{AppendData, CreateTableAsSelect, CreateTableAsSelectStatement, InsertIntoStatement, LogicalPlan, OverwriteByExpression, OverwritePartitionsDynamic, ReplaceTableAsSelect, TableSpec} | ||
import org.apache.spark.sql.catalyst.util.CaseInsensitiveMap | ||
import org.apache.spark.sql.connector.catalog.{CatalogPlugin, CatalogV2Implicits, CatalogV2Util, Identifier, SupportsCatalogOptions, Table, TableCatalog, TableProvider, V1Table} | ||
import org.apache.spark.sql.connector.catalog.TableCapability._ | ||
|
@@ -586,19 +586,22 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) { | |
AppendData.byName(v2Relation, df.logicalPlan, extraOptions.toMap) | ||
|
||
case (SaveMode.Overwrite, _) => | ||
ReplaceTableAsSelectStatement( | ||
nameParts, | ||
df.queryExecution.analyzed, | ||
val tableSpec = TableSpec( | ||
bucketSpec = None, | ||
properties = Map.empty, | ||
provider = Some(source), | ||
options = Map.empty, | ||
location = extraOptions.get("path"), | ||
comment = extraOptions.get(TableCatalog.PROP_COMMENT), | ||
serde = None, | ||
external = false) | ||
ReplaceTableAsSelect( | ||
UnresolvedDBObjectName(nameParts, isNamespace = false), | ||
partitioningAsV2, | ||
None, | ||
Map.empty, | ||
Some(source), | ||
Map.empty, | ||
extraOptions.get("path"), | ||
extraOptions.get(TableCatalog.PROP_COMMENT), | ||
extraOptions.toMap, | ||
None, | ||
orCreate = true) // Create the table if it doesn't exist | ||
df.queryExecution.analyzed, | ||
tableSpec, | ||
writeOptions = Map.empty, | ||
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. I think there is a bug here. Previously we pass 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. Sorry for the bug. Will fix. |
||
orCreate = true) // Create the table if it doesn't exist | ||
|
||
case (other, _) => | ||
// We have a potential race condition here in AppendMode, if the table suddenly gets | ||
|
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.
shall we prepend
catalog.name
?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.
Seems no need? I stepped into one of the test, the
nameParts
here is "testcat", "ns", "t", so it already containscatalog.name
.