Skip to content

Conversation

@andygrove
Copy link
Member

@andygrove andygrove commented Mar 23, 2019

This PR re-implements get_supertype to be easier to read and maintain. It still only supports numeric types and string. After this PR is merged I will create new PRs to add rules for boolean and date/time.

@andygrove
Copy link
Member Author

@kszucs Please take a look when you can

@andygrove
Copy link
Member Author

@paddyhoran @sunchao Some code cleanup that would be good to get into 0.13

Copy link

@uagashe-rms uagashe-rms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove . Sorry for the late review.

))),
},
use arrow::datatypes::DataType::*;
let d = if l == r {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old implementation the super type of UInt16 and Int8 is None but now it is Int16. Why is that? Also do you know how C++ handles this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not statically compatible in C++ (safely). https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L156-L208

It can be safe to cast, but it needs a runtime check.

));
}
}
assert_eq!(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid comparing with string? whenever there's an error it is very hard to find out since you are comparing two huge strings.

))),
},
use arrow::datatypes::DataType::*;
let d = if l == r {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not statically compatible in C++ (safely). https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/cast.cc#L156-L208

It can be safe to cast, but it needs a runtime check.

Some(l.clone())
} else if l == &Utf8 || r == &Utf8 {
Some(Utf8)
} else if is_signed_int(l) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block is hard to follow, I'd rewrite this with small functions.

@wesm
Copy link
Member

wesm commented May 23, 2019

Can this PR be merged?

@sunchao
Copy link
Member

sunchao commented May 24, 2019

I think there are a few pending comments to be resolved. @andygrove can you take a look?

@andygrove
Copy link
Member Author

Sorry, I haven't had any spare time for a while due to work commitments. I am closing this and will try again another time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants