You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ur...@apache.org on 2026/08/05 07:19:43 UTC

(spark) branch branch-4.3 updated: [SPARK-58566][SQL][TEST] Add tests for QuotingUtils.quoteIdentifier and escapeSingleQuotedString

This is an automated email from the ASF dual-hosted git repository.

uros-b pushed a commit to branch branch-4.3
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.3 by this push:
     new a3d90b8c449e [SPARK-58566][SQL][TEST] Add tests for QuotingUtils.quoteIdentifier and escapeSingleQuotedString
a3d90b8c449e is described below

commit a3d90b8c449e56d9c915fad6fb917d56aed523f4
Author: Uros Bojanic <22...@users.noreply.github.com>
AuthorDate: Wed Aug 5 07:19:14 2026 +0000

    [SPARK-58566][SQL][TEST] Add tests for QuotingUtils.quoteIdentifier and escapeSingleQuotedString
    
    ### What changes were proposed in this pull request?
    Adds unit tests for `QuotingUtils.quoteIdentifier` and `escapeSingleQuotedString`, which had no direct coverage.
    
    ### Why are the changes needed?
    These pure string helpers back-tick-escape identifiers and backslash-escape single quotes; the tests pin their contract (wrapping, doubling, escaping, empty input).
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    This PR is the test. `build/sbt "catalyst/testOnly *QuotingUtilsSuite"`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    Generated-by: Claude Code (Opus 4.8)
    
    Closes #57766 from uros-b/test-quotingutils.
    
    Authored-by: Uros Bojanic <22...@users.noreply.github.com>
    Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
    (cherry picked from commit 6521926f90d44a1195ad4ef36b6a4832747d44b3)
    Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
---
 .../apache/spark/sql/catalyst/util/QuotingUtilsSuite.scala  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/QuotingUtilsSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/QuotingUtilsSuite.scala
index 259284d7c405..c7d1280220a3 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/QuotingUtilsSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/QuotingUtilsSuite.scala
@@ -40,4 +40,17 @@ class QuotingUtilsSuite extends SparkFunSuite {
     assert(quoteIfNeeded("0d") == "`0d`")
     assert(quoteIfNeeded("") === "``")
   }
+
+  test("quoteIdentifier escapes back-ticks and always wraps") {
+    assert(QuotingUtils.quoteIdentifier("a") === "`a`")
+    assert(QuotingUtils.quoteIdentifier("") === "``")
+    assert(QuotingUtils.quoteIdentifier("a`b") === "`a``b`")
+    assert(QuotingUtils.quoteIdentifier("`") === "````")
+  }
+
+  test("escapeSingleQuotedString escapes single quotes only") {
+    assert(QuotingUtils.escapeSingleQuotedString("abc") === "abc")
+    assert(QuotingUtils.escapeSingleQuotedString("a'b") === "a\\'b")
+    assert(QuotingUtils.escapeSingleQuotedString("''") === "\\'\\'")
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org