-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-30098][SQL] Add a configuration to use default datasource as provider for CREATE TABLE command #30554
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
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 |
---|---|---|
|
@@ -2922,6 +2922,15 @@ object SQLConf { | |
.stringConf | ||
.createWithDefault("") | ||
|
||
val LEGACY_CREATE_HIVE_TABLE_BY_DEFAULT = | ||
buildConf("spark.sql.legacy.createHiveTableByDefault") | ||
.internal() | ||
.doc("When set to true, CREATE TABLE syntax without USING or STORED AS will use Hive " + | ||
s"instead of the value of ${DEFAULT_DATA_SOURCE_NAME.key} as the table provider.") | ||
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. If this is a "legacy" key mention how long folks can depend on it. 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. There are already a lot of legacy configurations, and there's no plan for how long we'll keep it. That's what I know as far as I have followed in the community. It would be a separate issue to decide lifetime of legacy configurations but ideally the legacy configurations will be removed in the major release bumpup I guess. I remember I discussed this with Sean as well somewhere. cc @srowen FYI 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. If we have a general policy for legacy configs that means this remains the same until Spark 4 by default I guess there is no need to document it here (I don't remember that conversation but I was out for a few months last/this year). |
||
.version("3.1.0") | ||
.booleanConf | ||
.createWithDefault(true) | ||
|
||
/** | ||
* Holds information about keys that have been deprecated. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import org.apache.spark.sql.connector.expressions.Transform | |
import org.apache.spark.sql.execution.command._ | ||
import org.apache.spark.sql.execution.datasources.{CreateTable, DataSource} | ||
import org.apache.spark.sql.execution.datasources.v2.FileDataSourceV2 | ||
import org.apache.spark.sql.internal.HiveSerDe | ||
import org.apache.spark.sql.internal.{HiveSerDe, SQLConf} | ||
import org.apache.spark.sql.types.{MetadataBuilder, StructField, StructType} | ||
|
||
/** | ||
|
@@ -636,11 +636,16 @@ class ResolveSessionCatalog( | |
(storageFormat, DDLUtils.HIVE_PROVIDER) | ||
} else { | ||
// If neither USING nor STORED AS/ROW FORMAT is specified, we create native data source | ||
// tables if it's a CTAS and `conf.convertCTAS` is true. | ||
// TODO: create native data source table by default for non-CTAS. | ||
if (ctas && conf.convertCTAS) { | ||
// tables if: | ||
// 1. `LEGACY_CREATE_HIVE_TABLE_BY_DEFAULT` is false, or | ||
// 2. It's a CTAS and `conf.convertCTAS` is true. | ||
val createHiveTableByDefault = conf.getConf(SQLConf.LEGACY_CREATE_HIVE_TABLE_BY_DEFAULT) | ||
HyukjinKwon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!createHiveTableByDefault || (ctas && conf.convertCTAS)) { | ||
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. Should this mark 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. yea, I can do it in a follow-up. |
||
(nonHiveStorageFormat, conf.defaultDataSourceName) | ||
} else { | ||
logWarning("A Hive serde table will be created as there is no table provider " + | ||
s"specified. You can set ${SQLConf.LEGACY_CREATE_HIVE_TABLE_BY_DEFAULT.key} to false " + | ||
"so that native data source table will be created instead.") | ||
(defaultHiveStorage, DDLUtils.HIVE_PROVIDER) | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.