sql-language-server
sql-language-server copied to clipboard
Question about associating configuration with mime type
I'm using sql-language-server within JupyterLab that is using ipython magics %%sparksql and %%trino
https://github.com/CybercentreCanada/jupyterlab-sql-editor
In that environment each magic is associated with mime type of text/x-sparksql and text/x-trino. There is also an association with file extensions .sparksql and .trino.
I have registered a sql-language-server for each of these mime types. This enables me to switch configurations automatically. When a cell or a file that is of mime type text/x-sparksql it uses the spark configuration. If you edit a cell or file with the trino mime type it uses the other sql-language-server.
I'm now trying to achieve the same behavior in VSCode. That is I would like to switch configurations based on mime type. Either by editing a file with the proper extension or a notebook cell with the proper mime type.
I'm wondering what would entail to switch based on mime type.
@cccs-jc Hi, thanks for your question and sorry for my late reply.
How about adding .spartsqk and .trino here?
https://github.com/joe-re/sql-language-server/blob/v1.2.0/packages/client/extension.ts#L25
I'm not familiar with JupyterLab and if there's some problems you can see please share us, thanks.
this is what I did in JupyterLab. When I detect a %%sparksql magic or a .sparksql file extension I trigger a mime type of x-sparksql.
The mime type x-sparksql is associated with a sql-language-server which is configured to use a json schema file containing the spark tables and functions.
I did this because in JupyterLab I have no way to switch between sql-language-server connections (no way to switch databases)
In VSCode however you've registered actions to do this. So in VSCode I only trigger a mime type of x-sql and it is up to the user to choose the database connection with the VSCode action. So basically I did it this way to be aligned with how sql-language-server is currently working.
However if you would like to support a behavior similar to JupyterLab where the connection is dictated by the cell/file type we could probably do that.
@cccs-jc Hi, thanks for your input.
However if you would like to support a behavior similar to JupyterLab where the connection is dictated by the cell/file type we could probably do that.
I see. Then how about set the connection as default? I understand there's no usecases that users want to connect other DBs for .sparksql or .trino though, if we can provide extra room that a user can overwrite it by configuration file, it's fine.