This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 0abae43135 modify register table functions args (#12630)
0abae43135 is described below
commit 0abae431359aa2146b55db56a68fa784f622772e
Author: JasonLi <[email protected]>
AuthorDate: Sat Sep 28 07:17:15 2024 +0800
modify register table functions args (#12630)
---
datafusion/core/src/execution/context/avro.rs | 10 +++++-----
datafusion/core/src/execution/context/csv.rs | 10 +++++-----
datafusion/core/src/execution/context/json.rs | 10 +++++-----
datafusion/core/src/execution/context/mod.rs | 7 ++-----
datafusion/core/src/execution/context/parquet.rs | 7 ++++---
5 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/datafusion/core/src/execution/context/avro.rs
b/datafusion/core/src/execution/context/avro.rs
index e829f6123e..a31f2af642 100644
--- a/datafusion/core/src/execution/context/avro.rs
+++ b/datafusion/core/src/execution/context/avro.rs
@@ -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.
@@ -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())),
diff --git a/datafusion/core/src/execution/context/csv.rs
b/datafusion/core/src/execution/context/csv.rs
index 08e93cb613..e97c70ef98 100644
--- a/datafusion/core/src/execution/context/csv.rs
+++ b/datafusion/core/src/execution/context/csv.rs
@@ -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};
@@ -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())),
diff --git a/datafusion/core/src/execution/context/json.rs
b/datafusion/core/src/execution/context/json.rs
index c21e32cfde..c9a9492f91 100644
--- a/datafusion/core/src/execution/context/json.rs
+++ b/datafusion/core/src/execution/context/json.rs
@@ -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};
@@ -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())),
diff --git a/datafusion/core/src/execution/context/mod.rs
b/datafusion/core/src/execution/context/mod.rs
index 53eb7c431b..12ce71768f 100644
--- a/datafusion/core/src/execution/context/mod.rs
+++ b/datafusion/core/src/execution/context/mod.rs
@@ -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>,
@@ -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(())
}
diff --git a/datafusion/core/src/execution/context/parquet.rs
b/datafusion/core/src/execution/context/parquet.rs
index 1d83c968c1..3f23c150be 100644
--- a/datafusion/core/src/execution/context/parquet.rs
+++ b/datafusion/core/src/execution/context/parquet.rs
@@ -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 {
@@ -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())),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]