Closed killme2008 closed 2 weeks ago
Hi Dennis @killme2008 Do I get it right that the exception comes from the DataFusion?
If that's the case is there any established way of "intercepting" the AST before sending it to plan? Thank you!
Hi Dennis @killme2008 Do I get it right that the exception comes from the DataFusion?
If that's the case is there any established way of "intercepting" the AST before sending it to plan? Thank you!
I think we can transform the Expr
just like type alias:
https://github.com/GreptimeTeam/greptimedb/blob/main/src/sql/src/statements/transform/type_alias.rs
Adds a new transform rule and add it to
@etolbakov Looks like compound signed number case not processed properly:
mysql> SELECT INTERVAL '-1h5m';
+----------------------------------------------+
| IntervalMonthDayNano("18446740773709551616") |
+----------------------------------------------+
| P0Y0M0DT0H-55M0S |
+----------------------------------------------+
mysql> SELECT INTERVAL '-1h-5m';
ERROR 1815 (HY000): Failed to plan SQL: Parser error: Invalid input syntax for type interval: "-1 h- 5 minutes"
Would you like to fix it?
ohhh....my bad, yeah, let me give it a go
I have crafted a document detailing the interval
type. Would you kindly provide feedback upon review?
@etolbakov I have an idea. Maybe we can apply this transform rule to the cast(string as interval)
expression too? Then it can be applied to the interval in the form of '3y2mon'::interval
. What do you think about it?
https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.Expr.html#variant.Cast
https://docs.rs/datafusion/latest/datafusion/logical_expr/struct.TryCast.html
It's a great idea! Let me make an assessment (and reopen the ticket 😁)
What type of enhancement is this?
API improvement, User experience
What does the enhancement do?
GreptimeDB supports sql-compatible intervals like:
That is great. But in many time-series query scenarios, the
1 hour
is shortened to1h
. It is great to support it too:Other units such as:
y
for yearsm
for minutess
for secondsw
for weeksd
for daysetc.
Implementation challenges
No response