Skip to content
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

Not supporting any MySQL functions! #75

Open
alan-ai-learner opened this issue Sep 8, 2021 · 5 comments
Open

Not supporting any MySQL functions! #75

alan-ai-learner opened this issue Sep 8, 2021 · 5 comments

Comments

@alan-ai-learner
Copy link

alan-ai-learner commented Sep 8, 2021

I'm trying to generate the parse sql queries for any functions like DATE_FORMAT or any other functions using script in the spider repository, preprocess/parse_one_sql.py to generate this parsed sql query and it is working perfectly for some queries, but when i tried this query ,SELECT DATE_FORMAT(date_complaint_raised,'%Y-%m'), count(*) FROM Complaints WHERE YEAR(date_complaint_raised) = value GROUP BY DATE_FORMAT(date_complaint_raised,'%Y-%m'), it gives some date-format assertion error. , while it is working fine with the simple queries(which don't have any function). Can any one please suggest a way to make this script to work for functions as well, and create the parse queries for it. Btw the error im getting is given as.
spider_err
@danielhers @ryanzhumich @IsaWdx @KylinChang @yangkai2g7k

@CrafterKolyan
Copy link

You need to add extra functionality in process_sql.py
Look for AGG_OPS global variable and its' usages. Functions can be implemented the same way, but you'll also need to support comma symbol.

@alan-ai-learner
Copy link
Author

alan-ai-learner commented Sep 9, 2021

You need to add extra functionality in process_sql.py
Look for AGG_OPS global variable and its' usages. Functions can be implemented the same way, but you'll also need to support comma symbol.

Thankyou so much for replying
one more question, like the AGG_OPS, have some limited functions, but the MySQL or other databases has lots of functions, so should i have to put all of them in a predefined variable?
And also the comma you are talking ablut, can you elaborate more, like whats the role of it?

@CrafterKolyan
Copy link

Yes, you should put all the functions in predefined variable. I think you can start with simply extending AGG_OPS with your function (e.g. date_format) but I don't guarantee you that everything would work as expected as this function has two parameters.

Talking about comma: I think that it may be interpreted incorrectly by the whole parser as currently comma is used only in Select query to separate columns and not to separate parameters of functions (this may mean that there's some code like: split select part by comma and parse each part with easier parser, which would lead to incorrect results because it would simply split date_format call into two separate strings and will try to analyze each of them independently and fail.

@alan-ai-learner
Copy link
Author

alan-ai-learner commented Sep 9, 2021

Oh, thanks, alot for your suggestion, it seems like a lot of work. I have to be very precise on writing the code, specifically for handling the function parameters.
I'll try to make it worked.

@alan-ai-learner
Copy link
Author

alan-ai-learner commented Sep 14, 2021

Hi @CrafterKolyan i tried to write the code that support functions, but i was facing the many difficulties, like to differentiate between the blocks DATE_FORMAT(date_complaint_raised,'%Y-%m') and Count(*), parser getting confused , like which is what. Can you please help in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants