Skip to content

Commit 855bcd9

Browse files
Wojciech Padloclaude
andcommitted
Fix pre-existing CI failures on the snowflake branch lineage
These checks were already red on the base branch (lav-379-2-for-over-cursor), inherited from the cursor/scripting/ACCOUNT commits — unrelated to ALTER STAGE, but required for green CI on this PR: - codestyle: run cargo fmt --all across the crate - lint: collapse a match-in-match (parser scripting list), replace a forbidden unreachable! in DESCRIBE object-type parsing with a parse error, and collapse nested match arms in the warehouse/account tests - docs: drop unresolved intra-doc link brackets in scripting-list doc comments - compile-no-std: gate 'use alloc::vec' behind not(feature = std) in spans.rs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e40bdea commit 855bcd9

5 files changed

Lines changed: 114 additions & 138 deletions

File tree

src/ast/mod.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7024,18 +7024,10 @@ impl fmt::Display for Statement {
70247024
}
70257025
write!(f, ")")?;
70267026
if let Some(val) = allow_writes {
7027-
write!(
7028-
f,
7029-
" ALLOW_WRITES = {}",
7030-
if *val { "TRUE" } else { "FALSE" }
7031-
)?;
7027+
write!(f, " ALLOW_WRITES = {}", if *val { "TRUE" } else { "FALSE" })?;
70327028
}
70337029
if let Some(ref c) = comment {
7034-
write!(
7035-
f,
7036-
" COMMENT = '{}'",
7037-
value::escape_single_quote_string(c)
7038-
)?;
7030+
write!(f, " COMMENT = '{}'", value::escape_single_quote_string(c))?;
70397031
}
70407032
Ok(())
70417033
}
@@ -7163,20 +7155,12 @@ impl fmt::Display for Statement {
71637155
if let Some(ref auth) = rest_authentication {
71647156
write!(f, " REST_AUTHENTICATION = ({auth})")?;
71657157
}
7166-
write!(
7167-
f,
7168-
" ENABLED = {}",
7169-
if *enabled { "TRUE" } else { "FALSE" }
7170-
)?;
7158+
write!(f, " ENABLED = {}", if *enabled { "TRUE" } else { "FALSE" })?;
71717159
if let Some(secs) = refresh_interval_seconds {
71727160
write!(f, " REFRESH_INTERVAL_SECONDS = {secs}")?;
71737161
}
71747162
if let Some(ref c) = comment {
7175-
write!(
7176-
f,
7177-
" COMMENT = '{}'",
7178-
value::escape_single_quote_string(c)
7179-
)?;
7163+
write!(f, " COMMENT = '{}'", value::escape_single_quote_string(c))?;
71807164
}
71817165
Ok(())
71827166
}
@@ -12466,11 +12450,7 @@ impl fmt::Display for CatalogRestConfig {
1246612450
write!(f, " CATALOG_API_TYPE = {t}")?;
1246712451
}
1246812452
if let Some(ref w) = self.warehouse {
12469-
write!(
12470-
f,
12471-
" WAREHOUSE = '{}'",
12472-
value::escape_single_quote_string(w)
12473-
)?;
12453+
write!(f, " WAREHOUSE = '{}'", value::escape_single_quote_string(w))?;
1247412454
}
1247512455
if let Some(ref m) = self.access_delegation_mode {
1247612456
write!(f, " ACCESS_DELEGATION_MODE = {m}")?;

src/ast/spans.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ use crate::{
2323
},
2424
tokenizer::TokenWithSpan,
2525
};
26+
#[cfg(not(feature = "std"))]
27+
use alloc::vec;
2628
use core::iter;
2729

