You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "logan-keede (via GitHub)" <gi...@apache.org> on 2025/02/11 20:34:16 UTC
[PR] refactor: Move various parts of datasource out of core [datafusion]
logan-keede opened a new pull request, #14616:
URL: https://github.com/apache/datafusion/pull/14616
## 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.
-->
## 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.
-->
## Are these changes tested?
<!--
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
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## 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.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653103730
`FileCompressionType`, `PartitionedFile`, `FileRange` can be move to `datasource`.
If A and B is tightly couple, you need to pull partial structure out to C and import C for A and B. Not moving A and B together.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "logan-keede (via GitHub)" <gi...@apache.org>.
logan-keede commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2652876201
> Why not move to the `datasource` crate but `catalog-listing`
original plan was to move just `datasource::listing` to `catalog-listing`, but `listing/table.rs` has some dependencies on 'these' files (almost all file with pattern "physical_plan/file_\*.rs" or "file_format/file_*.rs") but 'these' files also have some dependency on `catalog-listing` (like `PartitionedFile` and more). So, this was all I could think of to avoid circular dependency and keeping original structure somewhat intact. do you still think we can make a `datasource` crate distinct from `catalog-listing`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "logan-keede (via GitHub)" <gi...@apache.org>.
logan-keede commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653644761

