-
Notifications
You must be signed in to change notification settings - Fork 91
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
Extend extract function to support DateTime data types #227
Conversation
Add new getPlanner() methods in Frameworks.java to accept a SqlRexConvertletTable Raise an exception in StandardConvertletTable if extracting from a DATETTIME data type.
Can you add some tests to |
} | ||
|
||
/** Piece of code to be run in a context where a planner is available. The |
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.
fix indent
"Can you add some tests to SqlOperatorBaseTest (maybe add a method below testExtractFunc). Then we can see that this function produces the right results." Did you want me to add negative tests, because StandardConvertletTable.convertExtract() will currently throw an exception if the second input is a DATETIME type. Or did you want me to modify StandardConvertletTable, because the current multipliers in convertExtract() wouldn't work with DATETIME types. |
Can you write a test. If you can't easily get it to pass then you can add @ignore. In the long run, it will benefit you Drill developers, when you get round to calling SqlOperatorTest on your own operator implementations. |
Add test to SqlOperatorBaseTest. Use a singleton in StandardConvertletTable. Minor cleanup Remove newly added constructor in PlannerImpl Remove newly added getPlanner method in Frameworks.
Thanks for the quick reply. I've added tests to SqlOperatorBaseTest. convertExtract() function in StandardConvertletTable will need to be enhanced to handle DATETIME types. I can create a separate issue to address this and work on it. Made the other changes suggested by you. |
Currently extract() function only supports extracting time units from an Interval data type. This patch extends the extract() function to support DateTime.
In StandardConvertletTable() we reinterpret the extract() function to be a '/' expression based on the input data types. The problem is for Drill we cannot rewrite the extract() function this early because the data types are still 'ANY' and we cannot determine the multiplier to be used in the '/' expression while rewriting it.
Drill will extend the StandardConvertletTable() and override the convertExtract() method to simply treat it like a regular function and not rewrite it.