You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/19 20:18:27 UTC
(datafusion) branch gh-readonly-queue/main/pr-26410-384d6464a31d5f9fc677c2031a43142711957775 created (now 3646132962)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-26410-384d6464a31d5f9fc677c2031a43142711957775
in repository https://gitbox.apache.org/repos/asf/datafusion.git
at 3646132962 Revert #25363 due to overlapping optimizations (#26410)
This branch includes the following new commits:
new 3646132962 Revert #25363 due to overlapping optimizations (#26410)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion) 01/01: Revert #25363 due to overlapping optimizations (#26410)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-26410-384d6464a31d5f9fc677c2031a43142711957775
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 364613296206dcffa62634b855dbbc4fd0f77b50
Author: Yongting You <20...@gmail.com>
AuthorDate: Mon Oct 19 20:14:40 2026 +0000
Revert #25363 due to overlapping optimizations (#26410)
## 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.
-->
- Closes #.
## 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.
Please explain the problem you are trying to solve in terms of the
user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of
the
implementation. "COUNT(DISTINCT) returns wrong results when the column
contains
nulls" is the user-visible problem.
-->
See discussion for details:
[https://github.com/apache/datafusion/pull/25363](https://github.com/apache/datafusion/pull/25363)
TLDR: The optimization itself is great, but might not be a good perf
v.s. complexity tradeoff, so I overall think it's better to revert.
This PR introduces an integer-key prefilter for Hash Join, which
overlaps with the existing `ArrayMap` optimization.
For example, consider a Hash Join on a `UInt64` key, where the
build-side key range is `[1, 100]`:
- **ArrayMap:** Replaces the hash table with a flat array for direct
lookup.
- **This PR:** Keeps the hash table but adds a bitmap prefilter to skip
unnecessary hash table lookups.
The tradeoff is:
- **ArrayMap:** Faster, but uses more memory.
- **Prefilter + HashMap:** Slower, but more memory-efficient,
particularly for sparse key ranges.
The concern is **whether the benefits justify the additional maintenance
overhead**:
1. It introduces 4 configuration options, while `ArrayMap` already has a
similar threshold configuration.
2. Having two closely related optimizations makes execution behavior
harder to predict and maintain.
This seem very hard to tune them right. I've considered simplifying the
thresholds or integrating the prefilter with existing mechanisms, but
neither seems straightforward.
In the [[original
discussion](https://github.com/apache/datafusion/pull/25363#issuecomment-6183169314)](https://github.com/apache/datafusion/pull/25363#issuecomment-6183169314),
@lyne7-sc provided benchmarks confirming the tradeoff, and also
expressed uncertainty about whether the extra maintenance is worthwhile.
**My overall recommendation is to revert this optimization for
simplification**, given our limited engineering capacity and current
maintenance burden. (I think the optimization is a good idea, we can
still think about introducing it in the future, but try to be more
general-purpose and easier to configure)
I'd love to hear others' thoughts.
## 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.
-->
commit 1 is pure change revert
commit 2 is some fixing due to main updates
## What is the testing strategy for this PR?
<!--
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
Briefly describe how this PR is tested, and point to the specific tests
you added. For example: 'This new feature is covered by the
`sqllogictest` cases added in `foo.slt`'.
If this PR does not add tests, explain why. For example, if the change
is already covered by existing tests, please mention it.
You should also check the `codecov` bot reply on this PR to confirm the
changed code is exercised.
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
datafusion/common/src/config.rs | 24 +-
datafusion/optimizer/src/push_down_filter.rs | 5 +
datafusion/physical-plan/Cargo.toml | 5 -
.../physical-plan/benches/hash_join_probe.rs | 282 -------------
.../physical-plan/src/joins/hash_join/exec.rs | 296 +------------
.../src/joins/hash_join/exec/prepared.rs | 1 -
.../src/joins/hash_join/exec/prepared/tests.rs | 76 ----
.../physical-plan/src/joins/hash_join/stream.rs | 59 +--
.../physical-plan/src/joins/integer_prefilter.rs | 459 ---------------------
datafusion/physical-plan/src/joins/mod.rs | 1 -
.../test_files/hash_join_integer_prefilter.slt | 242 -----------
.../sqllogictest/test_files/information_schema.slt | 8 -
docs/source/user-guide/configs.md | 4 -
13 files changed, 12 insertions(+), 1450 deletions(-)
diff --git a/datafusion/common/src/config.rs b/datafusion/common/src/config.rs
index 290baeb379..fc7202a6c5 100644
--- a/datafusion/common/src/config.rs
+++ b/datafusion/common/src/config.rs
@@ -925,29 +925,6 @@ config_namespace! {
/// Support for build_side.num_rows() >= u32::MAX will be added in the future.
pub perfect_hash_join_min_key_density: f64, default = 0.15
- /// Enable an exact integer membership prefilter for hash joins with a single
- /// integer key when the build side uses a hash table and the join is not
- /// null-aware. It skips lookups for absent keys while retaining NULLs and
- /// probe rows for the original join logic.
- pub enable_join_integer_prefilter: bool, default = false
-
- /// Maximum number of integer values covered by the join prefilter bitmap
- /// (`max_key - min_key + 1`). Zero disables bitmap construction.
- /// Larger ranges fall back to normal hash table lookups.
- pub join_integer_prefilter_max_key_range: u64, default = 262144
-
- /// The integer prefilter must prune more than this fraction of all sampled
- /// probe rows, including NULLs, to keep filtering. Must be finite and in
- /// [0, 1], validated when executing the join.
- pub join_integer_prefilter_min_pruning_ratio: f64, default = 0.5
-
- /// Minimum input probe rows in each integer prefilter sampling window,
- /// including NULLs. Must be greater than zero. Windows end at batch boundaries.
- /// Unprofitable samples initially pause for 10 times this many input rows;
- /// consecutive failures double the pause up to 128 times. A profitable
- /// sample resets the pause to 10 times this many rows.
- pub join_integer_prefilter_sample_rows: ConfigNonZeroUsize, default = non_zero_usize_default(12288)
-
/// When set to true, record batches will be examined between each operator and
/// small batches will be coalesced into larger batches. This is helpful when there
/// are highly selective filters or joins that could produce tiny output batches. The
@@ -4266,6 +4243,7 @@ impl Display for OutputFormat {
#[cfg(test)]
mod tests {
use crate::assert_contains;
+ #[cfg(feature = "parquet")]
use crate::config::TableParquetOptions;
use crate::config::{
ConfigEntry, ConfigExtension, ConfigField, ConfigFileType, ExtensionOptions,
diff --git a/datafusion/optimizer/src/push_down_filter.rs b/datafusion/optimizer/src/push_down_filter.rs
index becc789d81..54f220a1fe 100644
--- a/datafusion/optimizer/src/push_down_filter.rs
+++ b/datafusion/optimizer/src/push_down_filter.rs
@@ -1175,10 +1175,14 @@ impl OptimizerRule for PushDownFilter {
// multiple window functions, each with potentially different partition keys.
// Therefore, we need to ensure that any potential partition key returned is used in
// ALL window functions. Otherwise, filters cannot be pushed by through that column.
+ // Arrow buffer memory accounting does not affect expression hashing.
+ #[allow(clippy::allow_attributes, clippy::mutable_key_type)]
fn extract_partition_keys(func: &WindowFunction) -> HashSet<&Expr> {
func.params.partition_by.iter().collect()
}
+ // Arrow buffer memory accounting does not affect expression hashing.
+ #[allow(clippy::allow_attributes, clippy::mutable_key_type)]
let potential_partition_keys = window
.window_expr
.iter()
@@ -1678,6 +1682,7 @@ fn with_filters(predicates: Vec<Expr>, plan: LogicalPlan) -> LogicalPlan {
///
/// A predicate containing a subquery is never pushed: what the subquery reads is
/// not visible from the expression tree.
+#[allow(clippy::allow_attributes, clippy::mutable_key_type)] // Arrow buffer memory accounting does not affect expression hashing.
fn reads_only_partition_keys(
expr: &Expr,
partition_keys: &HashSet<&Expr>,
diff --git a/datafusion/physical-plan/Cargo.toml b/datafusion/physical-plan/Cargo.toml
index 73edbbdcdf..82a2215581 100644
--- a/datafusion/physical-plan/Cargo.toml
+++ b/datafusion/physical-plan/Cargo.toml
@@ -173,11 +173,6 @@ name = "compute_statistics"
harness = false
name = "dictionary_group_values"
-[[bench]]
-harness = false
-name = "hash_join_probe"
-required-features = ["test_utils"]
-
[[bench]]
harness = false
name = "hash_join_semi_anti"
diff --git a/datafusion/physical-plan/benches/hash_join_probe.rs b/datafusion/physical-plan/benches/hash_join_probe.rs
deleted file mode 100644
index ddd853c1df..0000000000
--- a/datafusion/physical-plan/benches/hash_join_probe.rs
+++ /dev/null
@@ -1,282 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-//! Full in-memory HashJoin execution, including build, with fixed Int32 workloads.
-//! All inputs carry an Int32 data column and a Utf8 payload column.
-//! Session settings use the standard DataFusion environment configuration.
-
-use std::hint::black_box;
-use std::sync::Arc;
-
-use arrow::array::{ArrayRef, Int32Array, StringArray};
-use arrow::datatypes::{DataType, Field, Schema, SchemaRef};
-use arrow::record_batch::RecordBatch;
-use criterion::{Criterion, criterion_group, criterion_main};
-use datafusion_common::{JoinType, NullEquality};
-use datafusion_execution::TaskContext;
-use datafusion_execution::config::SessionConfig;
-use datafusion_physical_expr::expressions::col;
-use datafusion_physical_plan::joins::{HashJoinExec, PartitionMode};
-use datafusion_physical_plan::test::TestMemoryExec;
-use datafusion_physical_plan::{ExecutionPlan, collect};
-use tokio::runtime::Runtime;
-
-const BATCH_SIZE: usize = 8_192;
-const BUILD_ROWS: usize = 20_000;
-const PROBE_ROWS: usize = 1_000_000;
-const LARGE_BUILD_ROWS: usize = 100_000;
-const SPARSE_KEY_STEP: i32 = 10;
-const DENSE_KEY_STEP: i32 = 1;
-const HIT_EVERY: usize = 10;
-
-#[derive(Clone, Copy)]
-enum Pattern {
- AllHit,
- InterleavedLowHit,
- ClusteredLowHit,
- HighToLow,
-}
-
-fn make_batches(
- rows: usize,
- build_rows: usize,
- key_step: i32,
- pattern: Pattern,
- schema: &SchemaRef,
-) -> Vec<RecordBatch> {
- let mut hits = 0;
- (0..rows)
- .step_by(BATCH_SIZE)
- .map(|start| {
- let end = (start + BATCH_SIZE).min(rows);
- let keys = Int32Array::from_iter_values((start..end).map(|row| {
- let hit = match pattern {
- Pattern::AllHit => true,
- Pattern::InterleavedLowHit => row % HIT_EVERY == 0,
- Pattern::ClusteredLowHit => row < rows / HIT_EVERY,
- Pattern::HighToLow => row < rows / 2 || row % HIT_EVERY == 0,
- };
- if hit {
- let key = (hits % build_rows) as i32 * key_step;
- hits += 1;
- key
- } else {
- // Every hole stays strictly between the build min and max.
- (row % (build_rows - 1)) as i32 * key_step + 1
- }
- }));
- let columns: Vec<ArrayRef> = vec![
- Arc::new(keys),
- Arc::new(Int32Array::from_iter_values(
- (start..end).map(|row| row as i32),
- )),
- Arc::new(StringArray::from_iter_values(
- (start..end).map(|row| format!("{row}")),
- )),
- ];
- RecordBatch::try_new(Arc::clone(schema), columns).unwrap()
- })
- .collect()
-}
-
-fn make_join(
- build_batches: &[RecordBatch],
- probe_batches: &[RecordBatch],
- join_type: JoinType,
-) -> Arc<dyn ExecutionPlan> {
- let schema = build_batches[0].schema();
- let build = TestMemoryExec::try_new_exec(
- &[build_batches.to_vec()],
- Arc::clone(&schema),
- None,
- )
- .unwrap();
- let probe = TestMemoryExec::try_new_exec(
- &[probe_batches.to_vec()],
- Arc::clone(&schema),
- None,
- )
- .unwrap();
- Arc::new(
- HashJoinExec::try_new(
- build,
- probe,
- vec![(col("key", &schema).unwrap(), col("key", &schema).unwrap())],
- None,
- &join_type,
- None,
- PartitionMode::CollectLeft,
- NullEquality::NullEqualsNothing,
- false,
- )
- .unwrap(),
- )
-}
-
-fn bench_hash_join_probe(c: &mut Criterion) {
- let rt = Runtime::new().unwrap();
- let config = SessionConfig::from_env()
- .unwrap()
- .with_batch_size(BATCH_SIZE);
- let context = Arc::new(TaskContext::default().with_session_config(config));
- let schema = Arc::new(Schema::new(vec![
- Field::new("key", DataType::Int32, false),
- Field::new("data", DataType::Int32, false),
- Field::new("payload", DataType::Utf8, false),
- ]));
- let mut group = c.benchmark_group("hash_join_probe");
- for (name, join_type, pattern, build_rows, probe_rows, key_step) in [
- (
- "right_semi_interleaved_10pct",
- JoinType::RightSemi,
- Pattern::InterleavedLowHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_semi_all_hit",
- JoinType::RightSemi,
- Pattern::AllHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_anti_interleaved_10pct",
- JoinType::RightAnti,
- Pattern::InterleavedLowHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_anti_all_hit",
- JoinType::RightAnti,
- Pattern::AllHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "inner_interleaved_10pct",
- JoinType::Inner,
- Pattern::InterleavedLowHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "inner_all_hit",
- JoinType::Inner,
- Pattern::AllHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_semi_clustered_10pct",
- JoinType::RightSemi,
- Pattern::ClusteredLowHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_anti_clustered_10pct",
- JoinType::RightAnti,
- Pattern::ClusteredLowHit,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_semi_high_to_low",
- JoinType::RightSemi,
- Pattern::HighToLow,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_anti_high_to_low",
- JoinType::RightAnti,
- Pattern::HighToLow,
- BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- (
- "right_semi_single_batch_all_hit",
- JoinType::RightSemi,
- Pattern::AllHit,
- BUILD_ROWS,
- BATCH_SIZE,
- SPARSE_KEY_STEP,
- ),
- (
- "right_semi_dense_100k_all_hit",
- JoinType::RightSemi,
- Pattern::AllHit,
- LARGE_BUILD_ROWS,
- PROBE_ROWS,
- DENSE_KEY_STEP,
- ),
- (
- "right_semi_sparse_100k_all_hit",
- JoinType::RightSemi,
- Pattern::AllHit,
- LARGE_BUILD_ROWS,
- PROBE_ROWS,
- SPARSE_KEY_STEP,
- ),
- ] {
- let build =
- make_batches(build_rows, build_rows, key_step, Pattern::AllHit, &schema);
- let probe = make_batches(probe_rows, build_rows, key_step, pattern, &schema);
- let run = || {
- let join = make_join(&build, &probe, join_type);
- rt.block_on(collect(join, Arc::clone(&context))).unwrap()
- };
-
- let hits = match pattern {
- Pattern::AllHit => probe_rows,
- Pattern::InterleavedLowHit | Pattern::ClusteredLowHit => {
- probe_rows / HIT_EVERY
- }
- Pattern::HighToLow => probe_rows / 2 + probe_rows / 2 / HIT_EVERY,
- };
- let expected_rows = if join_type == JoinType::RightAnti {
- probe_rows - hits
- } else {
- hits
- };
- let output = run();
- assert_eq!(
- output.iter().map(RecordBatch::num_rows).sum::<usize>(),
- expected_rows,
- "{name}",
- );
- drop(output);
-
- group.bench_function(name, |b| b.iter(|| black_box(run())));
- }
- group.finish();
-}
-
-criterion_group!(benches, bench_hash_join_probe);
-criterion_main!(benches);
diff --git a/datafusion/physical-plan/src/joins/hash_join/exec.rs b/datafusion/physical-plan/src/joins/hash_join/exec.rs
index 5c68018bda..806cff9773 100644
--- a/datafusion/physical-plan/src/joins/hash_join/exec.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/exec.rs
@@ -39,7 +39,6 @@ use crate::joins::hash_join::shared_bounds::{
use crate::joins::hash_join::stream::{
BuildSide, BuildSideInitialState, HashJoinStream, HashJoinStreamState,
};
-use crate::joins::integer_prefilter::{IntegerPrefilter, PrefilterState};
use crate::joins::join_hash_map::{JoinHashMapU32, JoinHashMapU64};
use crate::joins::key_range_bitmap::KeyRangeBitmap;
use crate::joins::utils::{
@@ -348,8 +347,6 @@ impl NullAwareMode {
struct JoinBuildData {
/// Hash table with row indices into `batch`, also shared with dynamic filters.
map: Arc<Map>,
- /// Optional exact integer membership bitmap shared by probe streams.
- integer_prefilter: Option<IntegerPrefilter>,
/// The input rows for the build side.
batch: RecordBatch,
/// Evaluated build-side key expressions, with float `-0.0` rewritten to
@@ -402,10 +399,6 @@ impl JoinLeftData {
&self.build.map
}
- pub(super) fn integer_prefilter(&self) -> Option<&IntegerPrefilter> {
- self.build.integer_prefilter.as_ref()
- }
-
pub(super) fn null_aware_scope_map(&self) -> Option<&dyn JoinHashMapType> {
self.null_aware_scope_map.as_deref()
}
@@ -1841,28 +1834,6 @@ impl ExecutionPlan for HashJoinExec {
.allow_join_dynamic_filter_pushdown(context.session_config().options())
&& self.dynamic_filter.is_some();
- let integer_prefilter_state = PrefilterState::try_from_config(
- &context.session_config().options().execution,
- )?
- .map(|state| {
- let reservation = MemoryConsumer::new("HashJoinIntegerPrefilter")
- .register(context.memory_pool());
- (state, reservation)
- });
- let (probe_prefilter_rows_pruned, integer_prefilter_created_count) =
- if integer_prefilter_state.is_some() {
- (
- MetricBuilder::new(&self.metrics)
- .with_category(MetricCategory::Rows)
- .counter("probe_prefilter_rows_pruned", partition),
- MetricBuilder::new(&self.metrics)
- .counter("integer_prefilter_created_count", partition),
- )
- } else {
- // Keep the default metrics unchanged when the prefilter is disabled.
- (Count::new(), Count::new())
- };
-
let join_metrics = BuildProbeJoinMetrics::new(partition, &self.metrics);
let null_aware = self.null_aware_mode()?;
@@ -1928,7 +1899,6 @@ impl ExecutionPlan for HashJoinExec {
self.null_equality,
null_aware,
array_map_created_count,
- integer_prefilter_created_count,
BuildMode::Ordinary,
))
})?,
@@ -1951,7 +1921,6 @@ impl ExecutionPlan for HashJoinExec {
self.null_equality,
null_aware,
array_map_created_count,
- integer_prefilter_created_count,
BuildMode::Ordinary,
))
}
@@ -2004,8 +1973,6 @@ impl ExecutionPlan for HashJoinExec {
self.mode,
null_aware,
self.fetch,
- integer_prefilter_state,
- probe_prefilter_rows_pruned,
)))
}
@@ -3250,7 +3217,6 @@ async fn collect_left_input(
null_equality: NullEquality,
null_aware: Option<NullAwareMode>,
array_map_created_count: Count,
- integer_prefilter_created_count: Count,
mode: BuildMode,
) -> Result<JoinLeftData> {
let schema = left_stream.schema();
@@ -3591,6 +3557,10 @@ async fn collect_left_input(
}
};
+ if is_phj_candidate && !should_compute_dynamic_filters {
+ bounds = None;
+ }
+
let build_has_null = null_aware == Some(NullAwareMode::RightAnti)
&& !left_values.is_empty()
&& left_values[0].logical_null_count() > 0;
@@ -3635,40 +3605,9 @@ async fn collect_left_input(
)?;
}
- // Reserve optional memory only after all mandatory join state has been
- // allocated. Reuse the bounds already computed for perfect hash join.
- let integer_prefilter = if config.execution.enable_join_integer_prefilter
- && null_aware.is_none()
- && matches!(map.as_ref(), Map::HashMap(_))
- && left_values.len() == 1
- {
- bounds
- .as_ref()
- .and_then(|bounds| bounds.get_column_bounds(0))
- .and_then(|bounds| {
- IntegerPrefilter::try_new(
- left_values[0].as_ref(),
- (&bounds.min, &bounds.max),
- config.execution.join_integer_prefilter_max_key_range,
- &reservation,
- )
- })
- } else {
- None
- };
- if let Some(filter) = &integer_prefilter {
- metrics.build_mem_used.add(filter.size());
- integer_prefilter_created_count.add(1);
- }
-
- if is_phj_candidate && !should_compute_dynamic_filters {
- bounds = None;
- }
-
let data = JoinLeftData {
build: Arc::new(JoinBuildData {
map,
- integer_prefilter,
batch,
values: normalized_values,
left_mark_build_key_nulls,
@@ -3691,230 +3630,6 @@ async fn collect_left_input(
mod tests {
use super::*;
- fn integer_prefilter_join(
- build: ArrayRef,
- probe: ArrayRef,
- ) -> Result<Arc<HashJoinExec>> {
- let table = |keys: ArrayRef| -> Result<Arc<dyn ExecutionPlan>> {
- let schema = Arc::new(Schema::new(vec![Field::new(
- "key",
- keys.data_type().clone(),
- true,
- )]));
- let batches = (0..keys.len())
- .step_by(3)
- .map(|offset| {
- RecordBatch::try_new(
- Arc::clone(&schema),
- vec![keys.slice(offset, 3.min(keys.len() - offset))],
- )
- })
- .collect::<std::result::Result<Vec<_>, _>>()?;
- Ok(TestMemoryExec::try_new_exec(&[batches], schema, None)?)
- };
- let left = table(build)?;
- let right = table(probe)?;
- let on = vec![(col("key", &left.schema())?, col("key", &right.schema())?)];
- Ok(Arc::new(HashJoinExec::try_new(
- left,
- right,
- on,
- None,
- &JoinType::Full,
- None,
- PartitionMode::CollectLeft,
- NullEquality::NullEqualsNothing,
- false,
- )?))
- }
-
- fn integer_prefilter_context(enabled: bool) -> Arc<TaskContext> {
- let mut config = SessionConfig::default().with_batch_size(2);
- config.options_mut().execution.enable_join_integer_prefilter = enabled;
- config
- .options_mut()
- .execution
- .join_integer_prefilter_sample_rows =
- datafusion_common::config::ConfigNonZeroUsize::try_new(3).unwrap();
- Arc::new(TaskContext::default().with_session_config(config))
- }
-
- #[tokio::test]
- async fn test_integer_prefilter_fallbacks() -> Result<()> {
- let cases: Vec<(ArrayRef, ArrayRef, bool)> = vec![
- (
- Arc::new(Int32Array::from(vec![0, 1])),
- Arc::new(Int32Array::from(vec![0, 2])),
- true,
- ),
- (
- Arc::new(StringArray::from(vec!["a", "c"])),
- Arc::new(StringArray::from(vec!["a", "b"])),
- false,
- ),
- (
- Arc::new(Int32Array::from(vec![None, None])),
- Arc::new(Int32Array::from(vec![None, Some(2)])),
- false,
- ),
- ];
- for (build, probe, phj) in cases {
- let join = integer_prefilter_join(build, probe)?;
- crate::collect(Arc::clone(&join) as _, integer_prefilter_context(true))
- .await?;
- let metrics = join.metrics().unwrap();
- assert_phj_used(&metrics, phj);
- assert_eq!(
- metrics
- .sum_by_name("integer_prefilter_created_count")
- .unwrap()
- .as_usize(),
- 0
- );
- assert_eq!(
- metrics
- .sum_by_name("probe_prefilter_rows_pruned")
- .unwrap()
- .as_usize(),
- 0
- );
- }
- Ok(())
- }
-
- #[tokio::test]
- async fn test_integer_prefilter_memory_fallback_preserves_join() -> Result<()> {
- use datafusion_execution::memory_pool::GreedyMemoryPool;
- let make_join = || {
- integer_prefilter_join(
- Arc::new(Int32Array::from(vec![0, 2048])),
- Arc::new(Int32Array::from(vec![0, 1, 2049])),
- )
- };
- // Measure mandatory build reservations, including the visited bitmap.
- let baseline = make_join()?;
- let expected =
- crate::collect(Arc::clone(&baseline) as _, integer_prefilter_context(false))
- .await?;
- let bytes = baseline
- .metrics()
- .unwrap()
- .sum_by_name("build_mem_used")
- .unwrap()
- .as_usize();
- // Either only mandatory state fits, or the build bitmap fits but the
- // additional probe masks do not. Both must preserve normal join output.
- for bitmap_bytes in [0, 2049_usize.div_ceil(64) * size_of::<u64>()] {
- let pool = Arc::new(GreedyMemoryPool::new(bytes + bitmap_bytes));
- let runtime = RuntimeEnvBuilder::new()
- .with_memory_pool(Arc::clone(&pool) as _)
- .build_arc()?;
- let context = integer_prefilter_context(true);
- let context = Arc::new(
- TaskContext::default()
- .with_session_config(context.session_config().clone())
- .with_runtime(runtime),
- );
- let join = make_join()?;
- let result = crate::collect(Arc::clone(&join) as _, context).await?;
- assert_eq!(
- batches_to_sort_string(&result),
- batches_to_sort_string(&expected)
- );
- let metrics = join.metrics().unwrap();
- assert_eq!(
- metrics
- .sum_by_name("integer_prefilter_created_count")
- .unwrap()
- .as_usize(),
- usize::from(bitmap_bytes > 0)
- );
- assert_eq!(
- metrics
- .sum_by_name("probe_prefilter_rows_pruned")
- .unwrap()
- .as_usize(),
- 0
- );
- assert_eq!(
- metrics.sum_by_name("build_mem_used").unwrap().as_usize(),
- bytes + bitmap_bytes
- );
- drop(join);
- use datafusion_execution::memory_pool::MemoryPool;
- assert_eq!(pool.reserved(), 0);
- }
- Ok(())
- }
-
- #[tokio::test]
- async fn test_integer_prefilter_shared_build() -> Result<()> {
- let schema =
- Arc::new(Schema::new(vec![Field::new("key", DataType::Int32, false)]));
- let hits = RecordBatch::try_new(
- Arc::clone(&schema),
- vec![Arc::new(Int32Array::from(vec![0; 12]))],
- )?;
- let misses = RecordBatch::try_new(
- Arc::clone(&schema),
- vec![Arc::new(Int32Array::from(vec![1; 12]))],
- )?;
- let mut expected = None;
- for enabled in [false, true] {
- let build = RecordBatch::try_new(
- Arc::clone(&schema),
- vec![Arc::new(Int32Array::from(vec![0, 2048]))],
- )?;
- let left =
- TestMemoryExec::try_new_exec(&[vec![build]], Arc::clone(&schema), None)?;
- // Partition 0 pauses on hits; partition 1 must independently prune.
- let right = TestMemoryExec::try_new_exec(
- &[vec![hits.clone()], vec![misses.clone()]],
- Arc::clone(&schema),
- None,
- )?;
- let on = vec![(col("key", &schema)?, col("key", &schema)?)];
- let join = Arc::new(HashJoinExec::try_new(
- left,
- right,
- on,
- None,
- &JoinType::Full,
- None,
- PartitionMode::CollectLeft,
- NullEquality::NullEqualsNothing,
- false,
- )?);
- let result = crate::collect(
- Arc::clone(&join) as _,
- integer_prefilter_context(enabled),
- )
- .await?;
- let output = batches_to_sort_string(&result);
- if enabled {
- assert_eq!(&output, expected.as_ref().unwrap());
- let metrics = join.metrics().unwrap();
- assert_eq!(
- metrics
- .sum_by_name("integer_prefilter_created_count")
- .unwrap()
- .as_usize(),
- 1
- );
- assert_eq!(
- metrics
- .sum_by_name("probe_prefilter_rows_pruned")
- .unwrap()
- .as_usize(),
- 12
- );
- } else {
- expected = Some(output);
- }
- }
- Ok(())
- }
-
fn assert_phj_used(metrics: &MetricsSet, use_phj: bool) {
if use_phj {
assert!(
@@ -4003,7 +3718,7 @@ mod tests {
};
use datafusion_execution::runtime_env::RuntimeEnvBuilder;
use datafusion_expr::Operator;
- use datafusion_physical_expr::expressions::{BinaryExpr, Literal, col};
+ use datafusion_physical_expr::expressions::{BinaryExpr, Literal};
use datafusion_physical_expr::{
EquivalenceProperties, PhysicalSortExpr, RangePartitioning, SplitPoint,
};
@@ -4782,7 +4497,6 @@ mod tests {
NullEquality::NullEqualsNothing,
None,
Count::new(),
- Count::new(),
BuildMode::Ordinary,
)
.await?;
diff --git a/datafusion/physical-plan/src/joins/hash_join/exec/prepared.rs b/datafusion/physical-plan/src/joins/hash_join/exec/prepared.rs
index a83e5df9a5..fb46cedf96 100644
--- a/datafusion/physical-plan/src/joins/hash_join/exec/prepared.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/exec/prepared.rs
@@ -197,7 +197,6 @@ impl HashJoinExec {
self.null_equality,
None,
count,
- Count::new(),
BuildMode::Prepared,
)
.await?;
diff --git a/datafusion/physical-plan/src/joins/hash_join/exec/prepared/tests.rs b/datafusion/physical-plan/src/joins/hash_join/exec/prepared/tests.rs
index 8b0e8d361d..48281e5f48 100644
--- a/datafusion/physical-plan/src/joins/hash_join/exec/prepared/tests.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/exec/prepared/tests.rs
@@ -163,82 +163,6 @@ fn payload_filter(op: Operator) -> JoinFilter {
)
}
-#[tokio::test]
-async fn prepared_build_integer_prefilter() -> Result<()> {
- use datafusion_execution::config::SessionConfig;
-
- let batches = vec![
- batch(vec![Some(0), Some(1024)]),
- batch(vec![Some(2048), Some(3072)]),
- ];
- let probe = batch(vec![
- Some(0),
- Some(1),
- Some(1024),
- Some(1025),
- Some(2048),
- Some(2049),
- Some(3072),
- ]);
- let base = join(batches[0].schema(), probe.clone())?;
- let mut baseline_bytes = 0;
- let mut expected = None;
- for build_enabled in [false, true] {
- let mut config = ConfigOptions::default();
- config.execution.enable_join_integer_prefilter = build_enabled;
- let prepared = base
- .prepare_build(
- input(batches.clone(), batches[0].schema()),
- Arc::new(GreedyMemoryPool::new(1 << 20)),
- Arc::new(config),
- )
- .await?;
- if build_enabled {
- let bitmap = prepared.build.integer_prefilter.as_ref().unwrap();
- assert!(bitmap.size() > 0);
- assert_eq!(prepared.reserved_bytes(), baseline_bytes + bitmap.size());
- } else {
- assert!(prepared.build.integer_prefilter.is_none());
- baseline_bytes = prepared.reserved_bytes();
- }
-
- // Repeated consumers share the bitmap, but each chooses whether to use it.
- for probe_enabled in [false, true, true] {
- let consumer = Arc::new(
- join(base.left().schema(), probe.clone())?
- .builder()
- .with_prepared_build(Arc::clone(&prepared))
- .build()?,
- );
- let mut config = SessionConfig::default();
- config.options_mut().execution.enable_join_integer_prefilter = probe_enabled;
- let context = Arc::new(TaskContext::default().with_session_config(config));
- let output = crate::collect(Arc::clone(&consumer) as _, context).await?;
- assert_eq!(output.iter().map(RecordBatch::num_rows).sum::<usize>(), 4);
- let output = batches_to_sort_string(&output);
- if let Some(expected) = &expected {
- assert_eq!(&output, expected);
- } else {
- expected = Some(output);
- }
- let metrics = consumer.metrics().unwrap();
- assert_eq!(
- metrics
- .sum_by_name("integer_prefilter_created_count")
- .map_or(0, |count| count.as_usize()),
- 0,
- );
- assert_eq!(
- metrics
- .sum_by_name("probe_prefilter_rows_pruned")
- .map_or(0, |count| count.as_usize()),
- if build_enabled && probe_enabled { 3 } else { 0 },
- );
- }
- }
- Ok(())
-}
-
#[tokio::test]
async fn prepared_build_placeholder_properties_and_reset() -> Result<()> {
let ascending = |name, index| PhysicalSortExpr {
diff --git a/datafusion/physical-plan/src/joins/hash_join/stream.rs b/datafusion/physical-plan/src/joins/hash_join/stream.rs
index a0fb90ad21..db12f65bb0 100644
--- a/datafusion/physical-plan/src/joins/hash_join/stream.rs
+++ b/datafusion/physical-plan/src/joins/hash_join/stream.rs
@@ -31,13 +31,11 @@ use crate::joins::hash_join::probe_completion::ProbeSideSummary;
use crate::joins::hash_join::shared_bounds::{
PartitionBounds, PartitionBuildData, SharedBuildAccumulator,
};
-use crate::joins::integer_prefilter::PrefilterState;
use crate::joins::join_hash_map::ProbeOffset;
use crate::joins::join_hash_map::ProbeOffset::AtRow;
use crate::joins::utils::{
JoinKeyComparator, OnceFut, equal_rows_arr_with_normalized_left, matchable_join_keys,
};
-use crate::metrics::Count;
use crate::stream::EmptyRecordBatchStream;
use crate::{
RecordBatchStream, SendableRecordBatchStream, handle_state,
@@ -58,7 +56,6 @@ use arrow::record_batch::RecordBatch;
use datafusion_common::{
JoinSide, JoinType, NullEquality, Result, internal_datafusion_err, internal_err,
};
-use datafusion_execution::memory_pool::MemoryReservation;
use datafusion_expr::{ColumnarValue, Operator};
use datafusion_physical_expr::PhysicalExprRef;
use datafusion_physical_expr_common::datum::apply_cmp;
@@ -192,8 +189,6 @@ pub(super) struct ProcessProbeBatchState {
/// exist and cannot match (`NullEquality::NullEqualsNothing`); NULL rows
/// are skipped during JoinHashMap lookups
valid_keys: Option<NullBuffer>,
- /// Original validity combined with integer membership, for lookup only.
- lookup_keys: Option<NullBuffer>,
/// Starting offset for JoinHashMap lookups
offset: ProbeOffset,
/// Max joined probe-side index from current batch
@@ -393,8 +388,6 @@ pub(super) struct HashJoinStream {
random_state: RandomState,
/// Metrics
join_metrics: BuildProbeJoinMetrics,
- integer_prefilter_state: Option<(PrefilterState, MemoryReservation)>,
- probe_prefilter_rows_pruned: Count,
/// Information of index and left / right placement of columns
column_indices: Vec<ColumnIndex>,
/// Defines the null equality for the join.
@@ -588,8 +581,6 @@ impl HashJoinStream {
mode: PartitionMode,
null_aware: Option<NullAwareMode>,
fetch: Option<usize>,
- integer_prefilter_state: Option<(PrefilterState, MemoryReservation)>,
- probe_prefilter_rows_pruned: Count,
) -> Self {
// Create output buffer with coalescing and optional fetch limit.
let output_buffer =
@@ -604,8 +595,6 @@ impl HashJoinStream {
right,
random_state,
join_metrics,
- integer_prefilter_state,
- probe_prefilter_rows_pruned,
column_indices,
null_equality,
state,
@@ -803,10 +792,6 @@ impl HashJoinStream {
&mut self,
cx: &mut std::task::Context<'_>,
) -> Poll<Result<StatefulStreamResult<Option<RecordBatch>>>> {
- // The previous batch's lookup mask has been released with its state.
- if let Some((_, reservation)) = &self.integer_prefilter_state {
- reservation.free();
- }
match ready!(self.right.poll_next_unpin(cx)) {
None => {
// Release the probe-side input pipeline's resources. The schema
@@ -835,47 +820,6 @@ impl HashJoinStream {
None
};
- let lookup_keys = if let (Some((state, reservation)), Some(filter)) = (
- self.integer_prefilter_state.as_mut(),
- self.build_side
- .try_as_ready()?
- .left_data
- .integer_prefilter(),
- ) {
- let timer = self.join_metrics.join_time.timer();
- let bytes = PrefilterState::mask_memory_size(
- batch.num_rows(),
- valid_keys.is_some(),
- );
- let lookup_keys = if state.should_filter(batch.num_rows())
- && bytes
- .is_some_and(|bytes| reservation.try_resize(bytes).is_ok())
- {
- if let Some(mask) = state.filter(filter, keys_values[0].as_ref())
- {
- self.probe_prefilter_rows_pruned.add(mask.null_count());
- let lookup =
- NullBuffer::union(valid_keys.as_ref(), Some(&mask));
- drop(mask);
- reservation.resize(
- lookup
- .as_ref()
- .map_or(0, |mask| mask.inner().inner().capacity()),
- );
- lookup
- } else {
- reservation.free();
- valid_keys.clone()
- }
- } else {
- valid_keys.clone()
- };
- timer.done();
- lookup_keys
- } else {
- valid_keys.clone()
- };
-
self.join_metrics.input_batches.add(1);
self.join_metrics.input_rows.add(batch.num_rows());
@@ -884,7 +828,6 @@ impl HashJoinStream {
batch,
values: keys_values,
valid_keys,
- lookup_keys,
offset: AtRow { row: 0 },
joined_probe_idx: None,
matched_probe_idx: None,
@@ -976,7 +919,7 @@ impl HashJoinStream {
&state.values,
self.null_equality,
&self.hashes_buffer,
- state.lookup_keys.as_ref(),
+ state.valid_keys.as_ref(),
self.batch_size,
state.offset,
&mut self.probe_indices_buffer,
diff --git a/datafusion/physical-plan/src/joins/integer_prefilter.rs b/datafusion/physical-plan/src/joins/integer_prefilter.rs
deleted file mode 100644
index 01e5d0d2c6..0000000000
--- a/datafusion/physical-plan/src/joins/integer_prefilter.rs
+++ /dev/null
@@ -1,459 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-//! Exact membership filtering for a single integer hash join key.
-//!
-//! This only avoids hash table lookups. Probe rows remain in their original
-//! batch so outer, anti and mark joins can still produce unmatched results.
-
-use crate::joins::array_map::ArrayMap;
-use arrow::array::Array;
-use arrow::array::downcast_integer_array;
-use arrow::buffer::{BooleanBuffer, NullBuffer};
-use arrow::datatypes::DataType;
-use datafusion_common::config::ExecutionOptions;
-use datafusion_common::{Result, ScalarValue, config_err};
-use datafusion_execution::memory_pool::MemoryReservation;
-
-/// One bit per integer in the build key range, shared by all probe streams.
-#[derive(Debug)]
-pub(super) struct IntegerPrefilter {
- offset: u64,
- key_count: u64,
- words: Vec<u64>,
- data_type: DataType,
-}
-
-impl IntegerPrefilter {
- /// Uses already computed build bounds. Failure to reserve this optional
- /// allocation leaves the normal hash join available.
- #[expect(
- clippy::unnecessary_cast,
- reason = "the integer downcast macro also expands for UInt64"
- )]
- pub(super) fn try_new(
- values: &dyn Array,
- bounds: (&ScalarValue, &ScalarValue),
- max_key_range: u64,
- reservation: &MemoryReservation,
- ) -> Option<Self> {
- if !ArrayMap::is_supported_type(values.data_type()) || max_key_range == 0 {
- return None;
- }
- let offset = ArrayMap::key_to_u64(bounds.0)?;
- let max = ArrayMap::key_to_u64(bounds.1)?;
- let key_count = max.wrapping_sub(offset).checked_add(1)?;
- if key_count > max_key_range {
- return None;
- }
- let word_count = usize::try_from(key_count.div_ceil(64)).ok()?;
- let bytes = word_count.checked_mul(size_of::<u64>())?;
- reservation.try_grow(bytes).ok()?;
- let mut words = Vec::new();
- if words.try_reserve_exact(word_count).is_err() {
- reservation.shrink(bytes);
- return None;
- }
- let extra = (words.capacity() - word_count) * size_of::<u64>();
- if reservation.try_grow(extra).is_err() {
- reservation.shrink(bytes);
- return None;
- }
- words.resize(word_count, 0);
- downcast_integer_array!(values => {
- for value in values.iter().flatten() {
- let index = (value as u64).wrapping_sub(offset);
- if index >= key_count {
- reservation.shrink(bytes + extra);
- return None;
- }
- words[(index / 64) as usize] |= 1 << (index % 64);
- }
- }
- _ => unreachable!("integer type checked above"));
- Some(Self {
- offset,
- key_count,
- words,
- data_type: values.data_type().clone(),
- })
- }
-
- pub(super) fn size(&self) -> usize {
- self.words.capacity() * size_of::<u64>()
- }
-
- #[inline]
- fn contains(&self, value: u64) -> bool {
- // As in ArrayMap, wrapping subtraction also handles signed ranges
- // crossing zero and values below the build minimum.
- let index = value.wrapping_sub(self.offset);
- index < self.key_count
- && self.words[(index / 64) as usize] & (1 << (index % 64)) != 0
- }
-}
-
-/// Each probe stream independently measures additional skipped lookups.
-/// Windows end at batch boundaries after at least `sample_rows` input rows,
-/// including NULLs. Unprofitable windows pause for 10 to 128 windows of input
-/// rows, doubling the pause until a profitable sample resets it.
-#[derive(Debug)]
-pub(super) struct PrefilterState {
- rows_observed: usize,
- rows_pruned: usize,
- rows_to_skip: usize,
- pause_rows: usize,
- sample_rows: usize,
- min_pruning_ratio: f64,
-}
-
-impl PrefilterState {
- fn new(sample_rows: usize, min_pruning_ratio: f64) -> Self {
- Self {
- rows_observed: 0,
- rows_pruned: 0,
- rows_to_skip: 0,
- pause_rows: sample_rows.saturating_mul(10),
- sample_rows,
- min_pruning_ratio,
- }
- }
-
- pub(super) fn try_from_config(config: &ExecutionOptions) -> Result<Option<Self>> {
- if !config.enable_join_integer_prefilter {
- return Ok(None);
- }
- let ratio = config.join_integer_prefilter_min_pruning_ratio;
- if !(0.0..=1.0).contains(&ratio) {
- return config_err!(
- "join_integer_prefilter_min_pruning_ratio must be finite and in [0, 1]"
- );
- }
- Ok(Some(Self::new(
- config.join_integer_prefilter_sample_rows.get(),
- ratio,
- )))
- }
-
- /// Call before reserving or constructing a lookup mask. A paused batch
- /// advances only the cooldown and keeps the original validity mask.
- pub(super) fn should_filter(&mut self, rows: usize) -> bool {
- if self.rows_to_skip > 0 {
- self.rows_to_skip = self.rows_to_skip.saturating_sub(rows);
- return false;
- }
- rows > 0
- }
-
- /// Upper bound for simultaneously live membership and combined masks.
- /// A bitmap union with differing bit offsets may double its allocation
- /// when appending a partial word. No union allocation is needed without NULLs.
- pub(super) fn mask_memory_size(rows: usize, has_validity: bool) -> Option<usize> {
- rows.div_ceil(8)
- .checked_next_multiple_of(64)?
- .checked_mul(if has_validity { 3 } else { 1 })
- }
-
- /// Returns a membership mask that retains NULLs. The caller combines it
- /// with the original validity and counts excluded rows with `null_count`.
- pub(super) fn filter(
- &mut self,
- filter: &IntegerPrefilter,
- values: &dyn Array,
- ) -> Option<NullBuffer> {
- if values.data_type() != &filter.data_type {
- return None;
- }
- if values.null_count() == values.len() {
- self.record_sample(values.len(), 0);
- return None;
- }
- let mask = downcast_integer_array!(values => {
- if values.null_count() == 0 {
- let values = values.values();
- BooleanBuffer::collect_bool(values.len(), |i| {
- filter.contains(values[i] as u64)
- })
- } else {
- BooleanBuffer::collect_bool(values.len(), |i| {
- values.is_null(i) || filter.contains(values.value(i) as u64)
- })
- }
- }
- _ => return None);
- let mask = NullBuffer::new(mask);
- let pruned = mask.null_count();
- self.record_sample(values.len(), pruned);
- (pruned > 0).then_some(mask)
- }
-
- fn record_sample(&mut self, rows: usize, pruned: usize) {
- self.rows_observed = self.rows_observed.saturating_add(rows);
- self.rows_pruned = self.rows_pruned.saturating_add(pruned);
- if self.rows_observed >= self.sample_rows {
- if (self.rows_pruned as f64 / self.rows_observed as f64)
- <= self.min_pruning_ratio
- {
- self.rows_to_skip = self.pause_rows;
- self.pause_rows = self
- .pause_rows
- .saturating_mul(2)
- .min(self.sample_rows.saturating_mul(128));
- } else {
- self.pause_rows = self.sample_rows.saturating_mul(10);
- }
- self.rows_observed = 0;
- self.rows_pruned = 0;
- }
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use arrow::array::{
- Int8Array, Int16Array, Int32Array, Int64Array, UInt8Array, UInt16Array,
- UInt32Array, UInt64Array,
- };
- use datafusion_execution::memory_pool::{
- GreedyMemoryPool, MemoryConsumer, MemoryPool,
- };
- use std::sync::Arc;
-
- fn reservation(limit: usize) -> MemoryReservation {
- let pool: Arc<dyn MemoryPool> = Arc::new(GreedyMemoryPool::new(limit));
- MemoryConsumer::new("integer prefilter test").register(&pool)
- }
-
- #[test]
- fn membership_and_integer_boundaries() {
- macro_rules! check {
- ($array:ty, $scalar:ident, $min:expr) => {{
- let min = $min;
- let build =
- <$array>::from(vec![Some(min), Some(min + 2), Some(min), None]);
- let memory = reservation(8);
- let filter = IntegerPrefilter::try_new(
- &build,
- (
- &ScalarValue::$scalar(Some(min)),
- &ScalarValue::$scalar(Some(min + 2)),
- ),
- 3,
- &memory,
- )
- .unwrap();
- assert_eq!(memory.size(), 8);
- assert!(!filter.contains((min as u64).wrapping_sub(1)));
- let probe = <$array>::from(vec![
- None,
- Some(min),
- Some(min + 1),
- Some(min + 2),
- Some(min + 3),
- ]);
- let mask = PrefilterState::new(10, 0.5)
- .filter(&filter, &probe)
- .unwrap();
- assert_eq!(mask.null_count(), 2);
- assert_eq!(
- mask.iter().collect::<Vec<_>>(),
- vec![true, true, false, true, false]
- );
- }};
- }
- check!(Int8Array, Int8, i8::MIN);
- check!(Int16Array, Int16, i16::MIN);
- check!(Int32Array, Int32, -1_i32);
- check!(Int64Array, Int64, i64::MIN);
- check!(Int64Array, Int64, i64::MAX - 3);
- check!(UInt8Array, UInt8, 0_u8);
- check!(UInt16Array, UInt16, 0_u16);
- check!(UInt32Array, UInt32, 0_u32);
- check!(UInt64Array, UInt64, u64::MAX - 3);
- }
-
- #[test]
- fn mismatched_probe_type_is_not_filtered() {
- let memory = reservation(8);
- let filter = IntegerPrefilter::try_new(
- &Int32Array::from(vec![1]),
- (&ScalarValue::Int32(Some(1)), &ScalarValue::Int32(Some(1))),
- 1,
- &memory,
- )
- .unwrap();
- assert_eq!(
- PrefilterState::new(4, 0.5).filter(&filter, &UInt64Array::from(vec![1, 2])),
- None
- );
- }
-
- #[test]
- fn range_overflow() {
- let build = Int64Array::from(vec![i64::MIN, i64::MAX]);
- let memory = reservation(1024);
- assert!(
- IntegerPrefilter::try_new(
- &build,
- (
- &ScalarValue::Int64(Some(i64::MIN)),
- &ScalarValue::Int64(Some(i64::MAX))
- ),
- u64::MAX,
- &memory
- )
- .is_none()
- );
- assert_eq!(memory.size(), 0);
- let build = UInt64Array::from(vec![0, u64::MAX]);
- assert!(
- IntegerPrefilter::try_new(
- &build,
- (
- &ScalarValue::UInt64(Some(0)),
- &ScalarValue::UInt64(Some(u64::MAX))
- ),
- u64::MAX,
- &memory
- )
- .is_none()
- );
- }
-
- #[test]
- fn bitmap_word_boundaries() {
- let build = Int32Array::from(vec![-1, 62, 63, 64]);
- let memory = reservation(16);
- let filter = IntegerPrefilter::try_new(
- &build,
- (&ScalarValue::Int32(Some(-1)), &ScalarValue::Int32(Some(64))),
- 66,
- &memory,
- )
- .unwrap();
- assert_eq!(filter.size(), 16);
- assert_eq!(memory.size(), filter.size());
- for key in -2_i32..=65 {
- assert_eq!(filter.contains(key as u64), [-1, 62, 63, 64].contains(&key));
- }
- }
-
- #[test]
- fn sampling_counts_nulls_and_pauses_at_threshold() {
- let memory = reservation(8);
- let filter = IntegerPrefilter::try_new(
- &Int32Array::from(vec![1]),
- (&ScalarValue::Int32(Some(1)), &ScalarValue::Int32(Some(1))),
- 1,
- &memory,
- )
- .unwrap();
- let mut state = PrefilterState::new(8, 0.5);
- let values = Int32Array::from(vec![Some(2), Some(2), None, None]);
- for _ in 0..2 {
- assert!(state.should_filter(values.len()));
- let mask = state.filter(&filter, &values);
- assert_eq!(mask.as_ref().unwrap().null_count(), 2);
- assert_eq!(
- mask.unwrap().iter().collect::<Vec<_>>(),
- vec![false, false, true, true]
- );
- }
- // Four misses out of eight input rows reaches, but does not exceed,
- // the threshold. The two batches finish one window despite the NULLs.
- assert_eq!(state.rows_to_skip, 80);
- assert!(!state.should_filter(79));
- assert!(!state.should_filter(2));
- assert!(state.should_filter(1));
- assert_eq!(state.rows_observed, 0);
- assert_eq!(state.rows_pruned, 0);
-
- // The all-NULL fast path must also consume the sampling window.
- let mut state = PrefilterState::new(4, 0.5);
- assert!(!state.should_filter(0));
- let nulls = Int32Array::from(vec![None; 4]);
- assert!(state.should_filter(nulls.len()));
- assert_eq!(state.filter(&filter, &nulls), None);
- assert_eq!(state.rows_to_skip, 40);
- }
-
- #[test]
- fn sampling_backoff_caps_and_resets() {
- let mut state = PrefilterState::new(4, 0.5);
- for multiplier in [10, 20, 40, 80, 128, 128] {
- assert!(state.should_filter(4));
- state.record_sample(4, 0);
- assert_eq!(state.rows_to_skip, 4 * multiplier);
- assert!(!state.should_filter(4 * multiplier));
- }
- assert!(state.should_filter(4));
- state.record_sample(4, 3);
- assert_eq!(state.rows_to_skip, 0);
- assert_eq!(state.pause_rows, 40);
- state.record_sample(4, 0);
- assert_eq!(state.rows_to_skip, 40);
-
- // Threshold endpoints and saturating row arithmetic.
- let mut state = PrefilterState::new(1, 0.0);
- state.record_sample(1, 0);
- assert_eq!(state.rows_to_skip, 10);
- let mut state = PrefilterState::new(1, 1.0);
- state.record_sample(1, 1);
- assert_eq!(state.rows_to_skip, 10);
- let mut state = PrefilterState::new(usize::MAX, 0.5);
- state.record_sample(usize::MAX - 1, 0);
- state.record_sample(4, 0);
- assert_eq!(state.rows_to_skip, usize::MAX);
- assert_eq!(state.pause_rows, usize::MAX);
- assert!(!state.should_filter(usize::MAX));
- state.record_sample(usize::MAX - 1, usize::MAX - 1);
- state.record_sample(4, 4);
- assert_eq!(state.rows_to_skip, 0);
- }
-
- #[test]
- fn sliced_validity_mask_memory() {
- // A trailing partial word forces Arrow's differently aligned bitmap
- // union to grow. Account for both allocations while they coexist.
- let rows = 8193;
- let values = Int32Array::from_iter(
- (0..=rows).map(|i| (i % 3 != 0).then_some((i % 2) as i32)),
- )
- .slice(1, rows);
- let memory = reservation(8);
- let filter = IntegerPrefilter::try_new(
- &Int32Array::from(vec![0]),
- (&ScalarValue::Int32(Some(0)), &ScalarValue::Int32(Some(0))),
- 1,
- &memory,
- )
- .unwrap();
- let mask = PrefilterState::new(rows, 0.5)
- .filter(&filter, &values)
- .unwrap();
- let pruned = mask.null_count();
- let lookup = NullBuffer::union(values.nulls(), Some(&mask)).unwrap();
- let peak = mask.inner().inner().capacity() + lookup.inner().inner().capacity();
- assert!(peak <= PrefilterState::mask_memory_size(rows, true).unwrap());
- assert_eq!(pruned, values.iter().filter(|v| *v == Some(1)).count());
- assert_eq!(
- lookup.iter().collect::<Vec<_>>(),
- values.iter().map(|v| v == Some(0)).collect::<Vec<_>>()
- );
- }
-}
diff --git a/datafusion/physical-plan/src/joins/mod.rs b/datafusion/physical-plan/src/joins/mod.rs
index 38d31d16c3..259e49fd62 100644
--- a/datafusion/physical-plan/src/joins/mod.rs
+++ b/datafusion/physical-plan/src/joins/mod.rs
@@ -44,7 +44,6 @@ mod asof_join;
mod chain;
mod cross_join;
mod hash_join;
-mod integer_prefilter;
mod logical_batch;
mod nested_loop_join;
mod piecewise_merge_join;
diff --git a/datafusion/sqllogictest/test_files/hash_join_integer_prefilter.slt b/datafusion/sqllogictest/test_files/hash_join_integer_prefilter.slt
deleted file mode 100644
index a4869a460d..0000000000
--- a/datafusion/sqllogictest/test_files/hash_join_integer_prefilter.slt
+++ /dev/null
@@ -1,242 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Exercise the integer prefilter inside HashJoin, including probe rows that
-# skip lookup but must still contribute to outer, anti, and mark join output.
-# Sparse keys avoid the existing ArrayMap path. Keep the SQL build/probe order
-# and prevent dynamic filters from removing probe rows before HashJoin sees them.
-statement ok
-SET datafusion.execution.target_partitions = 1;
-
-statement ok
-SET datafusion.optimizer.join_reordering = false;
-
-statement ok
-SET datafusion.optimizer.enable_join_dynamic_filter_pushdown = false;
-
-statement ok
-SET datafusion.explain.analyze_categories = 'rows,uncategorized';
-
-statement ok
-SET datafusion.catalog.information_schema = true;
-
-query TT rowsort
-SELECT name, value FROM information_schema.df_settings
-WHERE name LIKE 'datafusion.execution.%join_integer_prefilter%';
-----
-datafusion.execution.enable_join_integer_prefilter false
-datafusion.execution.join_integer_prefilter_max_key_range 262144
-datafusion.execution.join_integer_prefilter_min_pruning_ratio 0.5
-datafusion.execution.join_integer_prefilter_sample_rows 12288
-
-statement ok
-CREATE TABLE build(k INT, label VARCHAR) AS VALUES
- (NULL, 'build_null'), (0, 'zero_a'), (0, 'zero_b'), (2048, 'build_only');
-
-statement ok
-CREATE TABLE probe(k INT, label VARCHAR) AS VALUES
- (NULL, 'probe_null'), (-1, 'below'), (0, 'hit_a'),
- (1, 'gap'), (3000, 'above'), (0, 'hit_b');
-
-# Baseline: duplicate matches and unmatched rows on both sides.
-query TT rowsort
-SELECT b.label, p.label FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-NULL above
-NULL below
-NULL gap
-NULL probe_null
-build_null NULL
-build_only NULL
-zero_a hit_a
-zero_a hit_b
-zero_b hit_a
-zero_b hit_b
-
-statement ok
-SET datafusion.execution.enable_join_integer_prefilter = true;
-
-# The bitmap is created and rejects below-range, in-range-gap, and above-range
-# keys. The NULL probe key is already invalid for equality and is not counted.
-# These three rejected rows must remain in the full join's output.
-query TT
-EXPLAIN ANALYZE SELECT * FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-Plan with Metrics
-01)HashJoinExec: mode=CollectLeft, join_type=Full, on=[(k@0, k@0)], metrics=[output_rows=10, <slt:ignore>array_map_created_count=0, <slt:ignore>integer_prefilter_created_count=1, probe_prefilter_rows_pruned=3, <slt:ignore>]
-02)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-03)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-
-query TT rowsort
-SELECT b.label, p.label FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-NULL above
-NULL below
-NULL gap
-NULL probe_null
-build_null NULL
-build_only NULL
-zero_a hit_a
-zero_a hit_b
-zero_b hit_a
-zero_b hit_b
-
-query TT rowsort
-SELECT b.label, p.label FROM build b JOIN probe p ON b.k = p.k;
-----
-zero_a hit_a
-zero_a hit_b
-zero_b hit_a
-zero_b hit_b
-
-# NULL equality must still look up the build-side NULL.
-query TT rowsort
-SELECT b.label, p.label FROM build b JOIN probe p
-ON b.k IS NOT DISTINCT FROM p.k;
-----
-build_null probe_null
-zero_a hit_a
-zero_a hit_b
-zero_b hit_a
-zero_b hit_b
-
-# Anti joins retain rejected probe rows and unmatched build rows respectively.
-query T rowsort
-SELECT p.label FROM build b RIGHT ANTI JOIN probe p ON b.k = p.k;
-----
-above
-below
-gap
-probe_null
-
-query T rowsort
-SELECT b.label FROM build b LEFT ANTI JOIN probe p ON b.k = p.k;
-----
-build_null
-build_only
-
-query T rowsort
-SELECT p.label FROM build b RIGHT SEMI JOIN probe p ON b.k = p.k;
-----
-hit_a
-hit_b
-
-# IS NULL around IN requires a null-aware mark join, which bypasses the
-# prefilter and preserves SQL's three-valued result.
-query TT
-EXPLAIN ANALYZE SELECT p.label FROM probe p
-WHERE (p.k IN (SELECT k FROM build)) IS NULL;
-----
-Plan with Metrics
-<slt:ignore>HashJoinExec: mode=CollectLeft, join_type=LeftMark, on=[(k@0, k@0)], <slt:ignore>null_aware, metrics=[output_rows=6, <slt:ignore>array_map_created_count=0, <slt:ignore>integer_prefilter_created_count=0, probe_prefilter_rows_pruned=0, <slt:ignore>]
-<slt:ignore>
-
-query T rowsort
-SELECT p.label FROM probe p WHERE (p.k IN (SELECT k FROM build)) IS NULL;
-----
-above
-below
-gap
-probe_null
-
-query T rowsort
-SELECT p.label FROM probe p
-WHERE (p.k IN (SELECT k FROM build WHERE k IS NOT NULL)) IS NULL;
-----
-probe_null
-
-query T rowsort
-SELECT p.label FROM probe p
-WHERE (p.k IN (SELECT k FROM build WHERE k IS NOT NULL)) IS FALSE;
-----
-above
-below
-gap
-
-# NOT IN must not emit the misses when its subquery contains NULL.
-query T rowsort
-SELECT p.label FROM probe p WHERE p.k NOT IN (SELECT k FROM build);
-----
-
-query T rowsort
-SELECT p.label FROM probe p
-WHERE p.k NOT IN (SELECT k FROM build WHERE k IS NOT NULL);
-----
-above
-below
-gap
-
-# max_key_range counts max - min + 1: 0..=2048 needs 2049 bits. A smaller
-# configured limit falls back to the normal hash lookup with identical output.
-statement ok
-SET datafusion.execution.join_integer_prefilter_max_key_range = 2048;
-
-query TT
-EXPLAIN ANALYZE SELECT * FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-Plan with Metrics
-01)HashJoinExec: mode=CollectLeft, join_type=Full, on=[(k@0, k@0)], metrics=[output_rows=10, <slt:ignore>array_map_created_count=0, <slt:ignore>integer_prefilter_created_count=0, probe_prefilter_rows_pruned=0, <slt:ignore>]
-02)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-03)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-
-query TT rowsort
-SELECT b.label, p.label FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-NULL above
-NULL below
-NULL gap
-NULL probe_null
-build_null NULL
-build_only NULL
-zero_a hit_a
-zero_a hit_b
-zero_b hit_a
-zero_b hit_b
-
-# A zero range disables bitmap construction without disabling the feature.
-statement ok
-SET datafusion.execution.join_integer_prefilter_max_key_range = 0;
-
-query TT
-EXPLAIN ANALYZE SELECT * FROM build b FULL JOIN probe p ON b.k = p.k;
-----
-Plan with Metrics
-01)HashJoinExec: mode=CollectLeft, join_type=Full, on=[(k@0, k@0)], metrics=[output_rows=10, <slt:ignore>array_map_created_count=0, <slt:ignore>integer_prefilter_created_count=0, probe_prefilter_rows_pruned=0, <slt:ignore>]
-02)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-03)--DataSourceExec: partitions=1, partition_sizes=[1], metrics=[]
-
-statement ok
-RESET datafusion.execution.enable_join_integer_prefilter;
-
-statement ok
-RESET datafusion.execution.join_integer_prefilter_max_key_range;
-
-# The SLT runner starts with four partitions, rather than the CPU-count default.
-statement ok
-SET datafusion.execution.target_partitions = 4;
-
-statement ok
-RESET datafusion.optimizer.join_reordering;
-
-statement ok
-RESET datafusion.optimizer.enable_join_dynamic_filter_pushdown;
-
-statement ok
-RESET datafusion.explain.analyze_categories;
-
-statement ok
-RESET datafusion.catalog.information_schema;
diff --git a/datafusion/sqllogictest/test_files/information_schema.slt b/datafusion/sqllogictest/test_files/information_schema.slt
index 2381fc14e3..25ada65f69 100644
--- a/datafusion/sqllogictest/test_files/information_schema.slt
+++ b/datafusion/sqllogictest/test_files/information_schema.slt
@@ -218,15 +218,11 @@ datafusion.execution.coalesce_batches true
datafusion.execution.collect_statistics true
datafusion.execution.enable_ansi_mode false
datafusion.execution.enable_file_stream_work_stealing true
-datafusion.execution.enable_join_integer_prefilter false
datafusion.execution.enable_migration_aggregate true
datafusion.execution.enable_nlj_coordinated_fallback true
datafusion.execution.enable_recursive_ctes true
datafusion.execution.enforce_batch_size_in_joins false
datafusion.execution.hash_join_buffering_capacity 0
-datafusion.execution.join_integer_prefilter_max_key_range 262144
-datafusion.execution.join_integer_prefilter_min_pruning_ratio 0.5
-datafusion.execution.join_integer_prefilter_sample_rows 12288
datafusion.execution.keep_partition_by_columns false
datafusion.execution.listing_table_factory_infer_partitions true
datafusion.execution.listing_table_ignore_subdirectory true
@@ -387,15 +383,11 @@ datafusion.execution.coalesce_batches true When set to true, record batches will
datafusion.execution.collect_statistics true Should DataFusion collect statistics when first creating a table. Has no effect after the table is created. Defaults to true.
datafusion.execution.enable_ansi_mode false Whether to enable ANSI SQL mode. The flag is experimental and relevant only for DataFusion Spark built-in functions When `enable_ansi_mode` is set to `true`, the query engine follows ANSI SQL semantics for expressions, casting, and error handling. This means: - **Strict type coercion rules:** implicit casts between incompatible types are disallowed. - **Standard SQL arithmetic behavior:** operations such as division by zero, numeric overflow, [...]
datafusion.execution.enable_file_stream_work_stealing true When `true` (the default), DataFusion's built-in file scans dynamically rebalance files across partitions at query execution time: a partition that goes idle reads files (or byte-range morsels) originally assigned to a sibling partition, which keeps all partitions busy in a single process. Executors that depend on the plan-time partition assignment — such as Ballista and datafusion-distributed, which run each partition as an isol [...]
-datafusion.execution.enable_join_integer_prefilter false Enable an exact integer membership prefilter for hash joins with a single integer key when the build side uses a hash table and the join is not null-aware. It skips lookups for absent keys while retaining NULLs and probe rows for the original join logic.
datafusion.execution.enable_migration_aggregate true Whether aggregation uses the implementation from the major refactor completed in the 56.0.0 release. When set to `false`, aggregation falls back to the implementation used before 55.0.0. The fallback exists only as a workaround for bugs in the new implementation and will be removed, together with this option, after the 56.0.0 release. See <https://github.com/apache/datafusion/issues/22710> for details.
datafusion.execution.enable_nlj_coordinated_fallback true Enables the memory-limited fallback for `NestedLoopJoinExec` join types that emit unmatched left rows in the final output (LEFT, LEFT SEMI, LEFT ANTI, LEFT MARK, FULL) when the right side has multiple partitions. This fallback shares left-side state (the current left chunk, the visited bitmap and the probe-thread counter) across all right-side partitions, which assumes every partition runs in the same process. Distributed engines [...]
datafusion.execution.enable_recursive_ctes true Should DataFusion support recursive CTEs
datafusion.execution.enforce_batch_size_in_joins false Should DataFusion enforce batch size in joins or not. By default, DataFusion will not enforce batch size in joins. Enforcing batch size in joins can reduce memory usage when joining large tables with a highly-selective join filter, but is also slightly slower. Note: this option currently only applies to the symmetric hash join.
datafusion.execution.hash_join_buffering_capacity 0 How many bytes to buffer in the probe side of hash joins while the build side is concurrently being built. Without this, hash joins will wait until the full materialization of the build side before polling the probe side. This is useful in scenarios where the query is not completely CPU bounded, allowing to do some early work concurrently and reducing the latency of the query. Note that when hash join buffering is enabled, the probe sid [...]
-datafusion.execution.join_integer_prefilter_max_key_range 262144 Maximum number of integer values covered by the join prefilter bitmap (`max_key - min_key + 1`). Zero disables bitmap construction. Larger ranges fall back to normal hash table lookups.
-datafusion.execution.join_integer_prefilter_min_pruning_ratio 0.5 The integer prefilter must prune more than this fraction of all sampled probe rows, including NULLs, to keep filtering. Must be finite and in [0, 1], validated when executing the join.
-datafusion.execution.join_integer_prefilter_sample_rows 12288 Minimum input probe rows in each integer prefilter sampling window, including NULLs. Must be greater than zero. Windows end at batch boundaries. Unprofitable samples initially pause for 10 times this many input rows; consecutive failures double the pause up to 128 times. A profitable sample resets the pause to 10 times this many rows.
datafusion.execution.keep_partition_by_columns false Should DataFusion keep the columns used for partition_by in the output RecordBatches
datafusion.execution.listing_table_factory_infer_partitions true Should a `ListingTable` created through the `ListingTableFactory` infer table partitions from Hive compliant directories. Defaults to true (partition columns are inferred and will be represented in the table schema).
datafusion.execution.listing_table_ignore_subdirectory true Should sub directories be ignored when scanning directories for data files. Defaults to true (ignores subdirectories), consistent with Hive. Note that this setting does not affect reading partitioned tables (e.g. `/table/year=2021/month=01/data.parquet`).
diff --git a/docs/source/user-guide/configs.md b/docs/source/user-guide/configs.md
index 273b0e39cf..44868ae2c9 100644
--- a/docs/source/user-guide/configs.md
+++ b/docs/source/user-guide/configs.md
@@ -76,10 +76,6 @@ The following configuration settings are available:
| datafusion.execution.batch_size | 8192 | Default batch size while creating new batches, it's especially useful for buffer-in-memory batches since creating tiny batches would result in too much metadata memory consumption [...]
| datafusion.execution.perfect_hash_join_small_build_threshold | 1024 | A perfect hash join (see `HashJoinExec` for more details) will be considered if the range of keys (max - min) on the build side is < this threshold. This provides a fast path for joins with very small key ranges, bypassing the density check. Currently only supports cases where build_side.num_rows() < u32::MAX. Support for build_side.num_rows() >= u32::MAX will be added in the future. [...]
| datafusion.execution.perfect_hash_join_min_key_density | 0.15 | The minimum required density of join keys on the build side to consider a perfect hash join (see `HashJoinExec` for more details). Density is calculated as: `(number of rows) / (max_key - min_key + 1)`. A perfect hash join may be used if the actual key density > this value. Currently only supports cases where build_side.num_rows() < u32::MAX. Support for build_side.num_rows() >= u32::M [...]
-| datafusion.execution.enable_join_integer_prefilter | false | Enable an exact integer membership prefilter for hash joins with a single integer key when the build side uses a hash table and the join is not null-aware. It skips lookups for absent keys while retaining NULLs and probe rows for the original join logic. [...]
-| datafusion.execution.join_integer_prefilter_max_key_range | 262144 | Maximum number of integer values covered by the join prefilter bitmap (`max_key - min_key + 1`). Zero disables bitmap construction. Larger ranges fall back to normal hash table lookups. [...]
-| datafusion.execution.join_integer_prefilter_min_pruning_ratio | 0.5 | The integer prefilter must prune more than this fraction of all sampled probe rows, including NULLs, to keep filtering. Must be finite and in [0, 1], validated when executing the join. [...]
-| datafusion.execution.join_integer_prefilter_sample_rows | 12288 | Minimum input probe rows in each integer prefilter sampling window, including NULLs. Must be greater than zero. Windows end at batch boundaries. Unprofitable samples initially pause for 10 times this many input rows; consecutive failures double the pause up to 128 times. A profitable sample resets the pause to 10 times this many rows. [...]
| datafusion.execution.coalesce_batches | true | When set to true, record batches will be examined between each operator and small batches will be coalesced into larger batches. This is helpful when there are highly selective filters or joins that could produce tiny output batches. The target batch size is determined by the configuration setting [...]
| datafusion.execution.collect_statistics | true | Should DataFusion collect statistics when first creating a table. Has no effect after the table is created. Defaults to true. [...]
| datafusion.execution.target_partitions | 0 | Number of partitions for query execution. Increasing partitions can increase concurrency. Defaults to the number of CPU cores on the system [...]
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org