Skip to content

Commit 2ad8468

Browse files
authored
Merge branch 'main' into sb/datafusion-math-floor
2 parents 0c0cef3 + d1a3058 commit 2ad8468

91 files changed

Lines changed: 2285 additions & 233 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/codeql.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
name: "CodeQL"
20+
21+
on:
22+
push:
23+
branches: [ "main" ]
24+
pull_request:
25+
branches: [ "main" ]
26+
schedule:
27+
- cron: '16 4 * * 1'
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
analyze:
34+
name: Analyze Actions
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: read
38+
security-events: write
39+
packages: read
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
44+
with:
45+
persist-credentials: false
46+
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@c793b717bc78562f491db7b0e93a3a178b099162 # v4
49+
with:
50+
languages: actions
51+
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@c793b717bc78562f491db7b0e93a3a178b099162 # v4
54+
with:
55+
category: "/language:actions"

.github/workflows/extended.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
# Check crate compiles and base cargo check passes
6767
linux-build-lib:
6868
name: linux build test
69-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=8,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
69+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=8,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
7070
# note: do not use amd/rust container to preserve disk space
7171
steps:
7272
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # v2.0.3
@@ -93,7 +93,7 @@ jobs:
9393
linux-test-extended:
9494
name: cargo test 'extended_tests' (amd64)
9595
needs: [linux-build-lib]
96-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=32,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion,spot=false', github.run_id) || 'ubuntu-latest' }}
96+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=32,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion,spot=false', github.run_id) || 'ubuntu-latest' }}
9797
# spot=false because the tests are long, https://runs-on.com/configuration/spot-instances/#disable-spot-pricing
9898
# note: do not use amd/rust container to preserve disk space
9999
steps:
@@ -140,7 +140,7 @@ jobs:
140140
# Check answers are correct when hash values collide
141141
hash-collisions:
142142
name: cargo test hash collisions (amd64)
143-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
143+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
144144
container:
145145
image: amd64/rust
146146
steps:
@@ -162,7 +162,7 @@ jobs:
162162
163163
sqllogictest-sqlite:
164164
name: "Run sqllogictests with the sqlite test suite"
165-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=48,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion,spot=false', github.run_id) || 'ubuntu-latest' }}
165+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=48,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion,spot=false', github.run_id) || 'ubuntu-latest' }}
166166
# spot=false because the tests are long, https://runs-on.com/configuration/spot-instances/#disable-spot-pricing
167167
container:
168168
image: amd64/rust

