Metadata-Version: 2.1
Name: trino-query-parser
Version: 0.408.7
Summary: Provides a parser for trino queries
Author-email: Gregory Borodin <grihabor@gmail.com>
License: Apache 2.0
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Description-Content-Type: text/x-rst
Requires-Dist: antlr4-python3-runtime (==4.13.0)
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'

trino-query-parser
==================

|pypi| |python|

.. |pypi| image:: https://img.shields.io/pypi/v/trino-query-parser
  :alt: PyPI

.. |python| image:: https://img.shields.io/pypi/pyversions/trino-query-parser
  :alt: PyPI - Python Version

The package provides a parser for trino queries.

Install
-------

To install the package run:

.. code-block:: bash

    pip install trino-query-parser

Example
-------

.. code-block:: python3

    >>> from trino_query_parser import parse_statement
    >>> parse_statement('select * from x.y')
    [['SELECT', '*', 'FROM', ['X', '.', 'Y']], '<EOF>']

Details
-------

:code:`trino-query-parser` uses `trino antlr4 grammar <https://raw.githubusercontent.com/trinodb/trino/405/core/trino-parser/src/main/antlr4/io/trino/sql/parser/SqlBase.g4>`_ to generate python parser code.

If you care about specific version of :code:`trino`, install the corresponding version of :code:`trino-query-parser`.

For example, for :code:`trino-405` run:

.. code-block:: bash

    pip install trino-query-parser~=0.405.0

If there is no such version, feel free to open an issue.

.. warning::

    Be careful, API is not stable, it might change in new versions

Development
-----------

To generate antlr4 parser code run:

.. code-block:: bash

    make generate-code

To install development dependencies run:

.. code-block:: bash

    pip install -e .[test]
