Skip to content

feat: Upgrade to the official DataFusion 49.0.0 release #1997

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
532 changes: 379 additions & 153 deletions native/Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ arrow = { version = "55.1.0", features = ["prettyprint", "ffi", "chrono-tz"] }
async-trait = { version = "0.1" }
bytes = { version = "1.10.0" }
parquet = { version = "55.1.0", default-features = false, features = ["experimental"] }
datafusion = { version = "48.0.0", default-features = false, features = ["unicode_expressions", "crypto_expressions", "nested_expressions", "parquet"] }
datafusion-spark = { version = "48.0.0" }
datafusion = { git = "https://github.com/apache/datafusion", rev = "3291e4e", default-features = false, features = ["unicode_expressions", "crypto_expressions", "nested_expressions", "parquet"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

The title mentions Upgrade to the official Datafusion 49.0.0 release, however it looks like version 49.0.0 hasn't been officially released yet (apache/datafusion#16235)?

Will this change be on hold until the release is finalized? Or is the plan to update Comet to revision 3291e4e in this PR, and then follow up with a separate PR once 49.0.0 is released?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isnt the PR to update Comet to revision 3291e4e. This is a incremental PR to update DF verion to 49.0.0 PTAL #1993

datafusion-spark = { git = "https://github.com/apache/datafusion", rev = "3291e4e" }
datafusion-comet-spark-expr = { path = "spark-expr" }
datafusion-comet-proto = { path = "proto" }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
Expand Down
2 changes: 1 addition & 1 deletion native/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ futures = { workspace = true }
mimalloc = { version = "*", default-features = false, optional = true }
tikv-jemallocator = { version = "0.6.0", optional = true, features = ["disable_initial_exec_tls"] }
tikv-jemalloc-ctl = { version = "0.6.0", optional = true, features = ["disable_initial_exec_tls", "stats"] }
tokio = { version = "1", features = ["rt-multi-thread"] }
tokio = { version = "1.46.1", features = ["rt-multi-thread"] }
async-trait = { workspace = true }
log = "0.4"
log4rs = "1.2.0"
Expand Down
3 changes: 2 additions & 1 deletion native/core/benches/shuffle_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ fn criterion_benchmark(c: &mut Criterion) {
CometPartitioning::RangePartitioning(
LexOrdering::new(vec![PhysicalSortExpr::new_default(
col("c0", batch.schema().as_ref()).unwrap(),
)]),
)])
.unwrap(),
16,
100,
),
Expand Down
35 changes: 14 additions & 21 deletions native/core/src/execution/operators/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,22 +211,16 @@ impl FilterExec {
if let Some(binary) = conjunction.as_any().downcast_ref::<BinaryExpr>() {
if binary.op() == &Operator::Eq {
// Filter evaluates to single value for all partitions
if input_eqs.is_expr_constant(binary.left()) {
let (expr, across_parts) = (
binary.right(),
input_eqs.get_expr_constant_value(binary.right()),
);
res_constants.push(
ConstExpr::new(Arc::clone(expr)).with_across_partitions(across_parts),
);
} else if input_eqs.is_expr_constant(binary.right()) {
let (expr, across_parts) = (
binary.left(),
input_eqs.get_expr_constant_value(binary.left()),
);
res_constants.push(
ConstExpr::new(Arc::clone(expr)).with_across_partitions(across_parts),
);
if input_eqs.is_expr_constant(binary.left()).is_some() {
let across = input_eqs
.is_expr_constant(binary.right())
.unwrap_or_default();
res_constants.push(ConstExpr::new(Arc::clone(binary.right()), across));
} else if input_eqs.is_expr_constant(binary.right()).is_some() {
let across = input_eqs
.is_expr_constant(binary.left())
.unwrap_or_default();
res_constants.push(ConstExpr::new(Arc::clone(binary.left()), across));
}
}
}
Expand All @@ -246,7 +240,7 @@ impl FilterExec {
let mut eq_properties = input.equivalence_properties().clone();
let (equal_pairs, _) = collect_columns_from_predicate(predicate);
for (lhs, rhs) in equal_pairs {
eq_properties.add_equal_conditions(lhs, rhs)?
eq_properties.add_equal_conditions(Arc::clone(lhs), Arc::clone(rhs))?;
}
// Add the columns that have only one viable value (singleton) after
// filtering to constants.
Expand All @@ -258,14 +252,13 @@ impl FilterExec {
.min_value
.get_value();
let expr = Arc::new(column) as _;
ConstExpr::new(expr)
.with_across_partitions(AcrossPartitions::Uniform(value.cloned()))
ConstExpr::new(expr, AcrossPartitions::Uniform(value.cloned()))
});
// This is for statistics
eq_properties = eq_properties.with_constants(constants);
eq_properties.add_constants(constants)?;
// This is for logical constant (for example: a = '1', then a could be marked as a constant)
// to do: how to deal with multiple situation to represent = (for example c1 between 0 and 0)
eq_properties = eq_properties.with_constants(Self::extend_constants(input, predicate));
eq_properties.add_constants(Self::extend_constants(input, predicate))?;

let mut output_partitioning = input.output_partitioning().clone();
// If contains projection, update the PlanProperties.
Expand Down
17 changes: 8 additions & 9 deletions native/core/src/execution/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use crate::parquet::parquet_support::prepare_object_store_with_configs;
use datafusion::common::scalar::ScalarStructBuilder;
use datafusion::common::{
tree_node::{Transformed, TransformedResult, TreeNode, TreeNodeRecursion, TreeNodeRewriter},
JoinType as DFJoinType, ScalarValue,
JoinType as DFJoinType, NullEquality, ScalarValue,
};
use datafusion::datasource::listing::PartitionedFile;
use datafusion::logical_expr::type_coercion::other::get_coerce_type_for_case_expression;
Expand Down Expand Up @@ -1115,7 +1115,7 @@ impl PhysicalPlanner {
let child_copied = Self::wrap_in_copy_exec(Arc::clone(&child.native_plan));

let sort = Arc::new(
SortExec::new(LexOrdering::new(exprs?), Arc::clone(&child_copied))
SortExec::new(LexOrdering::new(exprs?).unwrap(), Arc::clone(&child_copied))
.with_fetch(fetch),
);

Expand Down Expand Up @@ -1391,7 +1391,7 @@ impl PhysicalPlanner {
sort_options,
// null doesn't equal to null in Spark join key. If the join key is
// `EqualNullSafe`, Spark will rewrite it during planning.
false,
NullEquality::NullEqualsNothing,
)?);

if join.filter.is_some() {
Expand Down Expand Up @@ -1459,7 +1459,7 @@ impl PhysicalPlanner {
PartitionMode::Partitioned,
// null doesn't equal to null in Spark join key. If the join key is
// `EqualNullSafe`, Spark will rewrite it during planning.
false,
NullEquality::NullEqualsNothing,
)?);

// If the hash join is build right, we need to swap the left and right
Expand Down Expand Up @@ -2163,7 +2163,7 @@ impl PhysicalPlanner {
window_func_name,
&window_args,
partition_by,
&LexOrdering::new(sort_exprs.to_vec()),
&LexOrdering::new(sort_exprs.to_vec()).unwrap(),
window_frame.into(),
input_schema.as_ref(),
false, // TODO: Ignore nulls
Expand Down Expand Up @@ -2244,7 +2244,7 @@ impl PhysicalPlanner {
.iter()
.map(|expr| self.create_sort_expr(expr, Arc::clone(&input_schema)))
.collect();
let lex_ordering = LexOrdering::from(exprs?);
let lex_ordering = LexOrdering::new(exprs?).unwrap();
Ok(CometPartitioning::RangePartitioning(
lex_ordering,
range_partition.num_partitions as usize,
Expand Down Expand Up @@ -2611,6 +2611,7 @@ mod tests {
FileGroup, FileScanConfigBuilder, FileSource, ParquetSource,
};
use datafusion::error::DataFusionError;
use datafusion::functions_nested::make_array::MakeArray;
use datafusion::logical_expr::ScalarUDF;
use datafusion::physical_plan::ExecutionPlan;
use datafusion::{assert_batches_eq, physical_plan::common::collect, prelude::SessionContext};
Expand Down Expand Up @@ -2940,9 +2941,7 @@ mod tests {
#[test]
fn test_create_array() {
let session_ctx = SessionContext::new();
session_ctx.register_udf(ScalarUDF::from(
datafusion_functions_nested::make_array::MakeArray::new(),
));
session_ctx.register_udf(ScalarUDF::from(MakeArray::new()));
let task_ctx = session_ctx.task_ctx();
let planner = PhysicalPlanner::new(Arc::from(session_ctx), 0);

Expand Down
3 changes: 2 additions & 1 deletion native/core/src/execution/shuffle/range_partitioner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ mod test {

let lex_ordering = LexOrdering::new(vec![PhysicalSortExpr::new_default(
col("a", input_batch.schema().as_ref()).unwrap(),
)]);
)])
.unwrap();

let (rows, row_converter) = RangePartitioner::generate_bounds(
input_batch.columns().to_vec().as_ref(),
Expand Down
7 changes: 4 additions & 3 deletions native/core/src/execution/shuffle/shuffle_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ impl SinglePartitionShufflePartitioner {
Ok(Some(concatenated))
}
Err(e) => Err(DataFusionError::ArrowError(
e,
Box::new(e),
Some(DataFusionError::get_back_trace()),
)),
}
Expand Down Expand Up @@ -1122,7 +1122,7 @@ impl Iterator for PartitionedBatchIterator<'_> {
Some(Ok(batch))
}
Err(e) => Some(Err(DataFusionError::ArrowError(
e,
Box::new(e),
Some(DataFusionError::get_back_trace()),
))),
}
Expand Down Expand Up @@ -1409,7 +1409,8 @@ mod test {
CometPartitioning::RangePartitioning(
LexOrdering::new(vec![PhysicalSortExpr::new_default(
col("a", batch.schema().as_ref()).unwrap(),
)]),
)])
.unwrap(),
num_partitions,
100,
),
Expand Down
Loading