ANTLR4 grammar files for the MaxCompute SQL dialect, used as the reference oracle for testing the SQLGlot MaxCompute dialect.
Grammar files in odps/ are from the public Apache-2.0-licensed repository:
- Repository: https://github.com/aliyun/aliyun-odps-java-sdk
- Path:
odps-sdk/odps-sdk-core/src/main/java/com/aliyun/odps/sqa/commandapi/antlr/sql/ - License: Apache License 2.0
Generate the Python parser from the grammar files:
./grammar/generate.shThis will:
- Download the ANTLR 4.13.2 jar (if not cached)
- Apply Python-compatibility patches to the grammar
- Generate Python lexer/parser into
grammar/generated/
- Java 11+ (
java -version) - Python
antlr4-python3-runtimepackage:uv pip install antlr4-python3-runtime==4.13.2
grammar/
README.md ← this file
generate.sh ← one-shot generation script
odps/
OdpsLexer.g4 ← original grammar (do not edit)
OdpsParser.g4 ← original grammar (do not edit)
generated/ ← output (committed; regenerate via generate.sh)
To update to a newer grammar version:
- Download new
.g4files from the public repo intoodps/ - Run
./grammar/generate.sh - Run
pytest tests/to check for regressions