Skip to content

Commit bfc0318

Browse files
authored
Merge branch 'main' into asolimando/partition-statistics-context
2 parents 40f8a33 + 96a6096 commit bfc0318

93 files changed

Lines changed: 9285 additions & 984 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
@@ -45,7 +45,7 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4747
- name: Install cargo-audit
48-
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
48+
uses: taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2.81.11
4949
with:
5050
tool: cargo-audit
5151
- name: Run audit check

.github/workflows/breaking_changes_detector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
9090
- name: Install cargo-semver-checks
9191
if: steps.changed_crates.outputs.packages != ''
92-
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
92+
uses: taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2.81.11
9393
with:
9494
tool: cargo-semver-checks
9595

.github/workflows/dependencies.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ jobs:
5050
with:
5151
rust-version: stable
5252
- name: Check dependencies
53+
working-directory: dev/depcheck
5354
run: |
54-
cd dev/depcheck
55-
cargo run
55+
cargo run --locked
5656
5757
detect-unused-dependencies:
5858
name: Detect Unused Dependencies

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
source ci/scripts/utils/tool_versions.sh
6565
echo "LYCHEE_VERSION=${LYCHEE_VERSION}" >> "$GITHUB_ENV"
6666
- name: Install lychee
67-
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
67+
uses: taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2.81.11
6868
with:
6969
tool: lychee@${{ env.LYCHEE_VERSION }}
7070
- name: Run markdown link check

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ jobs:
429429
sudo apt-get update -qq
430430
sudo apt-get install -y -qq clang
431431
- name: Setup wasm-pack
432-
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
432+
uses: taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2.81.11
433433
with:
434434
tool: wasm-pack
435435
- name: Run tests with headless mode
@@ -773,7 +773,7 @@ jobs:
773773
- name: Setup Rust toolchain
774774
uses: ./.github/actions/setup-builder
775775
- name: Install cargo-msrv
776-
uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8
776+
uses: taiki-e/install-action@15449e3094499af05d8d964a1c884208e4b8b595 # v2.81.11
777777
with:
778778
tool: cargo-msrv
779779

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ workspace = true
7575
[dev-dependencies]
7676
ctor = { workspace = true }
7777
insta = { workspace = true }
78-
insta-cmd = "0.6.0"
78+
insta-cmd = "0.7.0"
7979
rstest = { workspace = true }
8080
testcontainers-modules = { workspace = true, features = ["minio"] }
8181
# Makes sure `test_display_pg_json` behaves in a consistent way regardless of

datafusion-cli/src/exec.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::print_format::PrintFormat;
2323
use crate::{
2424
command::{Command, OutputFormat},
2525
helper::CliHelper,
26-
object_storage::get_object_store,
26+
object_storage::{get_object_store, stdin::StdinUtils},
2727
print_options::{MaxRows, PrintOptions},
2828
};
2929
use datafusion::common::instant::Instant;
@@ -417,9 +417,14 @@ async fn create_plan(
417417
// Note that cmd is a mutable reference so that create_external_table function can remove all
418418
// datafusion-cli specific options before passing through to datafusion. Otherwise, datafusion
419419
// will raise Configuration errors.
420-
if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &plan {
420+
if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &mut plan {
421421
// To support custom formats, treat error as None
422422
let format = config_file_type_from_str(&cmd.file_type);
423+
424+
// Expose stdin (e.g. `cat data.csv | datafusion-cli`) as a `stdin://`
425+
// object store, registered like any other scheme in `get_object_store`.
426+
cmd.location = StdinUtils::rewrite_location(&cmd.location, format.as_ref());
427+
423428
register_object_store_and_config_extensions(
424429
ctx,
425430
&cmd.location,

datafusion-cli/src/main.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use datafusion_cli::functions::{
3737
use datafusion_cli::object_storage::instrumented::{
3838
InstrumentedObjectStoreMode, InstrumentedObjectStoreRegistry,
3939
};
40+
use datafusion_cli::object_storage::{StdinCarriesCommands, is_stdin_location};
4041
use datafusion_cli::{
4142
DATAFUSION_CLI_VERSION, exec,
4243
pool_type::PoolType,
@@ -158,6 +159,23 @@ struct Args {
158159
object_store_profiling: InstrumentedObjectStoreMode,
159160
}
160161

162+
impl Args {
163+
/// Without -c/-f the CLI enters the REPL, which reads its SQL from
164+
/// stdin — interactively or piped.
165+
fn repl_mode(&self) -> bool {
166+
self.command.is_empty() && self.file.is_empty()
167+
}
168+
169+
/// Whether the CLI consumes stdin for its own SQL input. This covers the
170+
/// REPL (no -c/-f, reading SQL interactively or piped) as well as an
171+
/// explicit `-f /dev/stdin` (or the other stdin pseudo-paths), where the
172+
/// SQL file *is* stdin. In either case stdin is already spoken for and
173+
/// cannot also back a `LOCATION '/dev/stdin'` table.
174+
fn reads_sql_from_stdin(&self) -> bool {
175+
self.repl_mode() || self.file.iter().any(|f| is_stdin_location(f))
176+
}
177+
}
178+
161179
#[tokio::main]
162180
/// Calls [`main_inner`], then handles printing errors and returning the correct exit code
163181
pub async fn main() -> ExitCode {
@@ -268,6 +286,7 @@ async fn main_inner() -> Result<()> {
268286
instrumented_registry: Arc::clone(&instrumented_registry),
269287
};
270288

289+
let repl_mode = args.repl_mode();
271290
let commands = args.command;
272291
let files = args.file;
273292
let rc = match args.rc {
@@ -285,7 +304,7 @@ async fn main_inner() -> Result<()> {
285304
}
286305
};
287306

288-
if commands.is_empty() && files.is_empty() {
307+
if repl_mode {
289308
if !rc.is_empty() {
290309
exec::exec_from_files(&ctx, rc, &print_options).await?;
291310
}
@@ -330,8 +349,16 @@ fn get_session_config(args: &Args) -> Result<SessionConfig> {
330349
config_options.format.null = String::from("NULL");
331350
}
332351

333-
let session_config =
352+
let mut session_config =
334353
SessionConfig::from(config_options).with_information_schema(true);
354+
355+
if args.reads_sql_from_stdin() {
356+
// When stdin carries the session's SQL — the REPL (including any rc
357+
// file run before it) or an explicit `-f /dev/stdin` — it cannot also
358+
// serve as a data source for `LOCATION '/dev/stdin'`.
359+
session_config = session_config.with_extension(Arc::new(StdinCarriesCommands));
360+
}
361+
335362
Ok(session_config)
336363
}
337364

datafusion-cli/src/object_storage.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
// under the License.
1717

1818
pub mod instrumented;
19+
pub(crate) mod stdin;
20+
21+
pub use stdin::{StdinCarriesCommands, is_stdin_location};
1922

2023
use async_trait::async_trait;
2124
use aws_config::BehaviorVersion;
@@ -564,6 +567,9 @@ pub(crate) async fn get_object_store(
564567
.with_url(url.origin().ascii_serialization())
565568
.build()?,
566569
),
570+
_ if scheme == stdin::StdinUtils::SCHEME => {
571+
stdin::StdinUtils::get_or_create(state, url).await?
572+
}
567573
_ => {
568574
// For other types, try to get from `object_store_registry`:
569575
state

0 commit comments

Comments
 (0)