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

Update register_table functions args to take Into<TableReference> #12630

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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