mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-12-23 11:12:51 +00:00
Added relative path to refresh parsing
This commit is contained in:
parent
ed28b883f1
commit
930264a426
4 changed files with 26 additions and 8 deletions
|
|
@ -371,10 +371,15 @@ pub enum AlterTableOperation {
|
|||
DropClusteringKey,
|
||||
SuspendRecluster,
|
||||
ResumeRecluster,
|
||||
/// `REFRESH`
|
||||
/// `REFRESH [ '<subpath>' ]`
|
||||
///
|
||||
/// Note: this is Snowflake specific for dynamic tables <https://docs.snowflake.com/en/sql-reference/sql/alter-table>
|
||||
Refresh,
|
||||
/// Note: this is Snowflake specific for dynamic/external tables
|
||||
/// <https://docs.snowflake.com/en/sql-reference/sql/alter-dynamic-table>
|
||||
/// <https://docs.snowflake.com/en/sql-reference/sql/alter-external-table>
|
||||
Refresh {
|
||||
/// Optional subpath for external table refresh
|
||||
subpath: Option<String>,
|
||||
},
|
||||
/// `ADD PARTITION COLUMN <column_name> <data_type>`
|
||||
///
|
||||
/// Note: this is Snowflake specific for external tables <https://docs.snowflake.com/en/sql-reference/sql/alter-external-table>
|
||||
|
|
@ -870,8 +875,12 @@ impl fmt::Display for AlterTableOperation {
|
|||
write!(f, "RESUME RECLUSTER")?;
|
||||
Ok(())
|
||||
}
|
||||
AlterTableOperation::Refresh => {
|
||||
write!(f, "REFRESH")
|
||||
AlterTableOperation::Refresh { subpath } => {
|
||||
write!(f, "REFRESH")?;
|
||||
if let Some(path) = subpath {
|
||||
write!(f, " '{path}'")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
AlterTableOperation::AddPartitionColumn {
|
||||
column_name,
|
||||
|
|
|
|||
|
|
@ -1145,7 +1145,7 @@ impl Spanned for AlterTableOperation {
|
|||
AlterTableOperation::DropClusteringKey => Span::empty(),
|
||||
AlterTableOperation::SuspendRecluster => Span::empty(),
|
||||
AlterTableOperation::ResumeRecluster => Span::empty(),
|
||||
AlterTableOperation::Refresh => Span::empty(),
|
||||
AlterTableOperation::Refresh { .. } => Span::empty(),
|
||||
AlterTableOperation::AddPartitionColumn { column_name, .. } => column_name.span,
|
||||
AlterTableOperation::Suspend => Span::empty(),
|
||||
AlterTableOperation::Resume => Span::empty(),
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ fn parse_alter_dynamic_table(parser: &mut Parser) -> Result<Statement, ParserErr
|
|||
|
||||
// Parse the operation (REFRESH, SUSPEND, or RESUME)
|
||||
let operation = if parser.parse_keyword(Keyword::REFRESH) {
|
||||
AlterTableOperation::Refresh
|
||||
AlterTableOperation::Refresh { subpath: None }
|
||||
} else if parser.parse_keyword(Keyword::SUSPEND) {
|
||||
AlterTableOperation::Suspend
|
||||
} else if parser.parse_keyword(Keyword::RESUME) {
|
||||
|
|
@ -662,7 +662,15 @@ fn parse_alter_external_table(parser: &mut Parser) -> Result<Statement, ParserEr
|
|||
|
||||
// Parse the operation
|
||||
let operation = if parser.parse_keyword(Keyword::REFRESH) {
|
||||
AlterTableOperation::Refresh
|
||||
// Optional subpath for refreshing specific partitions
|
||||
let subpath = match parser.peek_token().token {
|
||||
Token::SingleQuotedString(s) => {
|
||||
parser.next_token();
|
||||
Some(s)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
AlterTableOperation::Refresh { subpath }
|
||||
} else if parser.parse_keywords(&[Keyword::RENAME, Keyword::TO]) {
|
||||
let new_table_name = parser.parse_object_name(false)?;
|
||||
AlterTableOperation::RenameTable {
|
||||
|
|
|
|||
|
|
@ -4639,6 +4639,7 @@ fn test_alter_dynamic_table() {
|
|||
#[test]
|
||||
fn test_alter_external_table() {
|
||||
snowflake().verified_stmt("ALTER EXTERNAL TABLE some_table REFRESH");
|
||||
snowflake().verified_stmt("ALTER EXTERNAL TABLE some_table REFRESH 'year=2025/month=12/'");
|
||||
snowflake().verified_stmt("ALTER EXTERNAL TABLE my_database.my_schema.my_external_table REFRESH");
|
||||
snowflake().verified_stmt("ALTER EXTERNAL TABLE some_table RENAME TO new_table_name");
|
||||
snowflake().verified_stmt("ALTER EXTERNAL TABLE some_table ADD PARTITION COLUMN column_name VARCHAR");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue