Skip to content

Commit 76b9e12

Browse files
authored
Limit visibility of internal impl functions in function crates (#18877)
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> N/A ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> Whilst reviewing some recent PRs (#18839 & #18768) I noticed we have quite a few inner implementation functions that are public for some reason, which give the false impression these are meant to be public APIs (and thus any changes to their signature needs to be restricted). Went through and limited the functions to private where possible to try reduce our public API footprint. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Change inner functions in functions & nested-functions crates to be private, away from public. - There are still some that are left public such as some regex ones, because they are used directly in benches ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Compiler itself. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> Yes, quite a few functions are now private, but I don't think they were meant to be public in the first place. <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent c2ba087 commit 76b9e12

38 files changed

+101
-158
lines changed

datafusion/functions-nested/src/cardinality.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ impl ScalarUDFImpl for Cardinality {
117117
}
118118
}
119119

120-
/// Cardinality SQL function
121-
pub fn cardinality_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
120+
fn cardinality_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
122121
let [array] = take_function_args("cardinality", args)?;
123122
match array.data_type() {
124123
Null => Ok(Arc::new(UInt64Array::from_value(0, array.len()))),

datafusion/functions-nested/src/concat.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ impl ScalarUDFImpl for ArrayConcat {
352352
}
353353
}
354354

355-
/// Array_concat/Array_cat SQL function
356-
pub(crate) fn array_concat_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
355+
fn array_concat_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
357356
if args.is_empty() {
358357
return exec_err!("array_concat expects at least one argument");
359358
}
@@ -453,8 +452,7 @@ fn concat_internal<O: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
453452

454453
// Kernel functions
455454

456-
/// Array_append SQL function
457-
pub(crate) fn array_append_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
455+
fn array_append_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
458456
let [array, values] = take_function_args("array_append", args)?;
459457
match array.data_type() {
460458
DataType::Null => make_array_inner(&[Arc::clone(values)]),
@@ -464,8 +462,7 @@ pub(crate) fn array_append_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
464462
}
465463
}
466464

467-
/// Array_prepend SQL function
468-
pub(crate) fn array_prepend_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
465+
fn array_prepend_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
469466
let [values, array] = take_function_args("array_prepend", args)?;
470467
match array.data_type() {
471468
DataType::Null => make_array_inner(&[Arc::clone(values)]),

datafusion/functions-nested/src/dimension.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ impl ScalarUDFImpl for ArrayNdims {
189189
}
190190
}
191191

192-
/// Array_dims SQL function
193-
pub fn array_dims_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
192+
fn array_dims_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
194193
let [array] = take_function_args("array_dims", args)?;
195194
let data: Vec<_> = match array.data_type() {
196195
List(_) => as_list_array(&array)?
@@ -214,8 +213,7 @@ pub fn array_dims_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
214213
Ok(Arc::new(result))
215214
}
216215

217-
/// Array_ndims SQL function
218-
pub fn array_ndims_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
216+
fn array_ndims_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
219217
let [array] = take_function_args("array_ndims", args)?;
220218

221219
fn general_list_ndims(array: &ArrayRef) -> Result<ArrayRef> {

datafusion/functions-nested/src/distance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl ScalarUDFImpl for ArrayDistance {
141141
}
142142
}
143143

144-
pub fn array_distance_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
144+
fn array_distance_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
145145
let [array1, array2] = take_function_args("array_distance", args)?;
146146
match (array1.data_type(), array2.data_type()) {
147147
(List(_), List(_)) => general_array_distance::<i32>(args),

datafusion/functions-nested/src/empty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ impl ScalarUDFImpl for ArrayEmpty {
110110
}
111111
}
112112

113-
/// Array_empty SQL function
114-
pub fn array_empty_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
113+
fn array_empty_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
115114
let [array] = take_function_args("array_empty", args)?;
116115
match array.data_type() {
117116
List(_) => general_array_empty::<i32>(array),

datafusion/functions-nested/src/except.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ impl ScalarUDFImpl for ArrayExcept {
126126
}
127127
}
128128

129-
/// Array_except SQL function
130-
pub fn array_except_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
129+
fn array_except_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
131130
let [array1, array2] = take_function_args("array_except", args)?;
132131

133132
match (array1.data_type(), array2.data_type()) {

datafusion/functions-nested/src/flatten.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ impl ScalarUDFImpl for Flatten {
130130
}
131131
}
132132

133-
/// Flatten SQL function
134-
pub fn flatten_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
133+
fn flatten_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
135134
let [array] = take_function_args("flatten", args)?;
136135

137136
match array.data_type() {

datafusion/functions-nested/src/length.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ macro_rules! array_length_impl {
150150
}};
151151
}
152152

153-
/// Array_length SQL function
154-
pub fn array_length_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
153+
fn array_length_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
155154
if args.len() != 1 && args.len() != 2 {
156155
return exec_err!("array_length expects one or two arguments");
157156
}

datafusion/functions-nested/src/min_max.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ impl ScalarUDFImpl for ArrayMax {
113113
}
114114
}
115115

116-
/// array_max SQL function
117-
///
118-
/// There is one argument for array_max as the array.
119-
/// `array_max(array)`
120-
///
121-
/// For example:
122-
/// > array_max(\[1, 3, 2]) -> 3
123-
pub fn array_max_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
116+
fn array_max_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
124117
let [array] = take_function_args("array_max", args)?;
125118
match array.data_type() {
126119
List(_) => array_min_max_helper(as_list_array(array)?, max_batch),
@@ -202,7 +195,7 @@ impl ScalarUDFImpl for ArrayMin {
202195
}
203196
}
204197

205-
pub fn array_min_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
198+
fn array_min_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
206199
let [array] = take_function_args("array_min", args)?;
207200
match array.data_type() {
208201
List(_) => array_min_max_helper(as_list_array(array)?, min_batch),

datafusion/functions-nested/src/position.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ impl ScalarUDFImpl for ArrayPosition {
141141
}
142142
}
143143

144-
/// Array_position SQL function
145-
pub fn array_position_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
144+
fn array_position_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
146145
if args.len() < 2 || args.len() > 3 {
147146
return exec_err!("array_position expects two or three arguments");
148147
}
@@ -152,6 +151,7 @@ pub fn array_position_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
152151
array_type => exec_err!("array_position does not support type '{array_type}'."),
153152
}
154153
}
154+
155155
fn general_position_dispatch<O: OffsetSizeTrait>(args: &[ArrayRef]) -> Result<ArrayRef> {
156156
let list_array = as_generic_list_array::<O>(&args[0])?;
157157
let element_array = &args[1];
@@ -292,8 +292,7 @@ impl ScalarUDFImpl for ArrayPositions {
292292
}
293293
}
294294

295-
/// Array_positions SQL function
296-
pub fn array_positions_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
295+
fn array_positions_inner(args: &[ArrayRef]) -> Result<ArrayRef> {
297296
let [array, element] = take_function_args("array_positions", args)?;
298297

299298
match &array.data_type() {

0 commit comments

Comments
 (0)