Skip to content

Commit

Permalink
Merge remote-tracking branch 'apache/main' into alamb/deprecate_collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Jan 10, 2025
2 parents ee1c16f + 295ffb4 commit cf323b3
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 123 deletions.
3 changes: 3 additions & 0 deletions datafusion/common/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ mod tests {
fn test_py_scalar() {
init_python();

// TODO: remove this attribute when bumping pyo3 to v0.23.0
// See: <https://github.com/PyO3/pyo3/blob/v0.23.0/guide/src/migration.md#gil-refs-feature-removed>
#[allow(unexpected_cfgs)]
Python::with_gil(|py| {
let scalar_float = ScalarValue::Float64(Some(12.34));
let py_float = scalar_float.into_py(py).call_method0(py, "as_py").unwrap();
Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,8 @@ impl ListingTable {
/// This method first checks if the statistics for the given file are already cached.
/// If they are, it returns the cached statistics.
/// If they are not, it infers the statistics from the file and stores them in the cache.
async fn do_collect_statistics<'a>(
&'a self,
async fn do_collect_statistics(
&self,
ctx: &SessionState,
store: &Arc<dyn ObjectStore>,
part_file: &PartitionedFile,
Expand Down
9 changes: 3 additions & 6 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ impl SessionContext {
Ok(table)
}

async fn find_and_deregister<'a>(
async fn find_and_deregister(
&self,
table_ref: impl Into<TableReference>,
table_type: TableType,
Expand Down Expand Up @@ -1481,10 +1481,7 @@ impl SessionContext {
/// provided reference.
///
/// [`register_table`]: SessionContext::register_table
pub async fn table<'a>(
&self,
table_ref: impl Into<TableReference>,
) -> Result<DataFrame> {
pub async fn table(&self, table_ref: impl Into<TableReference>) -> Result<DataFrame> {
let table_ref: TableReference = table_ref.into();
let provider = self.table_provider(table_ref.clone()).await?;
let plan = LogicalPlanBuilder::scan(
Expand All @@ -1511,7 +1508,7 @@ impl SessionContext {
}

/// Return a [`TableProvider`] for the specified table.
pub async fn table_provider<'a>(
pub async fn table_provider(
&self,
table_ref: impl Into<TableReference>,
) -> Result<Arc<dyn TableProvider>> {
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion datafusion/expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ pub use datafusion_expr_common::columnar_value::ColumnarValue;
pub use datafusion_expr_common::groups_accumulator::{EmitTo, GroupsAccumulator};
pub use datafusion_expr_common::operator::Operator;
pub use datafusion_expr_common::signature::{
ArrayFunctionSignature, Signature, TypeSignature, Volatility, TIMEZONE_WILDCARD,
ArrayFunctionSignature, Signature, TypeSignature, TypeSignatureClass, Volatility,
TIMEZONE_WILDCARD,
};
pub use datafusion_expr_common::type_coercion::binary;
pub use expr::{
Expand Down
33 changes: 25 additions & 8 deletions datafusion/expr/src/type_coercion/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,11 @@ fn get_valid_types(
}

fn function_length_check(length: usize, expected_length: usize) -> Result<()> {
if length < 1 {
return plan_err!(
"The signature expected at least one argument but received {expected_length}"
);
}

if length != expected_length {
return plan_err!(
"The signature expected {length} arguments but received {expected_length}"
"The signature expected {expected_length} arguments but received {length}"
);
}

Ok(())
}

Expand Down Expand Up @@ -939,6 +932,7 @@ mod tests {

use super::*;
use arrow::datatypes::Field;
use datafusion_common::assert_contains;

#[test]
fn test_string_conversion() {
Expand Down Expand Up @@ -1027,6 +1021,29 @@ mod tests {
Ok(())
}

#[test]
fn test_get_valid_types_length_check() -> Result<()> {
let signature = TypeSignature::Numeric(1);

let err = get_valid_types(&signature, &[]).unwrap_err();
assert_contains!(
err.to_string(),
"The signature expected 1 arguments but received 0"
);

let err = get_valid_types(
&signature,
&[DataType::Int32, DataType::Int32, DataType::Int32],
)
.unwrap_err();
assert_contains!(
err.to_string(),
"The signature expected 1 arguments but received 3"
);

Ok(())
}

#[test]
fn test_fixed_list_wildcard_coerce() -> Result<()> {
let inner = Arc::new(Field::new_list_field(DataType::Int32, false));
Expand Down
4 changes: 1 addition & 3 deletions datafusion/physical-expr-common/src/physical_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ pub trait DynEq {

impl<T: Eq + Any> DynEq for T {
fn dyn_eq(&self, other: &dyn Any) -> bool {
other
.downcast_ref::<Self>()
.map_or(false, |other| other == self)
other.downcast_ref::<Self>() == Some(self)
}
}

Expand Down
6 changes: 3 additions & 3 deletions datafusion/physical-expr-common/src/sort_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ impl PhysicalSortRequirement {
/// Returns whether this requirement is equal or more specific than `other`.
pub fn compatible(&self, other: &PhysicalSortRequirement) -> bool {
self.expr.eq(&other.expr)
&& other.options.map_or(true, |other_opts| {
self.options.map_or(false, |opts| opts == other_opts)
})
&& other
.options
.map_or(true, |other_opts| self.options == Some(other_opts))
}

#[deprecated(since = "43.0.0", note = "use LexRequirement::from_lex_ordering")]
Expand Down

0 comments on commit cf323b3

Please sign in to comment.