@@ -351,8 +351,7 @@ impl Dialect for SnowflakeDialect {
351
351
match kw {
352
352
// The following keywords can be considered an alias as long as
353
353
// they are not followed by other tokens that may change their meaning
354
- Keyword :: LIMIT
355
- | Keyword :: RETURNING
354
+ Keyword :: RETURNING
356
355
| Keyword :: INNER
357
356
| Keyword :: USING
358
357
| Keyword :: PIVOT
@@ -365,6 +364,18 @@ impl Dialect for SnowflakeDialect {
365
364
false
366
365
}
367
366
367
+ // `LIMIT` can be considered an alias as long as it's not followed by a value. For example:
368
+ // `SELECT * FROM tbl LIMIT WHERE 1=1` - alias
369
+ // `SELECT * FROM tbl LIMIT 3` - not an alias
370
+ Keyword :: LIMIT
371
+ if matches ! (
372
+ parser. peek_token( ) . token,
373
+ Token :: Number ( _, _) | Token :: Placeholder ( _)
374
+ ) =>
375
+ {
376
+ false
377
+ }
378
+
368
379
// `FETCH` can be considered an alias as long as it's not followed by `FIRST`` or `NEXT`
369
380
// which would give it a different meanings, for example:
370
381
// `SELECT * FROM tbl FETCH FIRST 10 ROWS` - not an alias
@@ -373,7 +384,10 @@ impl Dialect for SnowflakeDialect {
373
384
if parser
374
385
. peek_one_of_keywords ( & [ Keyword :: FIRST , Keyword :: NEXT ] )
375
386
. is_some ( )
376
- || matches ! ( parser. peek_token( ) . token, Token :: Number ( _, _) ) =>
387
+ || matches ! (
388
+ parser. peek_token( ) . token,
389
+ Token :: Number ( _, _) | Token :: Placeholder ( _)
390
+ ) =>
377
391
{
378
392
false
379
393
}
@@ -387,6 +401,7 @@ impl Dialect for SnowflakeDialect {
387
401
{
388
402
false
389
403
}
404
+
390
405
Keyword :: GLOBAL if parser. peek_keyword ( Keyword :: FULL ) => false ,
391
406
392
407
// Reserved keywords by the Snowflake dialect, which seem to be less strictive
0 commit comments