Skip to content

Commit b61aee7

Browse files
alexandreycalexandreyc
andauthored
Minor: make signatures of SessionContext::register_* methods consistent (#20873)
## Which issue does this PR close? None. ## Rationale for this change All `register_*` methods on `SessionContext` should have similar signatures for the sake of API consistency. ## What changes are included in this PR? Update `SessionContext::register_batch` and `SessionContext::register_arrow` to have similar signatures than the rest of `SessionContext::register_*` methods. ## Are these changes tested? I don't think any tests are required for this. Type checking done by the compiler should be enough. Let me know if you disagree. ## Are there any user-facing changes? I don't think so. All previous calls to these methods should still work as before. Co-authored-by: alexandreyc <alexandre@crayssac.net>
1 parent 8609288 commit b61aee7

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

  • datafusion/core/src/execution/context

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -530,19 +530,14 @@ impl SessionContext {
530530
self.runtime_env().deregister_object_store(url)
531531
}
532532

533-
/// Registers the [`RecordBatch`] as the specified table name
533+
/// Registers the given [`RecordBatch`] as the specified table reference.
534534
pub fn register_batch(
535535
&self,
536-
table_name: &str,
536+
table_ref: impl Into<TableReference>,
537537
batch: RecordBatch,
538538
) -> Result<Option<Arc<dyn TableProvider>>> {
539539
let table = MemTable::try_new(batch.schema(), vec![vec![batch]])?;
540-
self.register_table(
541-
TableReference::Bare {
542-
table: table_name.into(),
543-
},
544-
Arc::new(table),
545-
)
540+
self.register_table(table_ref, Arc::new(table))
546541
}
547542

548543
/// Return the [RuntimeEnv] used to run queries with this `SessionContext`
@@ -1788,15 +1783,14 @@ impl SessionContext {
17881783
/// SQL statements executed against this context.
17891784
pub async fn register_arrow(
17901785
&self,
1791-
name: &str,
1792-
table_path: &str,
1786+
table_ref: impl Into<TableReference>,
1787+
table_path: impl AsRef<str>,
17931788
options: ArrowReadOptions<'_>,
17941789
) -> Result<()> {
17951790
let listing_options = options
17961791
.to_listing_options(&self.copied_config(), self.copied_table_options());
1797-
17981792
self.register_listing_table(
1799-
name,
1793+
table_ref,
18001794
table_path,
18011795
listing_options,
18021796
options.schema.map(|s| Arc::new(s.to_owned())),

0 commit comments

Comments
 (0)