Skip to content

Commit 344f2f1

Browse files
authored
Feat: store line/col position for Anonymous functions (#5120)
1 parent de67d3c commit 344f2f1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

sqlglot/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5712,7 +5712,9 @@ def _parse_function_call(
57125712
else:
57135713
if token_type == TokenType.IDENTIFIER:
57145714
this = exp.Identifier(this=this, quoted=True).update_positions(token)
5715+
57155716
this = self.expression(exp.Anonymous, this=this, expressions=args)
5717+
this = this.update_positions(token)
57165718

57175719
if isinstance(this, exp.Expression):
57185720
this.add_comments(comments)

tests/test_parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,9 @@ def test_identifier_meta(self):
985985
{"line": 1, "col": 81, "start": 69, "end": 80},
986986
)
987987

988+
ast = parse_one("SELECT FOO()")
989+
self.assertEqual(ast.find(exp.Anonymous).meta, {"line": 1, "col": 10, "start": 7, "end": 9})
990+
988991
def test_quoted_identifier_meta(self):
989992
sql = 'SELECT "a" FROM "test_schema"."test_table_a"'
990993
ast = parse_one(sql)

0 commit comments

Comments
 (0)