iffyio commented on code in PR #1526:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1526#discussion_r1845295217


##########
src/ast/query.rs:
##########
@@ -1610,6 +1610,40 @@ impl fmt::Display for TableAlias {
     }
 }
 
+/// SQL column definition in a table expression alias.
+/// Most of the time, the data type is not specified.
+/// But some table-valued functions do require specifying the data type.
+///
+/// See 
<https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS>
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct TableAliasColumnDef {
+    /// Column name alias
+    pub name: Ident,
+    /// Some table-valued functions require specifying the data type in the 
alias.
+    pub data_type: Option<DataType>,
+}
+
+impl TableAliasColumnDef {
+    pub fn from_column_name(name: &str) -> Self {
+        TableAliasColumnDef {
+            name: Ident::new(name),
+            data_type: None,
+        }
+    }

Review Comment:
   hmm exposing a helper for Ident I think is reasonable since its quite 
pervasive, and its simple/dialect-agonstic enough. Here doesnt feel the same, 
like the increased api surface area is worth it. I'm ok with keeping it, 
deferring to @alamb 
   
   If we do keep it we should probably rename to something like `from_name` or 
maybe just `new` like Ident does (thinking a bit unclear what column name 
refers to, since this is more an alias for the column)?. Also for the parameter 
to accept e.g. `name: Into<String>` so that folks arent forced to pass a `&str` 
if they have something else on hand



-- 
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