2830
use crate::tokenizer::Span;
@@ -35,20 +37,19 @@ use super::{
3537
ConflictTarget, ConnectByKind, ConstraintCharacteristics, CopySource, CreateIndex, CreateTable,
3638
CreateTableOptions, Cte, Delete, DoUpdate, ExceptSelectItem, ExcludeSelectItem, Expr,
3739
ExprWithAlias, Fetch, ForIterationSource, ForStatement, ForValues, FromTable, Function,
38-
FunctionArg,
39-
FunctionArgExpr, FunctionArgumentClause, FunctionArgumentList, FunctionArguments, GroupByExpr,
40-
HavingBound, IfStatement, IlikeSelectItem, IndexColumn, Insert, Interpolate, InterpolateExpr,
41-
Join, JoinConstraint, JoinOperator, JsonPath, JsonPathElem, LateralView, LimitClause,
42-
LoopControlStatement, LoopStatement, MatchRecognizePattern, Measure, Merge, MergeAction,
43-
MergeClause, MergeInsertExpr, MergeInsertKind, MergeUpdateExpr, NamedParenthesizedList,
44-
NamedWindowDefinition, ObjectName, ObjectNamePart, Offset, OnConflict, OnConflictAction,
45-
OnInsert, OpenStatement, OrderBy, OrderByExpr, OrderByKind, OutputClause, Parens, Partition,
46-
PartitionBoundValue, PivotValueSource, ProjectionSelect, Query, RaiseStatement,
47-
RaiseStatementValue, ReferentialAction, RenameSelectItem, RepeatStatement, ReplaceSelectElement,
48-
ReplaceSelectItem, Select, SelectInto, SelectItem, SetExpr, SqlOption, Statement, Subscript,
49-
SymbolDefinition, TableAlias, TableAliasColumnDef, TableConstraint, TableFactor, TableObject,
50-
TableOptionsClustered, TableWithJoins, Update, UpdateTableFromKind, Use, Values, ViewColumnDef,
51-
WhileStatement, WildcardAdditionalOptions, With, WithFill,
40+
FunctionArg, FunctionArgExpr, FunctionArgumentClause, FunctionArgumentList, FunctionArguments,
41+
GroupByExpr, HavingBound, IfStatement, IlikeSelectItem, IndexColumn, Insert, Interpolate,
42+
InterpolateExpr, Join, JoinConstraint, JoinOperator, JsonPath, JsonPathElem, LateralView,
43+
LimitClause, LoopControlStatement, LoopStatement, MatchRecognizePattern, Measure, Merge,
44+
MergeAction, MergeClause, MergeInsertExpr, MergeInsertKind, MergeUpdateExpr,
45+
NamedParenthesizedList, NamedWindowDefinition, ObjectName, ObjectNamePart, Offset, OnConflict,
46+
OnConflictAction, OnInsert, OpenStatement, OrderBy, OrderByExpr, OrderByKind, OutputClause,
47+
Parens, Partition, PartitionBoundValue, PivotValueSource, ProjectionSelect, Query,
48+
RaiseStatement, RaiseStatementValue, ReferentialAction, RenameSelectItem, RepeatStatement,
49+
ReplaceSelectElement, ReplaceSelectItem, Select, SelectInto, SelectItem, SetExpr, SqlOption,
50+
Statement, Subscript, SymbolDefinition, TableAlias, TableAliasColumnDef, TableConstraint,
51+
TableFactor, TableObject, TableOptionsClustered, TableWithJoins, Update, UpdateTableFromKind,
52+
Use, Values, ViewColumnDef, WhileStatement, WildcardAdditionalOptions, With, WithFill,
5253
};
5354

