Skip to content

Commit fa4d968

Browse files
committed
Merge branch 'main' into crypto_benchmark
# Conflicts: # datafusion/functions/Cargo.toml
2 parents a8f3bdc + 10db6b3 commit fa4d968

100 files changed

Lines changed: 4676 additions & 730 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4444
- name: Install cargo-audit
45-
uses: taiki-e/install-action@50cee16bd6b97b2579572f83cfa1c0a721b1e336 # v2.65.2
45+
uses: taiki-e/install-action@de7896b7cd1c7d181266425abbe571b5a8c757bc # v2.65.3
4646
with:
4747
tool: cargo-audit
4848
- name: Run audit check

.github/workflows/rust.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ jobs:
421421
sudo apt-get update -qq
422422
sudo apt-get install -y -qq clang
423423
- name: Setup wasm-pack
424-
uses: taiki-e/install-action@50cee16bd6b97b2579572f83cfa1c0a721b1e336 # v2.65.2
424+
uses: taiki-e/install-action@de7896b7cd1c7d181266425abbe571b5a8c757bc # v2.65.3
425425
with:
426426
tool: wasm-pack
427427
- name: Run tests with headless mode
@@ -709,6 +709,23 @@ jobs:
709709
./dev/update_function_docs.sh
710710
git diff --exit-code
711711
712+
examples-docs-check:
713+
name: check example README is up-to-date
714+
needs: linux-build-lib
715+
runs-on: ubuntu-latest
716+
container:
717+
image: amd64/rust
718+
719+
steps:
720+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
721+
with:
722+
submodules: true
723+
fetch-depth: 1
724+
725+
- name: Run examples docs check script
726+
run: |
727+
bash ci/scripts/check_examples_docs.sh
728+
712729
# Verify MSRV for the crates which are directly used by other projects:
713730
# - datafusion
714731
# - datafusion-substrait
@@ -724,7 +741,7 @@ jobs:
724741
- name: Setup Rust toolchain
725742
uses: ./.github/actions/setup-builder
726743
- name: Install cargo-msrv
727-
uses: taiki-e/install-action@50cee16bd6b97b2579572f83cfa1c0a721b1e336 # v2.65.2
744+
uses: taiki-e/install-action@de7896b7cd1c7d181266425abbe571b5a8c757bc # v2.65.3
728745
with:
729746
tool: cargo-msrv
730747

