Skip to content

Apache DataFusion SQL Query Engine

Remove scan_json methods from LogicalPlanBuilder (#2541)

Andy Groveffb9fa63ed24
diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs
index c18c49eb86..202928a0cb 100644
--- a/datafusion/core/src/execution/context.rs
+++ b/datafusion/core/src/execution/context.rs
@@ -527,18 +527,25 @@ 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_json(
- 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)
+ .with_listing_options(listing_options)
+ .with_schema(resolved_schema);
+ let provider = ListingTable::try_new(config)?;
+
+ self.read_table(Arc::new(provider))
}
/// Creates an empty DataFrame.
diff --git a/datafusion/core/src/logical_plan/builder.rs b/datafusion/core/src/logical_plan/builder.rs
index c35b522e6e..f01ef9489f 100644
--- a/datafusion/core/src/logical_plan/builder.rs
+++ b/datafusion/core/src/logical_plan/builder.rs
@@ -305,55 +305,6 @@ impl LogicalPlanBuilder {
Self::scan(table_name, Arc::new(provider), projection)
}
- /// Scan an Json data source
- pub async fn scan_json(
- object_store: Arc<dyn ObjectStore>,
- path: impl Into<String>,
- options: NdJsonReadOptions<'_>,
- projection: Option<Vec<usize>>,
- target_partitions: usize,
- ) -> Result<Self> {
- let path = path.into();
- Self::scan_json_with_name(
- object_store,
- path.clone(),
- options,
- projection,
- path,
- target_partitions,
- )
- .await
- }
-
- /// Scan an Json data source and register it with a given table name
- pub async fn scan_json_with_name(
- object_store: Arc<dyn ObjectStore>,
- path: impl Into<String>,
- options: NdJsonReadOptions<'_>,
- 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 empty data source, mainly used in tests
pub fn scan_empty(
name: Option<&str>,