-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
support: Date +/plus Int or date_add function #6876
Comments
👍 -- I believe @tustvold is cleaning up the arithmetic logic in arrow-rs / datafusion now What types can the |
It takes integers:
|
https://spark.apache.org/docs/2.3.0/api/sql/#date_add It appears that date_add should take the number of days as the second argument To model this in DataFusion you could probably do a rewrite like this
You could also add a new built in function (which would probably make the type casting logic more explicit) |
Ok, I will take look this work and track this process of work
In the spark
There is a specific analyse rule to handle the data/time with the operation of arithmetic, the rule convert the
because the PG support the operation
So I want to support the more arithmetic operation for date/time/timestamp/interval in the datafusion(maybe we can implement them in the arrow-rs). The date operated by the arithmetic operation is required in the sql system or the query engine, So i don't know if the implementation of above operation in the arrow-rs kernel is suitable? |
Upstream will, in the next release, support date subtraction returning a duration in addition to adding durations or intervals to dates. I think the semantics of adding plain integers to dates is suitably opaque that we probably won't support that upstream, but the approach of using a rewrite to convert to a duration makes a lot of sense |
Postgres has a function
Would this help if ported @liukun4515 ? |
What‘s the upstream? arrow-rs?
I also think the semantics of adding plain integers to dates is not suitable for adding in the arrow-rs. The pg https://www.postgresql.org/docs/current/functions-datetime.html support the operation
We can use the rewrite to support them. Thanks @tustvold |
Yes, i have a plan to implement this function from below discussion #3148 (comment) and create issue to track this #6951 |
Is your feature request related to a problem or challenge?
we have requirements related to the date operation, such as
date_add
,date_sub
.In the spark and mysql, the
date_add(start_date, value_expr)
function has been supported.But in the datafusion, we only use the
expr + interval 'value' day
to support them.In the mysql or the spark, the second args can be the expr, but the datafusion has no method to get the same target.
Describe the solution you'd like
In the PG document, PG support
date +/plus integer
.We can try to support this feature in the datafusion or in the kernel of arrow-rs.
Describe alternatives you've considered
No response
Additional context
cc @waitingkuo @alamb
The text was updated successfully, but these errors were encountered: