You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ne...@apache.org on 2022/04/02 02:33:41 UTC

[arrow-datafusion] 01/01: add a Tablesource

This is an automated email from the ASF dual-hosted git repository.

nevime pushed a commit to branch rdbms-changes
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git

commit e6614aa8ff84ffc6d36d19ae5eaa3e71602df949
Author: Wakahisa <ne...@gmail.com>
AuthorDate: Mon Feb 14 22:50:05 2022 +0200

    add a Tablesource
    
    Tablesource contains more information about the source of the table.
    It can be a relational table, file(s), in-memory or unspecified.
---
 datafusion/core/src/datasource/datasource.rs | 34 ++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/datafusion/core/src/datasource/datasource.rs b/datafusion/core/src/datasource/datasource.rs
index 1b59c85..48a2dc0 100644
--- a/datafusion/core/src/datasource/datasource.rs
+++ b/datafusion/core/src/datasource/datasource.rs
@@ -55,6 +55,35 @@ pub enum TableType {
     Temporary,
 }
 
+/// Indicates the source of this table for metadata/catalog purposes.
+#[derive(Debug, Clone, PartialEq)]
+pub enum TableSource {
+    /// An ordinary physical table.
+    Relational {
+        ///
+        server: Option<String>,
+        ///
+        database: Option<String>,
+        ///
+        schema: Option<String>,
+        ///
+        table: String
+    },
+    /// A file on some file system
+    File {
+        ///
+        protocol: String,
+        ///
+        path: String,
+        ///
+        format: String,
+    },
+    /// A transient table.
+    InMemory,
+    /// An unspecified source, used as the default
+    Unspecified,
+}
+
 /// Source table
 #[async_trait]
 pub trait TableProvider: Sync + Send {
@@ -70,6 +99,11 @@ pub trait TableProvider: Sync + Send {
         TableType::Base
     }
 
+    /// The source of this table
+    fn table_source(&self) -> TableSource {
+        TableSource::Unspecified
+    }
+
     /// Create an ExecutionPlan that will scan the table.
     /// The table provider will be usually responsible of grouping
     /// the source data into partitions that can be efficiently