Kusto Query Language Parser
A parser for parsing KQL queries, including printing parse tree as json and search capabilities. Feel free to request features or make suggestions for improvements
Install
Quick Install
pip install kusto-query-language-parser
Use from Source
Clone repo into your project then run pip install antlr4-python3-runtime==4.13.2
Testing
python -m venv .venv
.venv/bin/pip install -r requirements.txt pytest mypy
.venv/bin/pytest
.venv/bin/mypy .
Usage
Check the examples section for example code and an example KQL query for testing
Parse Code
You will need to pip install antlr4-python3-runtime==4.13.2 for creating a file stream or input stream
This will give you an antlr parse tree; the parser also add some further helper functions
from antlr4 import FileStream, InputStream
from kusto_query_language_parser.parser.kql_traverse import KqlTraverse
# parse from file
input_stream = FileStream('input.txt')
# OR parse from text
input_stream = InputStream('_GetWatchlist("Test")')
parser = KqlTraverse()
tree = parser.parse(input_stream)
Get JSON Tree
Traversing an Antlr parse tree can be tedious, the parser provides an alternate visualization of the tree in JSON
# After obtaining the tree above
listener = parser.traverse(tree)
json_tree = parser.get_json_tree(listener)
Searching
You can also search for functions which also returns the arguments along with function name Any expression can also be searched, you can view the JSON tree to see what expressions are available
functions = parser.find_functions(tree)
# e.g. [{'name': '_GetWatchlist', 'arguments': ["'test'"]}]
references = parser.find(tree, "nameReferenceWithDataScope")
# e.g. ['StartTime', 'State']
Metadata
Release files for kusto-query-language-parser 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kusto_query_language_parser-0.1.0.tar.gz | 227.4 kB | Without provenance | Details for kusto_query_language_parser-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kusto_query_language_parser-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for kusto_query_language_parser-0.1.0-py3-none-any.whl |
Total release size: 457.1 kB
Release files / kusto_query_language_parser-0.1.0.tar.gz
| Download URL | kusto_query_language_parser-0.1.0.tar.gz |
|---|---|
| Size | 227.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad0ffb9f389946b29ac8d929e49fd18625c7c4c62c12423efffff0092f25ddca
|
|
BLAKE2b-256 checksum How to use checksums |
817f14a646083e6a76dcab540b1716c4a72bf59a80a0478852cbd99cab84896e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / kusto_query_language_parser-0.1.0-py3-none-any.whl
| Download URL | kusto_query_language_parser-0.1.0-py3-none-any.whl |
|---|---|
| Size | 229.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ecb1d10cad26409ae9e9af073b15adde341e2f0cc30dec13a008c4cfa8c427bd
|
|
BLAKE2b-256 checksum How to use checksums |
6ebdfb6ab4209aaa26c9622e9be39e9c2ee0ff0cb7e71a37ca3141ad86f32357
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for kusto-query-language-parser 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.