File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
antlr4/org/apache/spark/sql/catalyst/parser
scala/org/apache/spark/sql/catalyst/parser
catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1693,12 +1693,8 @@ stringLitWithoutMarker
1693
1693
;
1694
1694
1695
1695
stringLit
1696
- : stringLitWithoutMarker
1697
- | namedParameterMarkerVal
1698
- ;
1699
-
1700
- namedParameterMarkerVal
1701
- : namedParameterMarker #namedParameterValue
1696
+ : stringLitWithoutMarker #stringLiteralInContext
1697
+ | namedParameterMarker #namedParameterValue
1702
1698
;
1703
1699
1704
1700
comment
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ class DataTypeAstBuilder extends SqlBaseParserBaseVisitor[AnyRef] {
70
70
}
71
71
}
72
72
73
+ override def visitStringLiteralInContext (ctx : StringLiteralInContextContext ): Token = {
74
+ visit(ctx.stringLitWithoutMarker).asInstanceOf [Token ]
75
+ }
76
+
73
77
override def visitNamedParameterValue (ctx : NamedParameterValueContext ): Token = {
74
78
// For namedParameterValue in data type contexts, this shouldn't normally occur
75
79
// This indicates that parameter substitution failed or wasn't applied
@@ -285,7 +289,7 @@ class DataTypeAstBuilder extends SqlBaseParserBaseVisitor[AnyRef] {
285
289
/**
286
290
* Visit a stringLit context by delegating to the appropriate labeled visitor.
287
291
*/
288
- override def visitStringLit (ctx : StringLitContext ): Token = {
292
+ def visitStringLit (ctx : StringLitContext ): Token = {
289
293
visit(ctx).asInstanceOf [Token ]
290
294
}
291
295
Original file line number Diff line number Diff line change @@ -131,6 +131,9 @@ class SubstituteParmsAstBuilder extends SqlBaseParserBaseVisitor[AnyRef] {
131
131
visitNamedParameterValue(ctx)
132
132
case ctx : NamedParameterIntegerValueContext =>
133
133
visitNamedParameterIntegerValue(ctx)
134
+ case ctx : StringLiteralInContextContext =>
135
+ // For string literals in context, continue traversing to find any nested parameters
136
+ visitChildren(ctx)
134
137
case ruleNode : RuleNode =>
135
138
// Continue traversing children for rule nodes
136
139
visitChildren(ruleNode)
Original file line number Diff line number Diff line change @@ -211,13 +211,14 @@ class ParserUtilsSuite extends SparkFunSuite {
211
211
if (token1 != null ) {
212
212
assert(string(token1) == " identifier_with_wildcards" )
213
213
}
214
-
214
+
215
215
val token2 = dataTypeBuilder.visitStringLit(createDbContext.commentSpec().get(0 ).stringLit())
216
216
if (token2 != null ) {
217
217
assert(string(token2) == " database_comment" )
218
218
}
219
219
220
- val token3 = dataTypeBuilder.visitStringLit(createDbContext.locationSpec.asScala.head.stringLit())
220
+ val token3 = dataTypeBuilder.visitStringLit(
221
+ createDbContext.locationSpec.asScala.head.stringLit())
221
222
if (token3 != null ) {
222
223
assert(string(token3) == " /home/user/db" )
223
224
}
You can’t perform that action at this time.
0 commit comments