-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-46272][SQL] Support CTAS using DSv2 sources #44190
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
ec1f3ce
1568aec
05d1647
5f45a13
725ecda
564fbcf
7ed9ad2
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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ import org.apache.spark.SparkUnsupportedOperationException | |
| import org.apache.spark.sql.catalyst.{FunctionIdentifier, SQLConfHelper, TableIdentifier} | ||
| import org.apache.spark.sql.catalyst.analysis.{NoSuchDatabaseException, NoSuchTableException, TableAlreadyExistsException} | ||
| import org.apache.spark.sql.catalyst.catalog.{CatalogDatabase, CatalogStorageFormat, CatalogTable, CatalogTableType, CatalogUtils, ClusterBySpec, SessionCatalog} | ||
| import org.apache.spark.sql.catalyst.util.CharVarcharUtils | ||
| import org.apache.spark.sql.catalyst.util.TypeUtils._ | ||
| import org.apache.spark.sql.connector.catalog.{CatalogManager, CatalogV2Util, Column, FunctionCatalog, Identifier, NamespaceChange, SupportsNamespaces, Table, TableCatalog, TableCatalogCapability, TableChange, V1Table} | ||
| import org.apache.spark.sql.connector.catalog.NamespaceChange.RemoveProperty | ||
|
|
@@ -36,7 +37,7 @@ import org.apache.spark.sql.errors.{QueryCompilationErrors, QueryExecutionErrors | |
| import org.apache.spark.sql.execution.datasources.DataSource | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.internal.connector.V1Function | ||
| import org.apache.spark.sql.types.StructType | ||
| import org.apache.spark.sql.types.{DataType, StructType} | ||
| import org.apache.spark.sql.util.CaseInsensitiveStringMap | ||
| import org.apache.spark.util.ArrayImplicits._ | ||
|
|
||
|
|
@@ -232,7 +233,21 @@ class V2SessionCatalog(catalog: SessionCatalog) | |
| throw QueryCompilationErrors.tableAlreadyExistsError(ident) | ||
| } | ||
|
|
||
| loadTable(ident) | ||
| val table = loadTable(ident) | ||
|
|
||
| // Check if the schema of the created table matches the given schema. | ||
| // TODO: move this check in loadTable to match the behavior with | ||
| // existing file data sources. | ||
| if (schema.nonEmpty) { | ||
| val tableSchema = CharVarcharUtils.replaceCharVarcharWithStringInSchema( | ||
| table.columns().asSchema) | ||
| if (!DataType.equalsIgnoreNullability(tableSchema, schema)) { | ||
|
||
| throw QueryCompilationErrors.dataSourceTableSchemaMismatchError( | ||
| table.columns().asSchema, schema) | ||
| } | ||
| } | ||
|
|
||
| table | ||
| } | ||
|
|
||
| private def toOptions(properties: Map[String, String]): Map[String, String] = { | ||
|
|
||
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.
When we change
src/main, you don't need to use[TESTS], @allisonwang-db .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 see! Thanks for letting me know!