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

Encapsulates logic from TypeSignatureClass, rename methods #4

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

alamb
Copy link

@alamb alamb commented Feb 13, 2025

Proposed PR to apache#14440 from @jayzhan211

Will comment inline

@@ -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();
Copy link
Author

Choose a reason for hiding this comment

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

renamed and deprecated get_possible_types to reflect what the function actually does

///
/// This is used for `information_schema` and can be used to generate
/// documentation or error messages.
fn get_example_types(&self) -> Vec<DataType> {
Copy link
Author

Choose a reason for hiding this comment

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

Moved logic that was related to TypeSignatureClass into methods

@@ -429,32 +516,6 @@ impl TypeSignature {
}
}

fn get_possible_types_from_signature_classes(
Copy link
Author

Choose a reason for hiding this comment

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

moved/renamed

@@ -599,76 +596,19 @@ fn get_valid_types(

let mut new_types = Vec::with_capacity(current_types.len());
for (current_type, param) in current_types.iter().zip(param_types.iter()) {
let current_logical_type: NativeType = current_type.into();
Copy link
Author

Choose a reason for hiding this comment

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

moved these into actual methods

///
/// This is used for `information_schema` and can be used to generate
/// documentation or error messages.
pub fn get_example_types(&self) -> Vec<Vec<DataType>> {
Copy link
Owner

@jayzhan211 jayzhan211 Feb 14, 2025

Choose a reason for hiding this comment

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

Can we make this private, it is not useful to make this public. I'm also thinking about other types than DataType

}

/// Does the specified `NativeType` match this type signature class?
pub fn matches_native_type(
Copy link
Owner

Choose a reason for hiding this comment

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

It would be nice to make this private

Copy link
Owner

Choose a reason for hiding this comment

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

Actually we can't make this private, that is why I didn't move it as a method, to keep us easy to change the logic

Copy link
Author

Choose a reason for hiding this comment

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

It seems to me like the exact details of what types are coerced to what other types is actually part of the DataFusion public API because those rules effect what queries will run

Whenever we make changes to the coercsion rules, it seems to result in a bunch of issues reported by users (because some queries that used to work no longer do).

Thus I propose we move towards a design that is both more explicit (and extensible)

I realize we could probably achieve this goal without making more pub methods 🤔

Copy link
Owner

Choose a reason for hiding this comment

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

let's try it

}

/// What type would `origin_type` be casted to when casting to the specified native type?
pub fn default_casted_type(
Copy link
Owner

Choose a reason for hiding this comment

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

It would be nice to make this private

Copy link
Author

Choose a reason for hiding this comment

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

As above, I don't fully understand the desire to keep it non pub

@jayzhan211 jayzhan211 merged commit 59d06d8 into jayzhan211:signature-v2 Feb 14, 2025
24 of 25 checks passed
@alamb alamb deleted the alamb/signature_suggestions branch February 14, 2025 15:16
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.

2 participants