Github user adrian-wang commented on the pull request:
https://github.com/apache/spark/pull/7589#issuecomment-123745566
@rxin On my second thought, I think we should keep date_add and date_sub as
simple as it should be. When it comes to Datetime IntervalType computation, we
need another node specially for this. Here are my considerations:
1. hive 1.2 supports interval type, but still keep date_add and date_sub
simple.
2, use another node can keep the registered function the same as most
database systems.
3. for strings, it is hard to decide whether it is a date or timestamp,
this would be troublesome. For most databases, we use `date '2015-01-01' +
interval XXXX` to do this calculation. so the sql engine could know how we
should take care of the string here.
And I have several other TODOS for the simple POC shown here, as follows:
1. we need to let us be aware of the precision of the interval type. For
the calculation here, we would return DateType if we are add a Date and an
Year-Month Interval, otherwise we should return TimestampType. For POC shown
here, I just use TimestampType as the general returning type. Maybe we need two
interval types here.
2. I need to get add support in parser. to translate the `shiptime +
interval XXXX` into corresponding logical node.
2-1. the left operand of `timestamp '2015-01-01 11:22:33' + interval XXXX`
should be translated into a Cast that cast string into corresponding type.
2-2. Then we translate the calculation to a TimeAdd or a TimeSub.
I think the whole stuff deserves another PR.
cc @chenghao-intel
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]