lovasoa commented on code in PR #1526:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1526#discussion_r1845250525
##########
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:
It is useful in tests, but also for other library users. Since we add a
level of indirection between TableAlias and the actual column names, this makes
it easier to instantiate TableAlias in the overwhelming majority of cases when
there is only a column name and no type. This is public like `Ident::new` is.
--
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]