-
Notifications
You must be signed in to change notification settings - Fork 251
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 basic support for cast in expressions #957
Conversation
rust/src/io/exec/planner.rs
Outdated
Ok(ArrowDataType::Timestamp(time_unit, None)) | ||
} | ||
_ => Err(Error::IO { | ||
message: format!("Unsupported data type: {:?}. Supports: float, double, boolean, int, integer, date, datetime", data_type), |
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.
Also supports binary / string / booleans, right? I mean just in the error message.
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.
Updated
@@ -186,6 +250,13 @@ impl Planner { | |||
SQLExpr::BinaryOp { left, op, right } => self.binary_expr(left, op, right), | |||
SQLExpr::UnaryOp { op, expr } => self.unary_expr(op, expr), | |||
SQLExpr::Value(value) => self.value(value), | |||
// For example, DATE '2020-01-01' | |||
SQLExpr::TypedString { data_type, value } => { |
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.
Does it mean we can actually do INT '1231'
to cast an integer? Is there any restriction on the data_type supported?
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.
Could you add a few tests in rust?
Also , should we maintain a doc to describe what expression we support? Can be a follow up issue tho.
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.
Yeah other types work. I think the other one that is good to have is decimal.
I'll add some docs and tests in Rust.
- Time unit | ||
* - ``timestamp(0)`` | ||
- Seconds | ||
* - ``timestamp(3)`` |
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.
is the precision a limitation by the parser? Feel that timestamp(s)
, timestamp(ms)
are easier to use. Curious how much effort to make it happen?
https://arrow.apache.org/docs/python/generated/pyarrow.timestamp.html
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.
Yeah that's unfortunately something that's not built in; it only allows integers.
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.
Ok, if this cannot be done in a few hours, let's just 🚢 it for now.
The rest LGTM |
04852e2
to
a9b8ebf
Compare
Fixed #956. Allows casting, but also "typed literals" where you just put the type you want in front of the string.