cloud-fan commented on code in PR #55569:
URL: https://github.com/apache/spark/pull/55569#discussion_r3169014410
##########
sql/core/src/test/scala/org/apache/spark/sql/SetPathSuite.scala:
##########
@@ -361,6 +361,50 @@ class SetPathSuite extends SharedSparkSession {
}
}
+ test("PATH enabled: case-sensitive mode does not treat differently cased
entries as duplicates") {
+ withSQLConf(
+ SQLConf.PATH_ENABLED.key -> "true",
+ SQLConf.CASE_SENSITIVE.key -> "true") {
+ sql("SET PATH = spark_catalog.DEFAULT, spark_catalog.default")
+ val stored = spark.sessionState.catalogManager.sessionPathEntries.get
+ val rendered = stored.map(_.resolve("ignored", Nil).mkString("."))
+ assert(rendered === Seq("spark_catalog.DEFAULT",
"spark_catalog.default"))
+ }
+ }
+
+ test("PATH enabled: unqualified session variable lookup follows PATH") {
+ withPathEnabled {
+ sql("DECLARE VARIABLE system.session.path_var_gate = 7")
+ try {
+ sql("SET PATH = spark_catalog.default")
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql("DROP TEMPORARY VARIABLE path_var_gate")
+ },
+ condition = "UNRESOLVED_VARIABLE",
+ sqlState = "42883",
+ parameters = Map(
+ "variableName" -> "`path_var_gate`",
+ "searchPath" -> "`SYSTEM`.`SESSION`"))
+
+ sql("SET PATH = spark_catalog.default, system.session")
+ sql("DROP TEMPORARY VARIABLE path_var_gate")
+ } finally {
+ sql("DROP TEMPORARY VARIABLE IF EXISTS system.session.path_var_gate")
+ }
+ }
+ }
+
+ test("PATH enabled: current_path does not accept arguments") {
+ withPathEnabled {
+ val e = intercept[AnalysisException] {
+ sql("SET PATH = DEFAULT_PATH")
Review Comment:
`SET PATH = DEFAULT_PATH` is inside the `intercept[AnalysisException]` block
but isn't needed for an arg-count check on a builtin function. If it ever
throws (e.g. if `DEFAULT_PATH` semantics change), the assertion would silently
match the wrong exception. Move it out of the intercept (or drop it).
```suggestion
test("PATH enabled: current_path does not accept arguments") {
withPathEnabled {
val e = intercept[AnalysisException] {
sql("SELECT current_path(1)")
}
assert(e.getCondition == "WRONG_NUM_ARGS.WITHOUT_SUGGESTION",
e.getMessage)
}
}
```
(Aside: other tests in this file use `checkError` with explicit
`condition`/`sqlState`/`parameters` — could migrate for consistency, but that
needs the parameter map to match the actual error and is out of scope here.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]