5455
/// Given an iterator of spans, return the [Span::union] of all spans.
@@ -832,10 +833,7 @@ impl Spanned for RepeatStatement {
832833
impl Spanned for LoopControlStatement {
833834
fn span(&self) -> Span {
834835
let LoopControlStatement { kind: _, label } = self;
835-
label
836-
.as_ref()
837-
.map(|l| l.span)
838-
.unwrap_or_else(Span::empty)
836+
label.as_ref().map(|l| l.span).unwrap_or_else(Span::empty)
839837
}
840838
}
841839

src/dialect/snowflake.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ use crate::ast::helpers::stmt_data_loading::{
2828
};
2929
use crate::ast::{
3030
AlterExternalVolumeOperation, AlterFileFormatOperation, AlterStageOperation, AlterTable,
31-
AlterTableOperation, AlterTableType,
32-
CatalogRestAuthentication, CatalogRestConfig, CatalogSource, CatalogSyncNamespaceMode,
33-
CatalogTableFormat, ColumnOption, ColumnPolicy, ColumnPolicyProperty, ContactEntry,
34-
CopyIntoSnowflakeKind, CreateTable, CreateTableLikeKind, DollarQuotedString,
35-
ExternalVolumeEncryption, ExternalVolumeStorageLocation, Ident, IdentityParameters,
36-
IdentityProperty, IdentityPropertyFormatKind, IdentityPropertyKind, IdentityPropertyOrder,
37-
InitializeKind, Insert, MultiTableInsertIntoClause, MultiTableInsertType, MultiTableInsertValue,
38-
MultiTableInsertValues, MultiTableInsertWhenClause, ObjectName, ObjectNamePart,
39-
RefreshModeKind, RowAccessPolicy, ShowObjects, SqlOption, Statement, StorageLifecyclePolicy,
40-
StorageSerializationPolicy, TableObject, TagsColumnOption, Value, WrappedCollection,
31+
AlterTableOperation, AlterTableType, CatalogRestAuthentication, CatalogRestConfig,
32+
CatalogSource, CatalogSyncNamespaceMode, CatalogTableFormat, ColumnOption, ColumnPolicy,
33+
ColumnPolicyProperty, ContactEntry, CopyIntoSnowflakeKind, CreateTable, CreateTableLikeKind,
34+
DollarQuotedString, ExternalVolumeEncryption, ExternalVolumeStorageLocation, Ident,
35+
IdentityParameters, IdentityProperty, IdentityPropertyFormatKind, IdentityPropertyKind,
36+
IdentityPropertyOrder, InitializeKind, Insert, MultiTableInsertIntoClause,
37+
MultiTableInsertType, MultiTableInsertValue, MultiTableInsertValues,
38+
MultiTableInsertWhenClause, ObjectName, ObjectNamePart, RefreshModeKind, RowAccessPolicy,
39+
ShowObjects, SqlOption, Statement, StorageLifecyclePolicy, StorageSerializationPolicy,
40+
TableObject, TagsColumnOption, Value, WrappedCollection,
4141
};
4242
use crate::dialect::{Dialect, Precedence};
4343
use crate::keywords::Keyword;
@@ -319,7 +319,10 @@ impl Dialect for SnowflakeDialect {
319319
return Some(parse_drop_file_format(parser));
320320
}
321321

322-
if parser.parse_one_of_keywords(&[Keyword::DESC, Keyword::DESCRIBE]).is_some() {
322+
if parser
323+
.parse_one_of_keywords(&[Keyword::DESC, Keyword::DESCRIBE])
324+
.is_some()
325+
{
323326
if parser.parse_keywords(&[Keyword::EXTERNAL, Keyword::VOLUME]) {
324327
// DESC[RIBE] EXTERNAL VOLUME
325328
return Some(parse_describe_external_volume(parser));
@@ -2206,9 +2209,7 @@ fn parse_external_volume_storage_location(
22062209
}
22072210

22082211
let storage_base_url = storage_base_url.ok_or_else(|| {
2209-
ParserError::ParserError(
2210-
"STORAGE_BASE_URL is required in STORAGE_LOCATION".to_string(),
2211-
)
2212+
ParserError::ParserError("STORAGE_BASE_URL is required in STORAGE_LOCATION".to_string())
22122213
})?;
22132214

22142215
Ok(ExternalVolumeStorageLocation {
@@ -2316,7 +2317,8 @@ fn parse_create_file_format(
23162317
}
23172318

23182319
// `LIKE` is mutually exclusive with `TYPE`/options per Snowflake's grammar.
2319-
if like_source.is_some() && !matches!(parser.peek_token().token, Token::EOF | Token::SemiColon) {
2320+
if like_source.is_some() && !matches!(parser.peek_token().token, Token::EOF | Token::SemiColon)
2321+
{
23202322
return parser.expected(
23212323
"end of statement after CREATE FILE FORMAT ... LIKE",
23222324
parser.peek_token(),

src/parser/mod.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,8 @@ impl<'a> Parser<'a> {
979979
}
980980
};
981981

982-
let conditional_statements = self.parse_scripting_conditional_statements(terminal_keywords)?;
982+
let conditional_statements =
983+
self.parse_scripting_conditional_statements(terminal_keywords)?;
983984

984985
Ok(ConditionalStatementBlock {
985986
start_token: AttachedToken(start_token),
@@ -1013,13 +1014,13 @@ impl<'a> Parser<'a> {
10131014
Ok(conditional_statements)
10141015
}
10151016

1016-
/// Like [`parse_conditional_statements`], but the bare-sequence branch
1017-
/// dispatches to [`parse_scripting_statement_list`] so that body-only
1017+
/// Like `parse_conditional_statements`, but the bare-sequence branch
1018+
/// dispatches to `parse_scripting_statement_list` so that body-only
10181019
/// scripting forms (loop control, `LET`, bare assignment) parse when the
10191020
/// body omits an inner `BEGIN … END`. Used by Snowflake-scripting loop
10201021
/// and conditional constructs; **not** used by `CREATE TRIGGER` /
10211022
/// `CREATE PROCEDURE` bodies, which retain their existing semantics via
1022-
/// [`parse_conditional_statements`].
1023+
/// `parse_conditional_statements`.
10231024
fn parse_scripting_conditional_statements(
10241025
&mut self,
10251026
terminal_keywords: &[Keyword],
@@ -1042,7 +1043,7 @@ impl<'a> Parser<'a> {
10421043

10431044
/// Parse a list of statements inside a `BEGIN...END` scripting block.
10441045
///
1045-
/// Extends [`parse_statement_list`] with Snowflake-scripting-specific forms:
1046+
/// Extends `parse_statement_list` with Snowflake-scripting-specific forms:
10461047
/// - Bare assignment: `var := expr`
10471048
/// - `LET` declaration: `LET var [data_type] := expr`
10481049
pub(crate) fn parse_scripting_statement_list(
@@ -1053,10 +1054,10 @@ impl<'a> Parser<'a> {
10531054
loop {
10541055
match &self.peek_nth_token_ref(0).token {
10551056
Token::EOF => break,
1056-
Token::Word(w) => {
1057-
if w.quote_style.is_none() && terminal_keywords.contains(&w.keyword) {
1058-
break;
1059-
}
1057+
Token::Word(w)
1058+
if w.quote_style.is_none() && terminal_keywords.contains(&w.keyword) =>
1059+
{
1060+
break
10601061
}
10611062
_ => {}
10621063
}
@@ -8160,12 +8161,7 @@ impl<'a> Parser<'a> {
81608161
// The word could be a variable name. Check that the token
81618162
// after it looks like the rest of a declaration (type, `:=`,
81628163
// `DEFAULT`, or `;` for a bare declaration with no type/init).
8163-
matches!(
8164-
tok1,
8165-
Token::Assignment
8166-
| Token::Word(_)
8167-
| Token::SemiColon
8168-
)
8164+
matches!(tok1, Token::Assignment | Token::Word(_) | Token::SemiColon)
81698165
}
81708166
_ => false,
81718167
}
@@ -11476,10 +11472,7 @@ impl<'a> Parser<'a> {
1147611472
})?;
1147711473
AlterAccountOperation::Set { params }
1147811474
} else {
11479-
return self.expected(
11480-
"SET or RENAME TO after ALTER ACCOUNT",
11481-
self.peek_token(),
11482-
);
11475+
return self.expected("SET or RENAME TO after ALTER ACCOUNT", self.peek_token());
1148311476
};
1148411477

1148511478
Ok(Statement::AlterAccount { name, operation })
@@ -12684,8 +12677,7 @@ impl<'a> Parser<'a> {
1268412677
let peek_token = parser.peek_token();
1268512678
let span = peek_token.span;
1268612679
match peek_token.token {
12687-
Token::DollarQuotedString(s)
12688-
if dialect_of!(parser is PostgreSqlDialect | GenericDialect | SnowflakeDialect) =>
12680+
Token::DollarQuotedString(s) if dialect_of!(parser is PostgreSqlDialect | GenericDialect | SnowflakeDialect) =>
1268912681
{
1269012682
parser.next_token();
1269112683
Ok(Expr::Value(Value::DollarQuotedString(s).with_span(span)))
@@ -14493,7 +14485,10 @@ impl<'a> Parser<'a> {
1449314485

1449414486
// Snowflake-style: DESC <object_type> <name>
1449514487
if self.dialect.describe_requires_table_keyword()
14496-
&& matches!(describe_alias, DescribeAlias::Desc | DescribeAlias::Describe)
14488+
&& matches!(
14489+
describe_alias,
14490+
DescribeAlias::Desc | DescribeAlias::Describe
14491+
)
1449714492
{
1449814493
if let Some(kw) = self.parse_one_of_keywords(&[
1449914494
Keyword::TABLE,
@@ -14508,7 +14503,7 @@ impl<'a> Parser<'a> {
1450814503
Keyword::DATABASE => DescribeObjectType::Database,
1450914504
Keyword::SCHEMA => DescribeObjectType::Schema,
1451014505
Keyword::TASK => DescribeObjectType::Task,
14511-
_ => unreachable!(),
14506+
_ => return self.expected("a describe object type", self.peek_token()),
1451214507
};
1451314508
let object_name = self.parse_object_name(false)?;
1451414509
return Ok(Statement::DescribeObject {

0 commit comments

Comments
 (0)