feat: support INSERT INTO [TABLE] FUNCTION of Clickhouse (#1633)

Co-authored-by: Kermit <chenjiawei1@xiaohongshu.com>
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
cjw 2025-01-10 22:23:56 +08:00 committed by GitHub
parent c54ba4dc41
commit b09514e492
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 147 additions and 53 deletions

View file

@ -7907,6 +7907,36 @@ impl fmt::Display for RenameTable {
}
}
/// Represents the referenced table in an `INSERT INTO` statement
#[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 {
/// Table specified by name.
/// Example:
/// ```sql
/// INSERT INTO my_table
/// ```
TableName(#[cfg_attr(feature = "visitor", visit(with = "visit_relation"))] ObjectName),
/// 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)
TableFunction(Function),
}
impl fmt::Display for TableObject {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::TableName(table_name) => write!(f, "{table_name}"),
Self::TableFunction(func) => write!(f, "FUNCTION {}", func),
}
}
}
#[cfg(test)]
mod tests {
use super::*;