pepijnve commented on code in PR #25112:
URL: https://github.com/apache/datafusion/pull/25112#discussion_r4071674001


##########
datafusion/sql/src/parser.rs:
##########
@@ -309,6 +309,70 @@ impl fmt::Display for CreateExternalTable {
     }
 }
 
+/// DataFusion extension `CREATE EXTERNAL CATALOG` statement.
+///
+/// ```sql
+/// CREATE [OR REPLACE] EXTERNAL CATALOG [IF NOT EXISTS] <catalog_name>
+/// STORED AS <catalog_type>
+/// [ LOCATION <literal> ]
+/// [ OPTIONS (<key_value_list>) ]
+///
+/// <key_value_list> := (<literal> <literal>, <literal> <literal>, ...)
+/// ```
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct CreateExternalCatalog {
+    /// Catalog name
+    pub catalog_name: ObjectName,
+    /// The key used to look up the registered `CatalogProviderFactory`
+    pub catalog_type: String,
+    /// The physical location of the catalog, if applicable
+    pub location: Option<String>,
+    /// Option to not error if catalog already exists
+    pub if_not_exists: bool,
+    /// Option to replace the catalog if it already exists
+    pub or_replace: bool,
+    /// Catalog(provider) specific options
+    pub options: Vec<(String, Value)>,
+}
+
+impl fmt::Display for CreateExternalCatalog {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        write!(f, "CREATE EXTERNAL CATALOG ")?;
+        if self.if_not_exists {
+            write!(f, "IF NOT EXISTS ")?;
+        }
+        write!(f, "{} ", self.catalog_name)?;
+        write!(f, "STORED AS {}", self.catalog_type)?;
+        if let Some(location) = &self.location {
+            write!(
+                f,
+                " LOCATION {}",
+                Value::SingleQuotedString(location.clone())
+            )?;
+        }

Review Comment:
   @alamb wdyt, would it make sense to add a session level `SecretsStore` as an 
extra extension point and then wire SQL `create secret` and `drop secret` to 
those? I would deliberately leave this open ended and default to a simple 
in-memory hashmap. The main intended use is to provide a way to reuse keys for 
multiple connections and provide a way to inject them out-of-band.
   
   See https://docs.snowflake.com/en/sql-reference/sql/create-secret, 
https://duckdb.org/docs/lts/configuration/secrets_manager, 
https://docs.risingwave.com/sql/commands/sql-create-secret, and  
https://learn.microsoft.com/en-us/sql/t-sql/statements/create-credential-transact-sql
 for some prior art.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to