shyjsarah commented on code in PR #749: URL: https://github.com/apache/paimon-rust/pull/749#discussion_r3877657824
########## crates/integrations/datafusion/src/table/object.rs: ########## @@ -0,0 +1,150 @@ +// 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. + +use std::sync::Arc; + +use async_trait::async_trait; +use datafusion::arrow::array::{ + new_null_array, ArrayRef, Int64Array, RecordBatch, StringViewArray, +}; +use datafusion::arrow::datatypes::SchemaRef; +use datafusion::catalog::Session; +use datafusion::datasource::memory::MemorySourceConfig; +use datafusion::datasource::{TableProvider, TableType}; +use datafusion::error::{DataFusionError, Result as DFResult}; +use datafusion::logical_expr::dml::InsertOp; +use datafusion::logical_expr::Expr; +use datafusion::physical_plan::ExecutionPlan; +use paimon::table::ObjectTable; + +use crate::error::to_datafusion_error; + +use super::datafusion_arrow_schema; + +/// DataFusion provider for a native read-only Paimon object table. +#[derive(Debug, Clone)] +pub(crate) struct ObjectTableProvider { + table: ObjectTable, + schema: SchemaRef, +} + +impl ObjectTableProvider { + pub(crate) fn try_new(table: ObjectTable, schema_force_view_types: bool) -> DFResult<Self> { + let schema = datafusion_arrow_schema(&ObjectTable::fields(), schema_force_view_types)?; + Ok(Self { table, schema }) + } +} + +#[async_trait] +impl TableProvider for ObjectTableProvider { + fn schema(&self) -> SchemaRef { + Arc::clone(&self.schema) + } + + fn table_type(&self) -> TableType { + TableType::Base + } + + async fn scan( + &self, + _state: &dyn Session, + projection: Option<&Vec<usize>>, + _filters: &[Expr], + limit: Option<usize>, + ) -> DFResult<Arc<dyn ExecutionPlan>> { + let entries = self Review Comment: Fixed in e50ea4f. Object Table scans now return a projection-aware `StreamingTableExec` instead of listing and materializing during planning. The partition stream lazily consumes OpenDAL, emits batches at the session batch size, builds only projected Arrow columns (including zero-column projections), and does not globally sort scan output. Pushed limits still stop the underlying lister after K files. Added regressions proving the first status is yielded before the next lister poll, projected scans produce bounded batches, and `COUNT(*)` works through an empty projection. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
