CybercentreCanada / jupyterlab-sql-editor

A JupyterLab extension providing, SQL formatter, auto-completion, syntax highlighting, Spark SQL and Trino
BSD 3-Clause "New" or "Revised" License
83 stars 13 forks source link

%trino SHOW CATALOGS adding LIMIT clause by default resulting in ERROR #97

Closed gmrqs closed 1 year ago

gmrqs commented 1 year ago

Hi people of CyberCentreCanada.

Really loved the project, had a bit trouble installing but managed to use the Trino magics.

I noticed that in

https://github.com/CybercentreCanada/jupyterlab-sql-editor/blob/main/example/Trino.ipynb

there is a cell with '%trino SHOW CATALOGS' commented out. I realized that it wasn't working when trying out the command and that is because in your code there must be an automatic 'LIMIT n' on every query resulting in the error:

TrinoUserError: TrinoUserError(type=USER_ERROR, name=SYNTAX_ERROR, message="line 1:15: mismatched input 'limit'. Expecting: 'LIKE', <EOF>", query_id=20230504_184729_00795_e8dqv)

Managed to make it work by injecting comment dashes in the code and escaping the LIMIT clause.

%trino SHOW CATALOGS--

don't really know what you could do to fix that, but just wanted to show my workaround and provide feedback to this excelent project.

Cheers

gmrqs commented 1 year ago

here's an example:

image

cccs-nik commented 1 year ago

Hello! You're meant to use the --raw parameter for anything that isn't a SELECT (https://github.com/CybercentreCanada/jupyterlab-sql-editor/blob/03104f5f7326a9dc984f72d88482644f97cbf3e0/README.md#trino) but quite frankly you shouldn't have to think about that at all. Should be fairly simple to implement a check which fixes your issue without having to use the --raw parameter, I'll look into it!

cccs-nik commented 1 year ago

Fixed in #131. That ended up being even easier than I thought with the previous improvement I just did for the LIMIT 👍