iffyio commented on code in PR #1633:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1633#discussion_r1907559764
##########
src/ast/mod.rs:
##########
@@ -7766,6 +7766,27 @@ impl fmt::Display for RenameTable {
}
}
+/// table object for insertion
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub enum TableObject {
+ // for simple table name
Review Comment:
```suggestion
/// Table specified by name.
/// Example:
/// ```sql
/// INSERT INTO my_table
/// ```
```
##########
src/dialect/mod.rs:
##########
@@ -782,6 +782,11 @@ pub trait Dialect: Debug + Any {
fn supports_insert_set(&self) -> bool {
false
}
+
+ /// Does the dialect support table function in insertion?
+ fn supports_table_function_in_insertion(&self) -> bool {
Review Comment:
```suggestion
fn supports_insert_table_function(&self) -> bool {
```
maybe something like this to match the style of `supports_insert_set` above?
##########
src/ast/mod.rs:
##########
@@ -7766,6 +7766,27 @@ impl fmt::Display for RenameTable {
}
}
+/// table object for insertion
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub enum TableObject {
+ // for simple table name
+ TableName(#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
ObjectName),
+
+ // for Clickhouse [table
functions](https://clickhouse.com/docs/en/sql-reference/table-functions)
Review Comment:
```suggestion
/// Table specified as a function.
/// Example:
/// ```sql
/// INSERT INTO TABLE FUNCTION remote('localhost', default.simple_table)
/// ```
///
[Clickhouse](https://clickhouse.com/docs/en/sql-reference/table-functions)
```
##########
src/ast/mod.rs:
##########
@@ -7766,6 +7766,27 @@ impl fmt::Display for RenameTable {
}
}
+/// table object for insertion
Review Comment:
```suggestion
/// Represents the referenced table in an `INSERT INTO` statement
```
##########
src/ast/dml.rs:
##########
@@ -470,8 +470,7 @@ pub struct Insert {
/// INTO - optional keyword
pub into: bool,
/// TABLE
- #[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
- pub table_name: ObjectName,
+ pub table_object: TableObject,
Review Comment:
Ah right, I didn't notice the existing table property. Looking at the
description of that property it feels its naming isn't ideal, I'm thinking as a
result we could take the opportunity to rename that one to e.g.
`has_table_keyword` to free up the current one to be called `table`?
##########
src/ast/mod.rs:
##########
@@ -7766,6 +7766,27 @@ impl fmt::Display for RenameTable {
}
}
+/// table object for insertion
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub enum TableObject {
+ // for simple table name
+ TableName(#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
ObjectName),
+
+ // for Clickhouse [table
functions](https://clickhouse.com/docs/en/sql-reference/table-functions)
+ TableFunction(Function),
+}
+
+impl fmt::Display for TableObject {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ Self::TableName(table_name) => write!(f, "{}",
display_separated(&table_name.0, ".")),
Review Comment:
```suggestion
Self::TableName(table_name) => write!(f, "{table_name}"),
```
I think this something like this should be equivalent?
--
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]