Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import org.apache.spark.sql.types.{ArrayType, DataType, MapType, StructField, St
import org.apache.spark.sql.util.PartitioningUtils.normalizePartitionSpec
import org.apache.spark.sql.util.SchemaUtils
import org.apache.spark.util.ArrayImplicits._
import org.apache.spark.util.SparkStringUtils

/**
* Replaces [[UnresolvedRelation]]s if the plan is for direct query on files.
Expand Down Expand Up @@ -106,7 +107,7 @@ class ResolveSQLOnFile(sparkSession: SparkSession) extends Rule[LogicalPlan] {
errorClass = "UNSUPPORTED_DATASOURCE_FOR_DIRECT_QUERY",
messageParameters = Map("dataSourceType" -> ident.head))
}
if (isFileFormat && ident.last.isEmpty) {
if (isFileFormat && SparkStringUtils.isBlank(ident.last)) {
unresolved.failAnalysis(
errorClass = "INVALID_EMPTY_LOCATION",
messageParameters = Map("location" -> ident.last))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,15 @@ class SQLQuerySuite extends SharedSparkSession with AdaptiveSparkPlanHelper
}
assert(e.message.contains("Unsupported data source type for direct query on files: " +
"org.apache.spark.sql.execution.datasources.jdbc"))

// Test for empty and whitespace-only paths
Seq("", " ", "\t", "\n", "\t\n", " \t ").foreach { location =>
val e = intercept[AnalysisException] {
sql(s"select id from json.`$location`")
}
assert(e.message.contains("The location name cannot be empty string"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test uses assert(e.message.contains(...)) instead of the structured checkError(condition = "INVALID_EMPTY_LOCATION", parameters = Map("location" -> location)) form used by the sibling tests.

contains is brittle and can false-pass; switching to checkError would match sibling convention and validate the exact condition code + params. Please update accordingly.

assert(e.message.contains(s"`$location`"))
}
}

test("SortMergeJoin returns wrong results when using UnsafeRows") {
Expand Down