.github/workflows/rust.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
# Check crate compiles and base cargo check passes
4848
linux-build-lib:
4949
name: linux build test
50-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=8,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
50+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=8,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
5151
container:
5252
image: amd64/rust
5353
steps:
@@ -101,7 +101,7 @@ jobs:
101101
linux-datafusion-substrait-features:
102102
name: cargo check datafusion-substrait features
103103
needs: linux-build-lib
104-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
104+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
105105
container:
106106
image: amd64/rust
107107
steps:
@@ -138,7 +138,7 @@ jobs:
138138
linux-datafusion-proto-features:
139139
name: cargo check datafusion-proto features
140140
needs: linux-build-lib
141-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
141+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
142142
container:
143143
image: amd64/rust
144144
steps:
@@ -170,7 +170,7 @@ jobs:
170170
linux-cargo-check-datafusion:
171171
name: cargo check datafusion features
172172
needs: linux-build-lib
173-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
173+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
174174
container:
175175
image: amd64/rust
176176
steps:
@@ -271,7 +271,7 @@ jobs:
271271
linux-test:
272272
name: cargo test (amd64)
273273
needs: linux-build-lib
274-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
274+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
275275
container:
276276
image: amd64/rust
277277
volumes:
@@ -322,7 +322,7 @@ jobs:
322322
linux-test-datafusion-cli:
323323
name: cargo test datafusion-cli (amd64)
324324
needs: linux-build-lib
325-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
325+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
326326
steps:
327327
- uses: runs-on/action@cd2b598b0515d39d78c38a02d529db87d2196d1e # v2.0.3
328328
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -352,7 +352,7 @@ jobs:
352352
linux-test-example:
353353
name: cargo examples (amd64)
354354
needs: linux-build-lib
355-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
355+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
356356
container:
357357
image: amd64/rust
358358
steps:
@@ -383,7 +383,7 @@ jobs:
383383
linux-test-doc:
384384
name: cargo test doc (amd64)
385385
needs: linux-build-lib
386-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
386+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
387387
container:
388388
image: amd64/rust
389389
steps:
@@ -405,7 +405,7 @@ jobs:
405405
linux-rustdoc:
406406
name: cargo doc
407407
needs: linux-build-lib
408-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
408+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
409409
container:
410410
image: amd64/rust
411411
steps:
@@ -446,7 +446,7 @@ jobs:
446446
verify-benchmark-results:
447447
name: verify benchmark results (amd64)
448448
needs: linux-build-lib
449-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
449+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
450450
container:
451451
image: amd64/rust
452452
steps:
@@ -480,7 +480,7 @@ jobs:
480480
sqllogictest-postgres:
481481
name: "Run sqllogictest with Postgres runner"
482482
needs: linux-build-lib
483-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
483+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
484484
container:
485485
image: amd64/rust
486486
services:
@@ -519,7 +519,7 @@ jobs:
519519
sqllogictest-substrait:
520520
name: "Run sqllogictest in Substrait round-trip mode"
521521
needs: linux-build-lib
522-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
522+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
523523
container:
524524
image: amd64/rust
525525
steps:
@@ -650,7 +650,7 @@ jobs:
650650
clippy:
651651
name: clippy
652652
needs: linux-build-lib
653-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
653+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
654654
container:
655655
image: amd64/rust
656656
steps:
@@ -697,7 +697,7 @@ jobs:
697697
config-docs-check:
698698
name: check configs.md and ***_functions.md is up-to-date
699699
needs: linux-build-lib
700-
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
700+
runs-on: ${{ github.repository_owner == 'apache' && format('runs-on={0},family=m8a+m7a+c8a,cpu=16,image=ubuntu24-full-x64,extras=s3-cache,disk=large,tag=datafusion', github.run_id) || 'ubuntu-latest' }}
701701
container:
702702
image: amd64/rust
703703
steps:

datafusion-cli/src/exec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ pub async fn exec_from_repl(
196196
}
197197
Err(ReadlineError::Interrupted) => {
198198
println!("^C");
199+
rl.helper().unwrap().reset_hint();
199200
continue;
200201
}
201202
Err(ReadlineError::Eof) => {

datafusion-cli/src/helper.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! and auto-completion for file name during creating external table.
2020
2121
use std::borrow::Cow;
22+
use std::cell::Cell;
2223

2324
use crate::highlighter::{Color, NoSyntaxHighlighter, SyntaxHighlighter};
2425

@@ -40,6 +41,10 @@ pub struct CliHelper {
4041
completer: FilenameCompleter,
4142
dialect: Dialect,
4243
highlighter: Box<dyn Highlighter>,
44+
/// Tracks whether to show the default hint. Set to `false` once the user
45+
/// types anything, so the hint doesn't reappear after deleting back to
46+
/// an empty line. Reset to `true` when the line is submitted.
47+
show_hint: Cell<bool>,
4348
}
4449

4550
impl CliHelper {
@@ -53,6 +58,7 @@ impl CliHelper {
5358
completer: FilenameCompleter::new(),
5459
dialect: *dialect,
5560
highlighter,
61+
show_hint: Cell::new(true),
5662
}
5763
}
5864

@@ -62,6 +68,11 @@ impl CliHelper {
6268
}
6369
}
6470

