New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for MySQL procedures/functions #901
Comments
SQLFluff does have support for BigQuery and Postgres functions, so it should be possible to support them for MySQL as well. Can you please create a separate issue for |
Yep, no prob. Thanks |
Hi, @barrywhart I tested with PostgreSQL functions but I got errors similar to those reported above. Please find below
|
@db-drive: IIRC, the Postgres dialect does not currently support all the possible delimiters for defining functions. If you see the |
@barrywhart Do you know if this issue will be addressed in the near future? |
My guess would be no. The dialect-specific issues tend to be addressed by someone personally interested in that database. Snowflake and BigQuery have pretty good coverage. Postgres gets some attention, MySQL not so much. Interested in volunteering? |
@barrywhart I would be interested! I read through the contribution guide lines, but I would appreciate it if you would be up for talking about some specifics once I get it running locally via Slack this week. Is that possible? |
Sure! Feel free to chat in Slack. I would encourage just using the #help channel and tagging me if you like. There's a number of friendly, knowledgeable people involved with the project. |
This could be a great first issue. Most dialect changes are fairly straightforward, with a bit of trial and error, maybe a question or two. |
As of version 0.13.0, Examples of valid but unparsable code: CREATE OR REPLACE
DEFINER=`alice`@`localhost`
PROCEDURE p()
SELECT 1; CREATE OR REPLACE
DEFINER=`alice`@`localhost`
FUNCTION f()
RETURNS INT
DETERMINISTIC
RETURN 1; |
There is same issue in snowflake, where $$ dilimited functions and procedures are not parsed. @jivanpal @barrywhart @tunetheweb CREATE OR REPLACE PROCEDURE SQLFLUFF_TEST( $$; Everything between '$$' is not properly parsed, no errors detected. However , when remove dollar signs it is. Should I raise this as a new issue? |
@NoraJama that's a separate issue. The query parses (so doesn't error out like it does for the issue being discussed here) but it does treat everything between This is intentional for now for a few reason:
So yes, procedure/function bodies are currently not linted. But getting them to parse (as it does for Snowflake, but not yet for MySQL) at least allows the surrounding SQL to be linted. So it's a first step. |
For anyone looking for the file linked earlier in this thread, it's https://github.com/sqlfluff/sqlfluff/blob/main/test/fixtures/dialects/postgres/create_function.sql now. It demonstrates usage of CREATE OR REPLACE FUNCTION public.some_func(
date_end TIMESTAMP(3) DEFAULT current_timestamp + interval '3' MONTH,
) RETURNS <stuff> $$ If I remove the |
Hello,
I just try SQLFluff and use it over my MySQL scheme and I was a little sad that it does not parse MySQL routines.
Example :
SQLFluff reports 2
PSR
and 3LXR
.Online Fluff
Is it possible to support routines parsing (and lint them) ?
PS: I also have some trouble with
USE my_db
.The text was updated successfully, but these errors were encountered: