Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3582,6 +3582,12 @@
],
"sqlState" : "0A000"
},
"UNSUPPORTED_DATA_SOURCE_SAVE_MODE" : {
"message" : [
"The data source '<source>' cannot be written in the <createMode> mode. Please use either the \"Append\" or \"Overwrite\" mode instead."
],
"sqlState" : "0A000"
},
"UNSUPPORTED_DATA_TYPE_FOR_DATASOURCE" : {
"message" : [
"The <format> datasource doesn't support the column <columnName> of the type <columnType>."
Expand Down Expand Up @@ -5397,11 +5403,6 @@
"There is a 'path' option set and save() is called with a path parameter. Either remove the path option, or call save() without the parameter. To ignore this check, set '<config>' to 'true'."
]
},
"_LEGACY_ERROR_TEMP_1308" : {
"message" : [
"TableProvider implementation <source> cannot be written with <createMode> mode, please use Append or Overwrite modes instead."
]
},
"_LEGACY_ERROR_TEMP_1309" : {
"message" : [
"insertInto() can't be used together with partitionBy(). Partition columns have already been defined for the table. It is not necessary to use partitionBy()."
Expand Down
6 changes: 6 additions & 0 deletions docs/sql-error-conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,12 @@ Unsupported data source type for direct query on files: `<dataSourceType>`

Unsupported data type `<typeName>`.

### UNSUPPORTED_DATA_SOURCE_SAVE_MODE

[SQLSTATE: 0A000](sql-error-conditions-sqlstates.html#class-0A-feature-not-supported)

The data source '`<source>`' cannot be written in the `<createMode>` mode. Please use either the "Append" or "Overwrite" mode instead.

### UNSUPPORTED_DATA_TYPE_FOR_DATASOURCE

[SQLSTATE: 0A000](sql-error-conditions-sqlstates.html#class-0A-feature-not-supported)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3186,10 +3186,10 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat

def writeWithSaveModeUnsupportedBySourceError(source: String, createMode: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1308",
errorClass = "UNSUPPORTED_DATA_SOURCE_SAVE_MODE",
messageParameters = Map(
"source" -> source,
"createMode" -> createMode))
"createMode" -> toDSOption(createMode)))
}

def partitionByDoesNotAllowedWhenUsingInsertIntoError(): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,21 @@ class PythonDataSourceSuite extends QueryTest with SharedSparkSession {
}

withClue("without mode") {
val error = intercept[AnalysisException] {
spark.range(1).write.format(dataSourceName).save()
}
// TODO: improve this error message.
assert(error.getMessage.contains("TableProvider implementation SimpleDataSource " +
"cannot be written with ErrorIfExists mode, please use Append or Overwrite modes instead."))
checkError(
exception = intercept[AnalysisException] {
spark.range(1).write.format(dataSourceName).save()
},
errorClass = "UNSUPPORTED_DATA_SOURCE_SAVE_MODE",
parameters = Map("source" -> "SimpleDataSource", "createMode" -> "\"ErrorIfExists\""))
}

withClue("with unsupported mode") {
checkError(
exception = intercept[AnalysisException] {
spark.range(1).write.format(dataSourceName).mode("ignore").save()
},
errorClass = "UNSUPPORTED_DATA_SOURCE_SAVE_MODE",
parameters = Map("source" -> "SimpleDataSource", "createMode" -> "\"Ignore\""))
}
}

Expand Down