Skip to content
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

Signature::Coercible with user defined implicit casting #14440

Merged
merged 36 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
386c7ed
coerciblev2
jayzhan211 Feb 6, 2025
579ffef
repeat
jayzhan211 Feb 6, 2025
104da43
fix possible types
jayzhan211 Feb 6, 2025
aae48ff
replace all coerciblev1
jayzhan211 Feb 6, 2025
f585136
cleanup
jayzhan211 Feb 7, 2025
bad7348
remove specialize logic
jayzhan211 Feb 7, 2025
c99e986
comment
jayzhan211 Feb 7, 2025
07f97d0
err msg
jayzhan211 Feb 7, 2025
da84394
ci escape
jayzhan211 Feb 7, 2025
e0a889e
rm coerciblev1
jayzhan211 Feb 7, 2025
7a78a6d
fmt
jayzhan211 Feb 7, 2025
2f8c2ad
rename
jayzhan211 Feb 7, 2025
f02bf6e
Merge branch 'main' of github.com:apache/datafusion into signature-v2
jayzhan211 Feb 9, 2025
8054915
rename
jayzhan211 Feb 9, 2025
62da381
refactor
jayzhan211 Feb 9, 2025
231d75b
make default_casted_type private
jayzhan211 Feb 9, 2025
44250fc
cleanup
jayzhan211 Feb 9, 2025
2f6b5d6
fmt
jayzhan211 Feb 9, 2025
5387e5e
integer
jayzhan211 Feb 9, 2025
181f2ab
rm binary for ascii
jayzhan211 Feb 11, 2025
d98e4b6
rm unused
jayzhan211 Feb 11, 2025
cb30d91
Merge branch 'main' of github.com:apache/datafusion into signature-v2
jayzhan211 Feb 12, 2025
2cd8f5f
conflit
jayzhan211 Feb 12, 2025
6ce159f
fmt
jayzhan211 Feb 12, 2025
a3120f7
Rename get_example_types, make method on TypeSignatureClass
alamb Feb 13, 2025
bde60f6
Move more logic into TypeSignatureClass
alamb Feb 13, 2025
5d47a62
fix docs
alamb Feb 13, 2025
59d06d8
Merge pull request #4 from alamb/alamb/signature_suggestions
jayzhan211 Feb 14, 2025
ff5d063
46
jayzhan211 Feb 14, 2025
77fe4b8
enum
jayzhan211 Feb 14, 2025
7dc7365
fmt
jayzhan211 Feb 14, 2025
6ce2c8c
Merge branch 'main' of github.com:apache/datafusion into signature-v2
jayzhan211 Feb 14, 2025
56838b7
fmt
jayzhan211 Feb 14, 2025
6ceb9a2
Merge remote-tracking branch 'apache/main' into signature-v2
alamb Feb 14, 2025
055d8d0
doc
jayzhan211 Feb 16, 2025
be575e3
upd doc
jayzhan211 Feb 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions datafusion/catalog/src/information_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ fn get_udf_args_and_return_types(
udf: &Arc<ScalarUDF>,
) -> Result<Vec<(Vec<String>, Option<String>)>> {
let signature = udf.signature();
let arg_types = signature.type_signature.get_possible_types();
let arg_types = signature.type_signature.get_example_types();
if arg_types.is_empty() {
Ok(vec![(vec![], None)])
} else {
Expand All @@ -428,7 +428,7 @@ fn get_udaf_args_and_return_types(
udaf: &Arc<AggregateUDF>,
) -> Result<Vec<(Vec<String>, Option<String>)>> {
let signature = udaf.signature();
let arg_types = signature.type_signature.get_possible_types();
let arg_types = signature.type_signature.get_example_types();
if arg_types.is_empty() {
Ok(vec![(vec![], None)])
} else {
Expand All @@ -452,7 +452,7 @@ fn get_udwf_args_and_return_types(
udwf: &Arc<WindowUDF>,
) -> Result<Vec<(Vec<String>, Option<String>)>> {
let signature = udwf.signature();
let arg_types = signature.type_signature.get_possible_types();
let arg_types = signature.type_signature.get_example_types();
if arg_types.is_empty() {
Ok(vec![(vec![], None)])
} else {
Expand Down
9 changes: 9 additions & 0 deletions datafusion/common/src/types/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ impl LogicalType for NativeType {
TypeSignature::Native(self)
}

/// Returns the default casted type for the given arrow type
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

///
/// For types like String or Date, multiple arrow types mapped to the same logical type
/// If the given arrow type is one of them, we return the same type
/// Otherwise, we define the default casted type for the given arrow type
fn default_cast_for(&self, origin: &DataType) -> Result<DataType> {
use DataType::*;

Expand Down Expand Up @@ -226,6 +231,10 @@ impl LogicalType for NativeType {
(Self::Decimal(p, s), _) if p <= &38 => Decimal128(*p, *s),
(Self::Decimal(p, s), _) => Decimal256(*p, *s),
(Self::Timestamp(tu, tz), _) => Timestamp(*tu, tz.clone()),
// If given type is Date, return the same type
(Self::Date, origin) if matches!(origin, Date32 | Date64) => {
origin.to_owned()
}
(Self::Date, _) => Date32,
(Self::Time(tu), _) => match tu {
TimeUnit::Second | TimeUnit::Millisecond => Time32(*tu),
Expand Down
1 change: 1 addition & 0 deletions datafusion/expr-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ path = "src/lib.rs"
[dependencies]
arrow = { workspace = true }
datafusion-common = { workspace = true }
indexmap = { workspace = true }
itertools = { workspace = true }
paste = "^1.0"
Loading
Loading