Skip to content

Commit 0abae43

Browse files
authored
modify register table functions args (#12630)
1 parent f39b467 commit 0abae43

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

datafusion/core/src/execution/context/avro.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use std::sync::Arc;
19-
2018
use super::super::options::{AvroReadOptions, ReadOptions};
2119
use super::{DataFilePaths, DataFrame, Result, SessionContext};
20+
use datafusion_common::TableReference;
21+
use std::sync::Arc;
2222

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

4949
self.register_listing_table(
50-
name,
50+
table_ref,
5151
table_path,
5252
listing_options,
5353
options.schema.map(|s| Arc::new(s.to_owned())),

datafusion/core/src/execution/context/csv.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use std::sync::Arc;
19-
2018
use crate::datasource::physical_plan::plan_to_csv;
19+
use datafusion_common::TableReference;
20+
use std::sync::Arc;
2121

2222
use super::super::options::{CsvReadOptions, ReadOptions};
2323
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
@@ -55,15 +55,15 @@ impl SessionContext {
5555
/// statements executed against this context.
5656
pub async fn register_csv(
5757
&self,
58-
name: &str,
59-
table_path: &str,
58+
table_ref: impl Into<TableReference>,
59+
table_path: impl AsRef<str>,
6060
options: CsvReadOptions<'_>,
6161
) -> Result<()> {
6262
let listing_options = options
6363
.to_listing_options(&self.copied_config(), self.copied_table_options());
6464

6565
self.register_listing_table(
66-
name,
66+
table_ref,
6767
table_path,
6868
listing_options,
6969
options.schema.map(|s| Arc::new(s.to_owned())),

datafusion/core/src/execution/context/json.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use std::sync::Arc;
19-
2018
use crate::datasource::physical_plan::plan_to_json;
19+
use datafusion_common::TableReference;
20+
use std::sync::Arc;
2121

2222
use super::super::options::{NdJsonReadOptions, ReadOptions};
2323
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
@@ -41,15 +41,15 @@ impl SessionContext {
4141
/// from SQL statements executed against this context.
4242
pub async fn register_json(
4343
&self,
44-
name: &str,
45-
table_path: &str,
44+
table_ref: impl Into<TableReference>,
45+
table_path: impl AsRef<str>,
4646
options: NdJsonReadOptions<'_>,
4747
) -> Result<()> {
4848
let listing_options = options
4949
.to_listing_options(&self.copied_config(), self.copied_table_options());
5050

5151
self.register_listing_table(
52-
name,
52+
table_ref,
5353
table_path,
5454
listing_options,
5555
options.schema.map(|s| Arc::new(s.to_owned())),

datafusion/core/src/execution/context/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ impl SessionContext {
12641264
/// [`ObjectStore`]: object_store::ObjectStore
12651265
pub async fn register_listing_table(
12661266
&self,
1267-
name: &str,
1267+
table_ref: impl Into<TableReference>,
12681268
table_path: impl AsRef<str>,
12691269
options: ListingOptions,
12701270
provided_schema: Option<SchemaRef>,
@@ -1279,10 +1279,7 @@ impl SessionContext {
12791279
.with_listing_options(options)
12801280
.with_schema(resolved_schema);
12811281
let table = ListingTable::try_new(config)?.with_definition(sql_definition);
1282-
self.register_table(
1283-
TableReference::Bare { table: name.into() },
1284-
Arc::new(table),
1285-
)?;
1282+
self.register_table(table_ref, Arc::new(table))?;
12861283
Ok(())
12871284
}
12881285

datafusion/core/src/execution/context/parquet.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use super::super::options::{ParquetReadOptions, ReadOptions};
2121
use super::{DataFilePaths, DataFrame, ExecutionPlan, Result, SessionContext};
2222
use crate::datasource::physical_plan::parquet::plan_to_parquet;
2323

24+
use datafusion_common::TableReference;
2425
use parquet::file::properties::WriterProperties;
2526

2627
impl SessionContext {
@@ -42,15 +43,15 @@ impl SessionContext {
4243
/// statements executed against this context.
4344
pub async fn register_parquet(
4445
&self,
45-
name: &str,
46-
table_path: &str,
46+
table_ref: impl Into<TableReference>,
47+
table_path: impl AsRef<str>,
4748
options: ParquetReadOptions<'_>,
4849
) -> Result<()> {
4950
let listing_options = options
5051
.to_listing_options(&self.copied_config(), self.copied_table_options());
5152

5253
self.register_listing_table(
53-
name,
54+
table_ref,
5455
table_path,
5556
listing_options,
5657
options.schema.map(|s| Arc::new(s.to_owned())),

0 commit comments

Comments
 (0)