Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove scan_avro methods from LogicalPlanBuilder #2540

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions datafusion/core/src/execution/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,18 +504,24 @@ impl SessionContext {
let uri: String = uri.into();
let (object_store, path) = self.runtime_env().object_store(&uri)?;
let target_partitions = self.copied_config().target_partitions;
Ok(Arc::new(DataFrame::new(
self.state.clone(),
&LogicalPlanBuilder::scan_avro(
object_store,
path,
options,
None,
target_partitions,
)
.await?
.build()?,
)))

let listing_options = options.to_listing_options(target_partitions);

let path: String = path.into();

let resolved_schema = match options.schema {
Some(s) => s,
None => {
listing_options
.infer_schema(Arc::clone(&object_store), &path)
.await?
}
};
let config = ListingTableConfig::new(object_store, path.clone())
.with_listing_options(listing_options)
.with_schema(resolved_schema);
let provider = ListingTable::try_new(config)?;
self.read_table(Arc::new(provider))
}

/// Creates a DataFrame for reading an Json data source.
Expand Down
49 changes: 0 additions & 49 deletions datafusion/core/src/logical_plan/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,55 +298,6 @@ impl LogicalPlanBuilder {
Self::scan(table_name, Arc::new(provider), projection)
}

/// Scan an Avro data source
pub async fn scan_avro(
object_store: Arc<dyn ObjectStore>,
path: impl Into<String>,
options: AvroReadOptions<'_>,
projection: Option<Vec<usize>>,
target_partitions: usize,
) -> Result<Self> {
let path = path.into();
Self::scan_avro_with_name(
object_store,
path.clone(),
options,
projection,
path,
target_partitions,
)
.await
}

/// Scan an Avro data source and register it with a given table name
pub async fn scan_avro_with_name(
object_store: Arc<dyn ObjectStore>,
path: impl Into<String>,
options: AvroReadOptions<'_>,
projection: Option<Vec<usize>>,
table_name: impl Into<String>,
target_partitions: usize,
) -> Result<Self> {
let listing_options = options.to_listing_options(target_partitions);

let path: String = path.into();

let resolved_schema = match options.schema {
Some(s) => s,
None => {
listing_options
.infer_schema(Arc::clone(&object_store), &path)
.await?
}
};
let config = ListingTableConfig::new(object_store, path)
.with_listing_options(listing_options)
.with_schema(resolved_schema);
let provider = ListingTable::try_new(config)?;

Self::scan(table_name, Arc::new(provider), projection)
}

/// Scan an Json data source
pub async fn scan_json(
object_store: Arc<dyn ObjectStore>,
Expand Down