@@ -119,6 +119,7 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession {
119119
120120 test(" using _FUNC_ instead of function names in examples" ) {
121121 val exampleRe = " (>.*;)" .r
122+ val setStmtRe = " (?i)^(>\\ s+set\\ s+).+" .r
122123 val ignoreSet = Set (
123124 // Examples for CaseWhen show simpler syntax:
124125 // `CASE WHEN ... THEN ... WHEN ... THEN ... END`
@@ -128,16 +129,16 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession {
128129 // _FUNC_ is replaced by `%` which causes a parsing error on `SELECT %(2, 1.8)`
129130 " org.apache.spark.sql.catalyst.expressions.Remainder" ,
130131 // Examples demonstrate alternative names, see SPARK-20749
131- " org.apache.spark.sql.catalyst.expressions.Length" ,
132- // Uses settings without _FUNC_ in `SET spark.sql.parser.escapedStringLiterals=true`
133- " org.apache.spark.sql.catalyst.expressions.RLike" )
132+ " org.apache.spark.sql.catalyst.expressions.Length" )
134133 spark.sessionState.functionRegistry.listFunction().foreach { funcId =>
135134 val info = spark.sessionState.catalog.lookupFunctionInfo(funcId)
136135 val className = info.getClassName
137136 withClue(s " Expression class ' $className' " ) {
138137 val exprExamples = info.getOriginalExamples
139138 if (! exprExamples.isEmpty && ! ignoreSet.contains(className)) {
140- assert(exampleRe.findAllIn(exprExamples).toSet.forall(_.contains(" _FUNC_" )))
139+ assert(exampleRe.findAllIn(exprExamples).toIterable
140+ .filter(setStmtRe.findFirstIn(_).isEmpty) // Ignore SET commands
141+ .forall(_.contains(" _FUNC_" )))
141142 }
142143 }
143144 }
0 commit comments