Skip to content

Commit

Permalink
modify register table functions args (#12630)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLi-cn committed Sep 27, 2024
1 parent f39b467 commit 0abae43
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
10 changes: 5 additions & 5 deletions datafusion/core/src/execution/context/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// specific language governing permissions and limitations
// under the License.

use std::sync::Arc;

use super::super::options::{AvroReadOptions, ReadOptions};
use super::{DataFilePaths, DataFrame, Result, SessionContext};
use datafusion_common::TableReference;
use std::sync::Arc;

impl SessionContext {
/// Creates a [`DataFrame`] for reading an Avro data source.
Expand All @@ -39,15 +39,15 @@ impl SessionContext {
/// SQL statements executed against this context.
pub async fn register_avro(
&self,
name: &str,
table_path: &str,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: AvroReadOptions<'_>,
) -> Result<()> {
let listing_options = options
.to_listing_options(&self.copied_config(), self.copied_table_options());

self.register_listing_table(
name,
table_ref,
table_path,
listing_options,
options.schema.map(|s| Arc::new(s.to_owned())),
Expand Down
10 changes: 5 additions & 5 deletions datafusion/core/src/execution/context/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.

use std::sync::Arc;

use crate::datasource::physical_plan::plan_to_csv;
use datafusion_common::TableReference;
use std::sync::Arc;

use super::super::options::{CsvReadOptions, ReadOptions};
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
Expand Down Expand Up @@ -55,15 +55,15 @@ impl SessionContext {
/// statements executed against this context.
pub async fn register_csv(
&self,
name: &str,
table_path: &str,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: CsvReadOptions<'_>,
) -> Result<()> {
let listing_options = options
.to_listing_options(&self.copied_config(), self.copied_table_options());

self.register_listing_table(
name,
table_ref,
table_path,
listing_options,
options.schema.map(|s| Arc::new(s.to_owned())),
Expand Down
10 changes: 5 additions & 5 deletions datafusion/core/src/execution/context/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// specific language governing permissions and limitations
// under the License.

use std::sync::Arc;

use crate::datasource::physical_plan::plan_to_json;
use datafusion_common::TableReference;
use std::sync::Arc;

use super::super::options::{NdJsonReadOptions, ReadOptions};
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
Expand All @@ -41,15 +41,15 @@ impl SessionContext {
/// from SQL statements executed against this context.
pub async fn register_json(
&self,
name: &str,
table_path: &str,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: NdJsonReadOptions<'_>,
) -> Result<()> {
let listing_options = options
.to_listing_options(&self.copied_config(), self.copied_table_options());

self.register_listing_table(
name,
table_ref,
table_path,
listing_options,
options.schema.map(|s| Arc::new(s.to_owned())),
Expand Down
7 changes: 2 additions & 5 deletions datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ impl SessionContext {
/// [`ObjectStore`]: object_store::ObjectStore
pub async fn register_listing_table(
&self,
name: &str,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: ListingOptions,
provided_schema: Option<SchemaRef>,
Expand All @@ -1279,10 +1279,7 @@ impl SessionContext {
.with_listing_options(options)
.with_schema(resolved_schema);
let table = ListingTable::try_new(config)?.with_definition(sql_definition);
self.register_table(
TableReference::Bare { table: name.into() },
Arc::new(table),
)?;
self.register_table(table_ref, Arc::new(table))?;
Ok(())
}

Expand Down
7 changes: 4 additions & 3 deletions datafusion/core/src/execution/context/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use super::super::options::{ParquetReadOptions, ReadOptions};
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
use crate::datasource::physical_plan::parquet::plan_to_parquet;

use datafusion_common::TableReference;
use parquet::file::properties::WriterProperties;

impl SessionContext {
Expand All @@ -42,15 +43,15 @@ impl SessionContext {
/// statements executed against this context.
pub async fn register_parquet(
&self,
name: &str,
table_path: &str,
table_ref: impl Into<TableReference>,
table_path: impl AsRef<str>,
options: ParquetReadOptions<'_>,
) -> Result<()> {
let listing_options = options
.to_listing_options(&self.copied_config(), self.copied_table_options());

self.register_listing_table(
name,
table_ref,
table_path,
listing_options,
options.schema.map(|s| Arc::new(s.to_owned())),
Expand Down

0 comments on commit 0abae43

Please sign in to comment.