ANTLR grammar fails to parse tabular subquery on the right of in
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
Research direction
Start with the listEqualityExpression rule in Kql.g4 and reproduce the failure using the provided Java ANTLR generation command and Python parser example. Update the grammar so the tabular subquery form parses while preserving the comma-separated invocation form, then rerun the full KQL example and confirm it produces no parse errors.
Written by the indexing model from the issue text.
Description
The KQL docs mention that this is a valid expression:
StormEvents
| where State in (
StormEvents
| summarize count() by State
| top 5 by count_
)
| count
The KQL ANTLR grammar in the repo fails to parse it:
line 5:4 mismatched input '|' expecting {')', ','}
line 7:4 mismatched input ')' expecting {<EOF>, ';'}
This seems to be due to this line in Kql.g4:
listEqualityExpression:
Left=relationalExpression OperatorToken=(IN | NOT_IN | IN_CI | NOT_IN_CI | HAS_ANY | HAS_ALL) '(' Expressions+=invocationExpression (',' Expressions+=invocationExpression)* ')';
which may need to be replaced with something like this (extra pipeExpression):
listEqualityExpression:
Left=relationalExpression OperatorToken=(IN | NOT_IN | IN_CI | NOT_IN_CI | HAS_ANY | HAS_ALL) '(' Subquery=pipeExpression ')'
| Left=relationalExpression OperatorToken=(IN | NOT_IN | IN_CI | NOT_IN_CI | HAS_ANY | HAS_ALL) '(' Expressions+=invocationExpression (',' Expressions+=invocationExpression)* ')'
;
Full repro:
- Install Java 11: https://learn.microsoft.com/en-us/java/openjdk/download
- Install Python 3.14 https://www.python.org/downloads/
- Run
pip install antlr4-python3-runtime==4.13.2 - Download https://repo1.maven.org/maven2/org/antlr/antlr4/4.13.2/antlr4-4.13.2-complete.jar
- Run
java -jar antlr4-4.13.2-complete.jar -Dlanguage=Python3 -visitor -o out Kql.g4 - Use the Python KQL parser:
from antlr4 import InputStream, CommonTokenStream from KqlLexer import KqlLexer from KqlParser import KqlParser def parse(query: str): parser = KqlParser(CommonTokenStream(KqlLexer(InputStream(query)))) tree = parser.top() print(tree.toStringTree(recog=parser)) parse(''' StormEvents | where State in ( StormEvents | summarize count() by State | top 5 by count_ ) | count ''')
- Dominant language
- C#
- Stars
- 680
- Forks
- 122
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/Kusto-Query-Language
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
microsoft/Kusto-Query-Language#189 · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
microsoft/Kusto-Query-Language#188 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoft/Kusto-Query-Language#186 · 1 comment ·
All issues in microsoft/Kusto-Query-Language
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·