andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.71k stars 693 forks source link

Split trailing semicolon #742

Closed Bisk1 closed 11 months ago

Bisk1 commented 11 months ago

Is your feature request related to a problem? Please describe. Trino is one of the few execution engines that does not accept a trailing semi-colon. sqlparse leaves the semi-colon after splitting. This means that the strings in result list of sqlparse.raw(raw) are not valid SQL for all execution engines.

Describe the solution you'd like Semicolon at the end of statements should be omitted by default (it seems like a safe choice). Alternatively it could be done with a configuration option.

Describe alternatives you've considered The alternative is e.g. to have a separate trimming process that post-processes the result of sqlparse.split(raw). However trimming unnecessary characters feels like a part of splitting process.

Additional context See related Airflow issue: https://github.com/apache/airflow/issues/34828

andialbrecht commented 11 months ago

It's been a while since I last worked with an Oracle database, but some backends had the same requirement IIRC.

Bisk1 commented 11 months ago

@andialbrecht do you plan next release any time soon? this enhancement would unblock a bugfix in Airflow

MikeWallis42 commented 9 months ago

@andialbrecht following up on this one, do you have a release data in mind for 0.5.0?