iffyio commented on code in PR #1526:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1526#discussion_r1845186912
##########
tests/sqlparser_common.rs:
##########
@@ -5576,6 +5580,40 @@ fn parse_table_function() {
);
}
+#[test]
+fn parse_table_valued_function_with_alias_and_column_defs() {
Review Comment:
```suggestion
fn parse_select_with_alias_and_column_defs() {
```
If I follow correctly this is only testing the column defs functionality and
the `FROM T` part hasn't changed with this PR so that it can be any table
factor?
##########
src/parser/mod.rs:
##########
@@ -8607,6 +8607,23 @@ impl<'a> Parser<'a> {
}
}
+ /// Parse a parenthesized comma-separated list of unqualified, possibly
quoted identifiers
Review Comment:
The comment doesn't seem to match the behavior?
##########
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:
is the function only being exposed publicly in order to use in tests?
Thinking if so we could instead replace with a helper function or similar in
the tests
##########
src/parser/mod.rs:
##########
@@ -8607,6 +8607,23 @@ impl<'a> Parser<'a> {
}
}
+ /// Parse a parenthesized comma-separated list of unqualified, possibly
quoted identifiers
+ pub fn parse_table_alias_column_defs(
Review Comment:
```suggestion
fn parse_table_alias_column_defs(
```
--
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]