mostly for my clarity
also, I am not suggesting that we keep the file_format and physical_plan folders in new solution,
though I was going to suggest(only one folder for all `file` related) if we move forward by old approach
PS: @jayzhan211 can/should I tag you in related PRs?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#discussion_r1952536136
##########
datafusion/core/src/datasource/physical_plan/file_stream.rs:
##########
@@ -31,49 +31,17 @@ use crate::datasource::listing::PartitionedFile;
use crate::datasource::physical_plan::file_scan_config::PartitionColumnProjector;
use crate::datasource::physical_plan::{FileMeta, FileScanConfig};
use crate::error::Result;
-use crate::physical_plan::metrics::{
- BaselineMetrics, Count, ExecutionPlanMetricsSet, MetricBuilder, Time,
-};
+use crate::physical_plan::metrics::{BaselineMetrics, ExecutionPlanMetricsSet};
use crate::physical_plan::RecordBatchStream;
use arrow::datatypes::SchemaRef;
use arrow::error::ArrowError;
use arrow::record_batch::RecordBatch;
-use datafusion_common::instant::Instant;
+pub use datafusion_catalog_listing::file_stream_part::*;
Review Comment:
It's better to avoid importing everything at once so that the imported modules are explicitly controlled and managed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653497557
`Catalog -> Schema -> Table -> FileFormat -> QueryPlanner` is the dependency based on my previous research.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "logan-keede (via GitHub)" <gi...@apache.org>.
logan-keede commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2652024062
cc @alamb
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653424551
FWIW I think we can merge this PR and then keep moving code around as follow on PRs)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653893209
> also, I am not suggesting that we keep the file_format and physical_plan folders in new solution,
> though I was going to suggest(only one folder for all file related) if we move forward by old approach
That is my understanding as well
<img width="449" alt="Screenshot 2025-02-12 at 9 35 28 AM" src="https://github.com/user-attachments/assets/2c1672c2-b41a-4878-8ce8-d4689e3d240e" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#discussion_r1952536901
##########
datafusion/catalog-listing/src/file_stream_part.rs:
##########
@@ -0,0 +1,214 @@
+// 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.
+
+//! A generic stream over file format readers that can be used by
+//! any file format that read its files from start to end.
+//!
+//! Note: Most traits here need to be marked `Sync + Send` to be
+//! compliant with the `SendableRecordBatchStream` trait.
+
+use crate::file_meta::FileMeta;
+use datafusion_common::error::Result;
+use datafusion_physical_plan::metrics::{
+ Count, ExecutionPlanMetricsSet, MetricBuilder, Time,
+};
+
+use arrow::error::ArrowError;
+use arrow::record_batch::RecordBatch;
+use datafusion_common::instant::Instant;
+use datafusion_common::ScalarValue;
+
+use futures::future::BoxFuture;
+use futures::stream::BoxStream;
+
+/// A fallible future that resolves to a stream of [`RecordBatch`]
+pub type FileOpenFuture =
+ BoxFuture<'static, Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>>;
+
+/// Describes the behavior of the `FileStream` if file opening or scanning fails
+pub enum OnError {
+ /// Fail the entire stream and return the underlying error
+ Fail,
+ /// Continue scanning, ignoring the failed file
+ Skip,
+}
+
+impl Default for OnError {
+ fn default() -> Self {
+ Self::Fail
+ }
+}
+
+/// Generic API for opening a file using an [`ObjectStore`] and resolving to a
+/// stream of [`RecordBatch`]
+///
+/// [`ObjectStore`]: object_store::ObjectStore
+pub trait FileOpener: Unpin + Send + Sync {
+ /// Asynchronously open the specified file and return a stream
+ /// of [`RecordBatch`]
+ fn open(&self, file_meta: FileMeta) -> Result<FileOpenFuture>;
+}
+
+/// Represents the state of the next `FileOpenFuture`. Since we need to poll
+/// this future while scanning the current file, we need to store the result if it
+/// is ready
+pub enum NextOpen {
+ Pending(FileOpenFuture),
+ Ready(Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>),
+}
+
+pub enum FileStreamState {
+ /// The idle state, no file is currently being read
+ Idle,
+ /// Currently performing asynchronous IO to obtain a stream of RecordBatch
+ /// for a given file
+ Open {
+ /// A [`FileOpenFuture`] returned by [`FileOpener::open`]
+ future: FileOpenFuture,
+ /// The partition values for this file
+ partition_values: Vec<ScalarValue>,
+ },
+ /// Scanning the [`BoxStream`] returned by the completion of a [`FileOpenFuture`]
+ /// returned by [`FileOpener::open`]
+ Scan {
+ /// Partitioning column values for the current batch_iter
+ partition_values: Vec<ScalarValue>,
+ /// The reader instance
+ reader: BoxStream<'static, Result<RecordBatch, ArrowError>>,
+ /// A [`FileOpenFuture`] for the next file to be processed,
+ /// and its corresponding partition column values, if any.
+ /// This allows the next file to be opened in parallel while the
+ /// current file is read.
+ next: Option<(NextOpen, Vec<ScalarValue>)>,
+ },
+ /// Encountered an error
+ Error,
+ /// Reached the row limit
+ Limit,
+}
+
+/// A timer that can be started and stopped.
+pub struct StartableTime {
+ pub metrics: Time,
+ // use for record each part cost time, will eventually add into 'metrics'.
+ pub start: Option<Instant>,
+}
+
+impl StartableTime {
+ pub fn start(&mut self) {
+ assert!(self.start.is_none());
+ self.start = Some(Instant::now());
+ }
+
+ pub fn stop(&mut self) {
+ if let Some(start) = self.start.take() {
+ self.metrics.add_elapsed(start);
+ }
+ }
+}
+
+#[allow(rustdoc::broken_intra_doc_links)]
+/// Metrics for [`FileStream`]
+///
+/// Note that all of these metrics are in terms of wall clock time
+/// (not cpu time) so they include time spent waiting on I/O as well
+/// as other operators.
+///
+/// [`FileStream`]: <https://github.com/apache/datafusion/blob/main/datafusion/core/src/datasource/physical_plan/file_stream.rs>
+pub struct FileStreamMetrics {
Review Comment:
I prefer `file_stream`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#discussion_r1951824134
##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -28,8 +28,8 @@ use crate::datasource::data_source::FileSource;
use crate::datasource::file_format::file_compression_type::FileCompressionType;
use crate::datasource::file_format::{deserialize_stream, DecoderDeserializer};
use crate::datasource::listing::{FileRange, ListingTableUrl, PartitionedFile};
-use crate::datasource::physical_plan::file_stream::{FileOpenFuture, FileOpener};
use crate::datasource::physical_plan::FileMeta;
+use crate::datasource::physical_plan::{FileOpenFuture, FileOpener};
Review Comment:
do you think it is ok to re-export `FileOpenFuture` and `FileOpener` in `physical_plan` ? Or should they still be in a `file_stream` submodule?
##########
datafusion/catalog-listing/src/file_stream_part.rs:
##########
@@ -0,0 +1,214 @@
+// 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.
+
+//! A generic stream over file format readers that can be used by
+//! any file format that read its files from start to end.
+//!
+//! Note: Most traits here need to be marked `Sync + Send` to be
+//! compliant with the `SendableRecordBatchStream` trait.
+
+use crate::file_meta::FileMeta;
+use datafusion_common::error::Result;
+use datafusion_physical_plan::metrics::{
+ Count, ExecutionPlanMetricsSet, MetricBuilder, Time,
+};
+
+use arrow::error::ArrowError;
+use arrow::record_batch::RecordBatch;
+use datafusion_common::instant::Instant;
+use datafusion_common::ScalarValue;
+
+use futures::future::BoxFuture;
+use futures::stream::BoxStream;
+
+/// A fallible future that resolves to a stream of [`RecordBatch`]
+pub type FileOpenFuture =
+ BoxFuture<'static, Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>>;
+
+/// Describes the behavior of the `FileStream` if file opening or scanning fails
+pub enum OnError {
+ /// Fail the entire stream and return the underlying error
+ Fail,
+ /// Continue scanning, ignoring the failed file
+ Skip,
+}
+
+impl Default for OnError {
+ fn default() -> Self {
+ Self::Fail
+ }
+}
+
+/// Generic API for opening a file using an [`ObjectStore`] and resolving to a
+/// stream of [`RecordBatch`]
+///
+/// [`ObjectStore`]: object_store::ObjectStore
+pub trait FileOpener: Unpin + Send + Sync {
+ /// Asynchronously open the specified file and return a stream
+ /// of [`RecordBatch`]
+ fn open(&self, file_meta: FileMeta) -> Result<FileOpenFuture>;
+}
+
+/// Represents the state of the next `FileOpenFuture`. Since we need to poll
+/// this future while scanning the current file, we need to store the result if it
+/// is ready
+pub enum NextOpen {
+ Pending(FileOpenFuture),
+ Ready(Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>),
+}
+
+pub enum FileStreamState {
+ /// The idle state, no file is currently being read
+ Idle,
+ /// Currently performing asynchronous IO to obtain a stream of RecordBatch
+ /// for a given file
+ Open {
+ /// A [`FileOpenFuture`] returned by [`FileOpener::open`]
+ future: FileOpenFuture,
+ /// The partition values for this file
+ partition_values: Vec<ScalarValue>,
+ },
+ /// Scanning the [`BoxStream`] returned by the completion of a [`FileOpenFuture`]
+ /// returned by [`FileOpener::open`]
+ Scan {
+ /// Partitioning column values for the current batch_iter
+ partition_values: Vec<ScalarValue>,
+ /// The reader instance
+ reader: BoxStream<'static, Result<RecordBatch, ArrowError>>,
+ /// A [`FileOpenFuture`] for the next file to be processed,
+ /// and its corresponding partition column values, if any.
+ /// This allows the next file to be opened in parallel while the
+ /// current file is read.
+ next: Option<(NextOpen, Vec<ScalarValue>)>,
+ },
+ /// Encountered an error
+ Error,
+ /// Reached the row limit
+ Limit,
+}
+
+/// A timer that can be started and stopped.
+pub struct StartableTime {
+ pub metrics: Time,
+ // use for record each part cost time, will eventually add into 'metrics'.
+ pub start: Option<Instant>,
+}
+
+impl StartableTime {
+ pub fn start(&mut self) {
+ assert!(self.start.is_none());
+ self.start = Some(Instant::now());
+ }
+
+ pub fn stop(&mut self) {
+ if let Some(start) = self.start.take() {
+ self.metrics.add_elapsed(start);
+ }
+ }
+}
+
+#[allow(rustdoc::broken_intra_doc_links)]
+/// Metrics for [`FileStream`]
+///
+/// Note that all of these metrics are in terms of wall clock time
+/// (not cpu time) so they include time spent waiting on I/O as well
+/// as other operators.
+///
+/// [`FileStream`]: <https://github.com/apache/datafusion/blob/main/datafusion/core/src/datasource/physical_plan/file_stream.rs>
+pub struct FileStreamMetrics {
Review Comment:
I was thinking about if there was some better name for this module than `file_stream_part.rs` but I couldn't come up with one
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "logan-keede (via GitHub)" <gi...@apache.org>.
logan-keede commented on code in PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#discussion_r1952105834
##########
datafusion/catalog-listing/src/file_stream_part.rs:
##########
@@ -0,0 +1,214 @@
+// 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.
+
+//! A generic stream over file format readers that can be used by
+//! any file format that read its files from start to end.
+//!
+//! Note: Most traits here need to be marked `Sync + Send` to be
+//! compliant with the `SendableRecordBatchStream` trait.
+
+use crate::file_meta::FileMeta;
+use datafusion_common::error::Result;
+use datafusion_physical_plan::metrics::{
+ Count, ExecutionPlanMetricsSet, MetricBuilder, Time,
+};
+
+use arrow::error::ArrowError;
+use arrow::record_batch::RecordBatch;
+use datafusion_common::instant::Instant;
+use datafusion_common::ScalarValue;
+
+use futures::future::BoxFuture;
+use futures::stream::BoxStream;
+
+/// A fallible future that resolves to a stream of [`RecordBatch`]
+pub type FileOpenFuture =
+ BoxFuture<'static, Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>>;
+
+/// Describes the behavior of the `FileStream` if file opening or scanning fails
+pub enum OnError {
+ /// Fail the entire stream and return the underlying error
+ Fail,
+ /// Continue scanning, ignoring the failed file
+ Skip,
+}
+
+impl Default for OnError {
+ fn default() -> Self {
+ Self::Fail
+ }
+}
+
+/// Generic API for opening a file using an [`ObjectStore`] and resolving to a
+/// stream of [`RecordBatch`]
+///
+/// [`ObjectStore`]: object_store::ObjectStore
+pub trait FileOpener: Unpin + Send + Sync {
+ /// Asynchronously open the specified file and return a stream
+ /// of [`RecordBatch`]
+ fn open(&self, file_meta: FileMeta) -> Result<FileOpenFuture>;
+}
+
+/// Represents the state of the next `FileOpenFuture`. Since we need to poll
+/// this future while scanning the current file, we need to store the result if it
+/// is ready
+pub enum NextOpen {
+ Pending(FileOpenFuture),
+ Ready(Result<BoxStream<'static, Result<RecordBatch, ArrowError>>>),
+}
+
+pub enum FileStreamState {
+ /// The idle state, no file is currently being read
+ Idle,
+ /// Currently performing asynchronous IO to obtain a stream of RecordBatch
+ /// for a given file
+ Open {
+ /// A [`FileOpenFuture`] returned by [`FileOpener::open`]
+ future: FileOpenFuture,
+ /// The partition values for this file
+ partition_values: Vec<ScalarValue>,
+ },
+ /// Scanning the [`BoxStream`] returned by the completion of a [`FileOpenFuture`]
+ /// returned by [`FileOpener::open`]
+ Scan {
+ /// Partitioning column values for the current batch_iter
+ partition_values: Vec<ScalarValue>,
+ /// The reader instance
+ reader: BoxStream<'static, Result<RecordBatch, ArrowError>>,
+ /// A [`FileOpenFuture`] for the next file to be processed,
+ /// and its corresponding partition column values, if any.
+ /// This allows the next file to be opened in parallel while the
+ /// current file is read.
+ next: Option<(NextOpen, Vec<ScalarValue>)>,
+ },
+ /// Encountered an error
+ Error,
+ /// Reached the row limit
+ Limit,
+}
+
+/// A timer that can be started and stopped.
+pub struct StartableTime {
+ pub metrics: Time,
+ // use for record each part cost time, will eventually add into 'metrics'.
+ pub start: Option<Instant>,
+}
+
+impl StartableTime {
+ pub fn start(&mut self) {
+ assert!(self.start.is_none());
+ self.start = Some(Instant::now());
+ }
+
+ pub fn stop(&mut self) {
+ if let Some(start) = self.start.take() {
+ self.metrics.add_elapsed(start);
+ }
+ }
+}
+
+#[allow(rustdoc::broken_intra_doc_links)]
+/// Metrics for [`FileStream`]
+///
+/// Note that all of these metrics are in terms of wall clock time
+/// (not cpu time) so they include time spent waiting on I/O as well
+/// as other operators.
+///
+/// [`FileStream`]: <https://github.com/apache/datafusion/blob/main/datafusion/core/src/datasource/physical_plan/file_stream.rs>
+pub struct FileStreamMetrics {
Review Comment:
Eventually, when all of `file_stream` is moved, we can change the name. or perhaps we should just keep it `file_stream` as I did not make a `file_scan_config_part` but `file_scan_config` (it was an arbitrary decision).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653488012
Yes and not only the 3 I mentioned, FileFormat, FileFormatFactory, etc. I think `File` related structure should belong into it own crate and then the implementation like parquet, arrow or listing table import it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2652751401
Why not move to the `datasource` crate but `catalog-listing`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "logan-keede (via GitHub)" <gi...@apache.org>.
logan-keede commented on code in PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#discussion_r1952101752
##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -28,8 +28,8 @@ use crate::datasource::data_source::FileSource;
use crate::datasource::file_format::file_compression_type::FileCompressionType;
use crate::datasource::file_format::{deserialize_stream, DecoderDeserializer};
use crate::datasource::listing::{FileRange, ListingTableUrl, PartitionedFile};
-use crate::datasource::physical_plan::file_stream::{FileOpenFuture, FileOpener};
use crate::datasource::physical_plan::FileMeta;
+use crate::datasource::physical_plan::{FileOpenFuture, FileOpener};
Review Comment:
They are already in physical_plan. They could be imported from both `file_stream` and `physical_plan` earlier.
https://github.com/apache/datafusion/blob/abb7669098a546c9368f60f752dfa71cdcb99a6d/datafusion/core/src/datasource/physical_plan/mod.rs#L58
or did I misunderstand something?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #14616:
URL: https://github.com/apache/datafusion/pull/14616
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653971828
Ok, I am going to merge this one in and we can keep working on this in follow on PRs.
@logan-keede can you update the plan on https://github.com/apache/datafusion/issues/14444 and keep on hacking ?
Thanks again!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] refactor: Move various parts of datasource out of core [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #14616:
URL: https://github.com/apache/datafusion/pull/14616#issuecomment-2653423772
> `FileCompressionType`, `PartitionedFile`, `FileRange` can be move to `datasource`.
>
> If A and B is tightly couple, you need to pull partial structure out to C and import C for A and B. Not moving A and B together.
The possible plan I proposed on https://github.com/apache/datafusion/issues/14444 proposes a structure like this
- `datafusion-catalog-listing`: `ListingTable` and associated types like `PartitionedFile`
- `datafusion-datasource-parquet`: `ParquetExec` and file firmat
- `datafusion-datasource-avro` `AvroExec` and file formats
- `datafusion-datasource-arrow`
- `datafusion-datasource-json`
- `datafusion-datasource-csv`
This was before the refactor with `DataSource` landed:
- https://github.com/apache/datafusion/pull/14224
@jayzhan211 are you proposing we add another crate in there, something like?
- `datafusion-catalog-listing`: `ListingTable` and associated types like `PartitionedFile`
- `datafusion-datasource`: **NEW** that holds `FileCompressionType`, `PartitonedFile`,and `DataSource`
- `datafusion-datasource-parquet`: `ParquetExec` and file firmat
- `datafusion-datasource-avro` `AvroExec` and file formats
- `datafusion-datasource-arrow`
- `datafusion-datasource-json`
- `datafusion-datasource-csv`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org