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

Minor: Add ScalarValue::data_type() for consistency with other APIs #7492

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Sep 7, 2023

Which issue does this PR close?

N/A

Rationale for this change

The fact that most of the DataFusion codebase uses fn data_type() to retrieve the datatype but ScalarValue uses get_datatype is frustrating to me. It is a very small rough edge, but one that is easy to fix

Here is the example showing exsiting APIs that use data_type(): https://github.com/search?q=repo%3Aapache%2Farrow-datafusion%20data_type&type=code

What changes are included in this PR?

  1. Add ScalarValue::data_type()
  2. Add docs to ScalarValue::get_datatype

Note I did not actually #deprecate get_datatype as I thought that would be too large a change. I can do so if people would like however.

Are these changes tested?

I changed a few locations to call ScalarValue::data_type

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions physical-expr Physical Expressions optimizer Optimizer rules labels Sep 7, 2023
@alamb alamb changed the title Minor: Add ScalarValue::data_type() for consistency Minor: Add ScalarValue::data_type() for consistency with other APIs Sep 7, 2023
Comment on lines +1152 to +1157
/// Getter for the `DataType` of the value.
///
/// Suggest using [`Self::data_type`] as a more standard API
pub fn get_datatype(&self) -> DataType {
self.data_type()
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to deprecate this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could/should -- I was basically being lazy.

I'll try and find time to bash out a follow on PR to deprecate it and update the uses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed #7506 to track

@Dandandan Dandandan merged commit 93c209f into apache:main Sep 8, 2023
@alamb alamb deleted the alamb/scalar_value_datatype branch September 8, 2023 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Physical Expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants