-
Notifications
You must be signed in to change notification settings - Fork 598
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
feat: binding struct values when they are parsed as row #2371
Changes from all commits
6da4c48
c4dda45
61e90ab
faf442a
b6d7b5d
c4c53c5
a9f717d
00d6aef
b789f74
1d2c3f4
7a4d983
6493e69
7dec8ee
030670e
e2435b7
45f6f19
17ce870
c2318ed
d71f203
98c751b
f351919
9497e37
3595deb
ee031dc
db2be86
6b2dacd
b8c3383
b253d60
fca4aa1
d4c3153
ee6c873
fd23fc5
e2e8bc5
78c589c
9e34ea6
c9f76b3
cfa1b74
fce1836
4c827a8
d222f47
7445b84
a29d816
924431d
40791ca
413b973
c82805a
b1b4902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,6 +300,40 @@ impl ScalarImpl { | |
} | ||
for_all_scalar_variants! { impl_all_get_ident, self } | ||
} | ||
|
||
pub(crate) fn data_type(&self) -> Result<DataType> { | ||
let data_type = match self { | ||
ScalarImpl::Int16(_) => DataType::Int16, | ||
ScalarImpl::Int32(_) => DataType::Int32, | ||
ScalarImpl::Int64(_) => DataType::Int64, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for mention, I will try to fix in follow pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just bringing it up. So that we are aware of this tricky issue in type system and can see which design is better. I do need see an immediate way to "fix" - in the current design, mapping from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me see, I found that acutally I don't need this function, I refactor this part #2508. |
||
ScalarImpl::Float32(_) => DataType::Float32, | ||
ScalarImpl::Float64(_) => DataType::Float64, | ||
ScalarImpl::Utf8(_) => DataType::Varchar, | ||
ScalarImpl::Bool(_) => DataType::Boolean, | ||
ScalarImpl::Decimal(_) => DataType::Decimal, | ||
ScalarImpl::Interval(_) => DataType::Interval, | ||
ScalarImpl::NaiveDate(_) => DataType::Date, | ||
ScalarImpl::NaiveDateTime(_) => DataType::Timestamp, | ||
ScalarImpl::NaiveTime(_) => DataType::Time, | ||
ScalarImpl::Struct(data) => { | ||
let types = data | ||
.fields() | ||
.iter() | ||
.map(get_data_type_from_datum) | ||
.collect::<Result<Vec<_>>>()?; | ||
DataType::Struct { | ||
fields: types.into(), | ||
} | ||
} | ||
ScalarImpl::List(data) => { | ||
let data = data.values().get(0).ok_or_else(|| { | ||
internal_error("cannot get data type from empty list".to_string()) | ||
})?; | ||
get_data_type_from_datum(data)? | ||
} | ||
}; | ||
Ok(data_type) | ||
} | ||
} | ||
|
||
impl<'scalar> ScalarRefImpl<'scalar> { | ||
|
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.
I think the data type of a literal should be unknown until it's inferred by some means, think of such case:
How can we determine the type of
(1, null)
until it's inferred from v1? (given the rule that v1 and(1, null)
must be the same type, so the null's type must beint
).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.
I see.., will fix in follow-up issue.