-
Notifications
You must be signed in to change notification settings - Fork 665
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 _all_ date function aliases to parser (extended) #1982
base: develop
Are you sure you want to change the base?
Add _all_ date function aliases to parser (extended) #1982
Conversation
- Add all other AlaSQL date functions and aliases to the parser - Adjust unit tests, as month is now a reserved keyword - Explicitly didn't add the "DATE()" function, as it's use is very ambiguous in AlaSQL -> as column alias, as column type, as JS expression. - Added IntervalLiteral which contains all possible values to use when specifying an interval expression
- Use Expression instead of ExprList to restrict the number of arguments to the methods
- Extend unit test with non existing interval - DAYOFYEAR is alias for DAY
- Compact the expression with an OR statement to reduce duplicate code
I really like this, but im a bit sad to break lots of current implementation by making Over the Christmas break I will see if I can make this work so its only a protected keyword as the first parameter in the date functions, and other places we look for the name plus a |
Still working on this. Neck deep in the jungle of JISON. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a few questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a few questions
@mathiasrw i processed your comments and made some changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have been more clear.
I cant find documentation that dayofyear
and dayofmonth
is a valid unit for interval
. I have a feeling those two should not be part of interval literals. What are you seeing that I am not seeing?
Ill pick up the rest and work on it not being breaking. |
Based on #1980, this PR attempts to add all relevant date functions to the parser (and thus validate the query for being valid).
NOW
GETDATE
CURRENT_DATE()
ADDDATE(args)
SUBDATE(args)
DAY(date)
DAYOFMONTH(date)
DAYOFWEEK(date)
DATE_ADD(args)
DATE_SUB(args)
SUBDATE(args)
MINUTE(date)
SECOND(date)
MONTH(date)
YEAR(date)
WEEK(date)
WEEKDAY(date)
Additional: the interval values that can be specified are now also part of the parser:
This makes some keywords now reserved keywords, like using
month
as column alias for example.This has been adjusted in this PR.
Do note that
DATE()
is not added to the parser, as its use is very ambigious in AlaSQL.There are new unit tests that verify the changes made.