ci/scripts/check_examples_docs.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
20+
set -euo pipefail
21+
22+
EXAMPLES_DIR="datafusion-examples/examples"
23+
README="datafusion-examples/README.md"
24+
25+
# ffi examples are skipped because they were not part of the recent example
26+
# consolidation work and do not follow the new grouping and execution pattern.
27+
# They are not documented in the README using the new structure, so including
28+
# them here would cause false CI failures.
29+
SKIP_LIST=("ffi")
30+
31+
missing=0
32+
33+
skip() {
34+
local value="$1"
35+
for item in "${SKIP_LIST[@]}"; do
36+
if [[ "$item" == "$value" ]]; then
37+
return 0
38+
fi
39+
done
40+
return 1
41+
}
42+
43+
# collect folder names
44+
folders=$(find "$EXAMPLES_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
45+
46+
# collect group names from README headers
47+
groups=$(grep "^### Group:" "$README" | sed -E 's/^### Group: `([^`]+)`.*/\1/')
48+
49+
for folder in $folders; do
50+
if skip "$folder"; then
51+
echo "Skipped group: $folder"
52+
continue
53+
fi
54+
55+
if ! echo "$groups" | grep -qx "$folder"; then
56+
echo "Missing README entry for example group: $folder"
57+
missing=1
58+
fi
59+
done
60+
61+
if [[ $missing -eq 1 ]]; then
62+
echo "README is out of sync with examples"
63+
exit 1
64+
fi

datafusion/catalog/src/cte_worktable.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@
1717

1818
//! CteWorkTable implementation used for recursive queries
1919
20+
use std::any::Any;
21+
use std::borrow::Cow;
2022
use std::sync::Arc;
21-
use std::{any::Any, borrow::Cow};
2223

23-
use crate::Session;
2424
use arrow::datatypes::SchemaRef;
2525
use async_trait::async_trait;
26-
use datafusion_physical_plan::work_table::WorkTableExec;
27-
28-
use datafusion_physical_plan::ExecutionPlan;
29-
3026
use datafusion_common::error::Result;
3127
use datafusion_expr::{Expr, LogicalPlan, TableProviderFilterPushDown, TableType};
28+
use datafusion_physical_plan::ExecutionPlan;
29+
use datafusion_physical_plan::work_table::WorkTableExec;
3230

33-
use crate::TableProvider;
31+
use crate::{ScanArgs, ScanResult, Session, TableProvider};
3432

3533
/// The temporary working table where the previous iteration of a recursive query is stored
3634
/// Naming is based on PostgreSQL's implementation.
@@ -85,16 +83,28 @@ impl TableProvider for CteWorkTable {
8583

8684
async fn scan(
8785
&self,
88-
_state: &dyn Session,
89-
_projection: Option<&Vec<usize>>,
90-
_filters: &[Expr],
91-
_limit: Option<usize>,
86+
state: &dyn Session,
87+
projection: Option<&Vec<usize>>,
88+
filters: &[Expr],
89+
limit: Option<usize>,
9290
) -> Result<Arc<dyn ExecutionPlan>> {
93-
// TODO: pushdown filters and limits
94-
Ok(Arc::new(WorkTableExec::new(
91+
let options = ScanArgs::default()
92+
.with_projection(projection.map(|p| p.as_slice()))
93+
.with_filters(Some(filters))
94+
.with_limit(limit);
95+
Ok(self.scan_with_args(state, options).await?.into_inner())
96+
}
97+
98+
async fn scan_with_args<'a>(
99+
&self,
100+
_state: &dyn Session,
101+
args: ScanArgs<'a>,
102+
) -> Result<ScanResult> {
103+
Ok(ScanResult::new(Arc::new(WorkTableExec::new(
95104
self.name.clone(),
96105
Arc::clone(&self.table_schema),
97-
)))
106+
args.projection().map(|p| p.to_vec()),
107+
)?)))
98108
}
99109

100110
fn supports_filters_pushdown(

datafusion/common/src/scalar/consts.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,36 @@
1717

1818
// Constants defined for scalar construction.
1919

20+
// Next F16 value above π (upper bound)
21+
pub(super) const PI_UPPER_F16: half::f16 = half::f16::from_bits(0x4249);
22+
2023
// Next f32 value above π (upper bound)
2124
pub(super) const PI_UPPER_F32: f32 = std::f32::consts::PI.next_up();
2225

2326
// Next f64 value above π (upper bound)
2427
pub(super) const PI_UPPER_F64: f64 = std::f64::consts::PI.next_up();
2528

29+
// Next f16 value below -π (lower bound)
30+
pub(super) const NEGATIVE_PI_LOWER_F16: half::f16 = half::f16::from_bits(0xC249);
31+
2632
// Next f32 value below -π (lower bound)
2733
pub(super) const NEGATIVE_PI_LOWER_F32: f32 = (-std::f32::consts::PI).next_down();
2834

2935
// Next f64 value below -π (lower bound)
3036
pub(super) const NEGATIVE_PI_LOWER_F64: f64 = (-std::f64::consts::PI).next_down();
3137

38+
// Next f16 value above π/2 (upper bound)
39+
pub(super) const FRAC_PI_2_UPPER_F16: half::f16 = half::f16::from_bits(0x3E49);
40+
3241
// Next f32 value above π/2 (upper bound)
3342
pub(super) const FRAC_PI_2_UPPER_F32: f32 = std::f32::consts::FRAC_PI_2.next_up();
3443

3544
// Next f64 value above π/2 (upper bound)
3645
pub(super) const FRAC_PI_2_UPPER_F64: f64 = std::f64::consts::FRAC_PI_2.next_up();
3746

47+
// Next f32 value below -π/2 (lower bound)
48+
pub(super) const NEGATIVE_FRAC_PI_2_LOWER_F16: half::f16 = half::f16::from_bits(0xBE49);
49+
3850
// Next f32 value below -π/2 (lower bound)
3951
pub(super) const NEGATIVE_FRAC_PI_2_LOWER_F32: f32 =
4052
(-std::f32::consts::FRAC_PI_2).next_down();

datafusion/common/src/scalar/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,7 @@ impl ScalarValue {
13421342
/// Returns a [`ScalarValue`] representing PI's upper bound
13431343
pub fn new_pi_upper(datatype: &DataType) -> Result<ScalarValue> {
13441344
match datatype {
1345-
// TODO: half::f16 doesn't seem to have equivalent
1346-
// https://github.com/apache/datafusion/issues/19465
1345+
DataType::Float16 => Ok(ScalarValue::Float16(Some(consts::PI_UPPER_F16))),
13471346
DataType::Float32 => Ok(ScalarValue::from(consts::PI_UPPER_F32)),
13481347
DataType::Float64 => Ok(ScalarValue::from(consts::PI_UPPER_F64)),
13491348
_ => {
@@ -1355,8 +1354,9 @@ impl ScalarValue {
13551354
/// Returns a [`ScalarValue`] representing -PI's lower bound
13561355
pub fn new_negative_pi_lower(datatype: &DataType) -> Result<ScalarValue> {
13571356
match datatype {
1358-
// TODO: half::f16 doesn't seem to have equivalent
1359-
// https://github.com/apache/datafusion/issues/19465
1357+
DataType::Float16 => {
1358+
Ok(ScalarValue::Float16(Some(consts::NEGATIVE_PI_LOWER_F16)))
1359+
}
13601360
DataType::Float32 => Ok(ScalarValue::from(consts::NEGATIVE_PI_LOWER_F32)),
13611361
DataType::Float64 => Ok(ScalarValue::from(consts::NEGATIVE_PI_LOWER_F64)),
13621362
_ => {
@@ -1368,8 +1368,9 @@ impl ScalarValue {
13681368
/// Returns a [`ScalarValue`] representing FRAC_PI_2's upper bound
13691369
pub fn new_frac_pi_2_upper(datatype: &DataType) -> Result<ScalarValue> {
13701370
match datatype {
1371-
// TODO: half::f16 doesn't seem to have equivalent
1372-
// https://github.com/apache/datafusion/issues/19465
1371+
DataType::Float16 => {
1372+
Ok(ScalarValue::Float16(Some(consts::FRAC_PI_2_UPPER_F16)))
1373+
}
13731374
DataType::Float32 => Ok(ScalarValue::from(consts::FRAC_PI_2_UPPER_F32)),
13741375
DataType::Float64 => Ok(ScalarValue::from(consts::FRAC_PI_2_UPPER_F64)),
13751376
_ => {
@@ -1381,8 +1382,9 @@ impl ScalarValue {
13811382
// Returns a [`ScalarValue`] representing FRAC_PI_2's lower bound
13821383
pub fn new_neg_frac_pi_2_lower(datatype: &DataType) -> Result<ScalarValue> {
13831384
match datatype {
1384-
// TODO: half::f16 doesn't seem to have equivalent
1385-
// https://github.com/apache/datafusion/issues/19465
1385+
DataType::Float16 => Ok(ScalarValue::Float16(Some(
1386+
consts::NEGATIVE_FRAC_PI_2_LOWER_F16,
1387+
))),
13861388
DataType::Float32 => {
13871389
Ok(ScalarValue::from(consts::NEGATIVE_FRAC_PI_2_LOWER_F32))
13881390
}

datafusion/core/tests/dataframe/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ async fn window_using_aggregates() -> Result<()> {
11121112
| -85 | -48 | 6 | -35 | -36 | 83 | -85 | 2 | -43 |
11131113
| -85 | -5 | 4 | -37 | -40 | -5 | -85 | 1 | 83 |
11141114
| -85 | -54 | 15 | -17 | -18 | 83 | -101 | 4 | -38 |
1115-
| -85 | -56 | 2 | -70 | 57 | -56 | -85 | 1 | -25 |
1115+
| -85 | -56 | 2 | -70 | -70 | -56 | -85 | 1 | -25 |
11161116
| -85 | -72 | 9 | -43 | -43 | 83 | -85 | 3 | -12 |
11171117
| -85 | -85 | 1 | -85 | -85 | -85 | -85 | 1 | -56 |
11181118
| -85 | 13 | 11 | -17 | -18 | 83 | -85 | 3 | 14 |

datafusion/core/tests/execution/coop.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ use std::time::Duration;
6464
use tokio::runtime::{Handle, Runtime};
6565
use tokio::select;
6666

67-
#[derive(Debug)]
67+
#[derive(Debug, Clone)]
6868
struct RangeBatchGenerator {
6969
schema: SchemaRef,
7070
value_range: Range<i64>,
7171
boundedness: Boundedness,
7272
batch_size: usize,
7373
poll_count: usize,
74+
original_range: Range<i64>,
7475
}
7576

7677
impl std::fmt::Display for RangeBatchGenerator {
@@ -110,6 +111,13 @@ impl LazyBatchGenerator for RangeBatchGenerator {
110111
RecordBatch::try_new(Arc::clone(&self.schema), vec![Arc::new(array)])?;
111112
Ok(Some(batch))
112113
}
114+
115+
fn reset_state(&self) -> Arc<RwLock<dyn LazyBatchGenerator>> {
116+
let mut new = self.clone();
117+
new.poll_count = 0;
118+
new.value_range = new.original_range.clone();
119+
Arc::new(RwLock::new(new))
120+
}
113121
}
114122

115123
fn make_lazy_exec(column_name: &str, pretend_infinite: bool) -> LazyMemoryExec {
@@ -139,9 +147,10 @@ fn make_lazy_exec_with_range(
139147
let batch_gen = RangeBatchGenerator {
140148
schema: Arc::clone(&schema),
141149
boundedness,
142-
value_range: range,
150+
value_range: range.clone(),
143151
batch_size: 8192,
144152
poll_count: 0,
153+
original_range: range,
145154
};
146155

147156
// Wrap the generator in a trait object behind Arc<RwLock<_>>

0 commit comments

Comments
 (0)