71+
/// Re-enable the default hint for the next prompt.
72+
pub fn reset_hint(&self) {
73+
self.show_hint.set(true);
74+
}
75+
6576
fn validate_input(&self, input: &str) -> Result<ValidationResult> {
6677
if let Some(sql) = input.strip_suffix(';') {
6778
let dialect = match dialect_from_str(self.dialect) {
@@ -119,12 +130,11 @@ impl Hinter for CliHelper {
119130
type Hint = String;
120131

121132
fn hint(&self, line: &str, _pos: usize, _ctx: &Context<'_>) -> Option<String> {
122-
if line.trim().is_empty() {
123-
let suggestion = Color::gray(DEFAULT_HINT_SUGGESTION);
124-
Some(suggestion)
125-
} else {
126-
None
133+
if !line.is_empty() {
134+
self.show_hint.set(false);
127135
}
136+
(self.show_hint.get() && line.trim().is_empty())
137+
.then(|| Color::gray(DEFAULT_HINT_SUGGESTION))
128138
}
129139
}
130140

@@ -133,12 +143,9 @@ impl Hinter for CliHelper {
133143
fn is_open_quote_for_location(line: &str, pos: usize) -> bool {
134144
let mut sql = line[..pos].to_string();
135145
sql.push('\'');
136-
if let Ok(stmts) = DFParser::parse_sql(&sql)
137-
&& let Some(Statement::CreateExternalTable(_)) = stmts.back()
138-
{
139-
return true;
140-
}
141-
false
146+
DFParser::parse_sql(&sql).is_ok_and(|stmts| {
147+
matches!(stmts.back(), Some(Statement::CreateExternalTable(_)))
148+
})
142149
}
143150

144151
impl Completer for CliHelper {
@@ -161,7 +168,9 @@ impl Completer for CliHelper {
161168
impl Validator for CliHelper {
162169
fn validate(&self, ctx: &mut ValidationContext<'_>) -> Result<ValidationResult> {
163170
let input = ctx.input().trim_end();
164-
self.validate_input(input)
171+
let result = self.validate_input(input);
172+
self.reset_hint();
173+
result
165174
}
166175
}
167176

datafusion-examples/examples/custom_data_source/custom_datasource.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use async_trait::async_trait;
2727
use datafusion::arrow::array::{UInt8Builder, UInt64Builder};
2828
use datafusion::arrow::datatypes::{DataType, Field, Schema, SchemaRef};
2929
use datafusion::arrow::record_batch::RecordBatch;
30+
use datafusion::common::tree_node::TreeNodeRecursion;
3031
use datafusion::datasource::{TableProvider, TableType, provider_as_source};
3132
use datafusion::error::Result;
3233
use datafusion::execution::context::TaskContext;
@@ -283,4 +284,20 @@ impl ExecutionPlan for CustomExec {
283284
None,
284285
)?))
285286
}
287+
288+
fn apply_expressions(
289+
&self,
290+
f: &mut dyn FnMut(
291+
&dyn datafusion::physical_plan::PhysicalExpr,
292+
) -> Result<TreeNodeRecursion>,
293+
) -> Result<TreeNodeRecursion> {
294+
// Visit expressions in the output ordering from equivalence properties
295+
let mut tnr = TreeNodeRecursion::Continue;
296+
if let Some(ordering) = self.cache.output_ordering() {
297+
for sort_expr in ordering {
298+
tnr = tnr.visit_sibling(|| f(sort_expr.expr.as_ref()))?;
299+
}
300+
}
301+
Ok(tnr)
302+
}
286303
}

datafusion-examples/examples/execution_monitoring/memory_pool_execution_plan.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use arrow::record_batch::RecordBatch;
3030
use arrow_schema::SchemaRef;
3131
use datafusion::common::record_batch;
32+
use datafusion::common::tree_node::TreeNodeRecursion;
3233
use datafusion::common::{exec_datafusion_err, internal_err};
3334
use datafusion::datasource::{DefaultTableSource, memory::MemTable};
3435
use datafusion::error::Result;
@@ -296,4 +297,20 @@ impl ExecutionPlan for BufferingExecutionPlan {
296297
}),
297298
)))
298299
}
300+
301+
fn apply_expressions(
302+
&self,
303+
f: &mut dyn FnMut(
304+
&dyn datafusion::physical_plan::PhysicalExpr,
305+
) -> Result<TreeNodeRecursion>,
306+
) -> Result<TreeNodeRecursion> {
307+
// Visit expressions in the output ordering from equivalence properties
308+
let mut tnr = TreeNodeRecursion::Continue;
309+
if let Some(ordering) = self.properties.output_ordering() {
310+
for sort_expr in ordering {
311+
tnr = tnr.visit_sibling(|| f(sort_expr.expr.as_ref()))?;
312+
}
313+
}
314+
Ok(tnr)
315+
}
299316
}

0 commit comments

Comments
 (0)