We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9889b24 commit d304c23Copy full SHA for d304c23
6 files changed
src/ast/mod.rs
@@ -40,8 +40,8 @@ pub use self::ddl::{
40
pub use self::operator::{BinaryOperator, UnaryOperator};
41
pub use self::query::{
42
ConnectBy, Cte, CteAsMaterialized, Distinct, ExceptSelectItem, ExcludeSelectItem, Fetch,
43
- ForClause, ForJson, ForXml, GroupByExpr, IdentWithAlias, IlikeSelectItem, Join, JoinConstraint,
44
- JoinOperator, JsonTableColumn, JsonTableColumnErrorHandling, LateralView, LockClause, LockType,
+ ForClause, ForJson, ForXml, GroupByExpr, IdentWithAlias, Join, JoinConstraint, JoinOperator,
+ JsonTableColumn, JsonTableColumnErrorHandling, LateralView, LockClause, LockType,
45
NamedWindowDefinition, NonBlock, Offset, OffsetRows, OrderByExpr, Query, RenameSelectItem,
46
ReplaceSelectElement, ReplaceSelectItem, Select, SelectInto, SelectItem, SetExpr, SetOperator,
47
SetQuantifier, Table, TableAlias, TableFactor, TableVersion, TableWithJoins, Top, TopQuantity,
src/ast/query.rs
@@ -477,9 +477,6 @@ impl fmt::Display for IdentWithAlias {
477
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
478
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
479
pub struct WildcardAdditionalOptions {
480
- /// `[ILIKE...]`.
481
- /// Snowflake syntax: <https://docs.snowflake.com/en/sql-reference/sql/select>
482
- pub opt_ilike: Option<IlikeSelectItem>,
483
/// `[EXCLUDE...]`.
484
pub opt_exclude: Option<ExcludeSelectItem>,
485
/// `[EXCEPT...]`.
@@ -495,9 +492,6 @@ pub struct WildcardAdditionalOptions {
495
492
496
493
impl fmt::Display for WildcardAdditionalOptions {
497
494
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
498
- if let Some(ilike) = &self.opt_ilike {
499
- write!(f, " {ilike}")?;
500
- }
501
if let Some(exclude) = &self.opt_exclude {
502
write!(f, " {exclude}")?;
503
}
@@ -514,29 +508,6 @@ impl fmt::Display for WildcardAdditionalOptions {
514
508
515
509
516
510
517
-/// Snowflake `ILIKE` information.
518
-///
519
-/// # Syntax
520
-/// ```plaintext
521
-/// ILIKE <value>
522
-/// ```
523
-#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
524
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
525
-#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
526
-pub struct IlikeSelectItem {
527
- pub pattern: String,
528
-}
529
-
530
-impl fmt::Display for IlikeSelectItem {
531
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
532
- write!(
533
- f,
534
- "ILIKE '{}'",
535
- value::escape_single_quote_string(&self.pattern)
536
- )?;
537
- Ok(())
538
539
540
511
/// Snowflake `EXCLUDE` information.
541
512
///
542
513
/// # Syntax
src/parser/mod.rs
@@ -8775,13 +8775,7 @@ impl<'a> Parser<'a> {
8775
pub fn parse_wildcard_additional_options(
8776
&mut self,
8777
) -> Result<WildcardAdditionalOptions, ParserError> {
8778
- let opt_ilike = if dialect_of!(self is GenericDialect | SnowflakeDialect) {
8779
- self.parse_optional_select_item_ilike()?
8780
- } else {
8781
- None
8782
- };
8783
- let opt_exclude = if opt_ilike.is_none()
8784
- && dialect_of!(self is GenericDialect | DuckDbDialect | SnowflakeDialect)
+ let opt_exclude = if dialect_of!(self is GenericDialect | DuckDbDialect | SnowflakeDialect)
8785
{
8786
self.parse_optional_select_item_exclude()?
8787
} else {
@@ -8807,30 +8801,13 @@ impl<'a> Parser<'a> {
8807
8801
};
8808
8802
8809
8803
Ok(WildcardAdditionalOptions {
8810
- opt_ilike,
8811
8804
opt_exclude,
8812
8805
opt_except,
8813
8806
opt_rename,
8814
opt_replace,
8815
})
8816
8817
8818
- pub fn parse_optional_select_item_ilike(
8819
- &mut self,
8820
- ) -> Result<Option<IlikeSelectItem>, ParserError> {
8821
- let opt_ilike = if self.parse_keyword(Keyword::ILIKE) {
8822
- let next_token = self.next_token();
8823
- let pattern = match next_token.token {
8824
- Token::SingleQuotedString(s) => s,
8825
- _ => return self.expected("ilike pattern", next_token),
8826
8827
- Some(IlikeSelectItem { pattern })
8828
8829
8830
8831
- Ok(opt_ilike)
8832
8833
8834
/// Parse an [`Exclude`](ExcludeSelectItem) information for wildcard select items.
8835
8836
/// If it is not possible to parse it, will return an option.
tests/sqlparser_common.rs
@@ -6560,7 +6560,6 @@ fn lateral_function() {
6560
distinct: None,
6561
top: None,
6562
projection: vec![SelectItem::Wildcard(WildcardAdditionalOptions {
6563
- opt_ilike: None,
6564
opt_exclude: None,
6565
opt_except: None,
6566
opt_rename: None,
tests/sqlparser_duckdb.rs
@@ -148,7 +148,6 @@ fn test_select_union_by_name() {
148
149
150
151
152
153
154
@@ -184,7 +183,6 @@ fn test_select_union_by_name() {
184
183
185
186
187
188
189
190
tests/sqlparser_snowflake.rs
@@ -1615,42 +1615,3 @@ fn test_select_wildcard_with_replace() {
1615
});
1616
assert_eq!(expected, select.projection[0]);
1617
1618
1619
-#[test]
1620
-fn test_select_wildcard_with_ilike() {
1621
- let select = snowflake_and_generic().verified_only_select(r#"SELECT * ILIKE '%id%' FROM tbl"#);
1622
- let expected = SelectItem::Wildcard(WildcardAdditionalOptions {
1623
- opt_ilike: Some(IlikeSelectItem {
1624
- pattern: "%id%".to_owned(),
1625
- }),
1626
- ..Default::default()
1627
- });
1628
- assert_eq!(expected, select.projection[0]);
1629
1630
1631
1632
-fn test_select_wildcard_with_ilike_double_quote() {
1633
- let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE "%id" FROM tbl"#);
1634
- assert_eq!(
1635
- res.unwrap_err().to_string(),
1636
- "sql parser error: Expected ilike pattern, found: \"%id\""
1637
- );
1638
1639
1640
1641
-fn test_select_wildcard_with_ilike_number() {
1642
- let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE 42 FROM tbl"#);
1643
1644
1645
- "sql parser error: Expected ilike pattern, found: 42"
1646
1647
1648
1649
1650
-fn test_select_wildcard_with_ilike_replace() {
1651
- let res = snowflake().parse_sql_statements(r#"SELECT * ILIKE '%id%' EXCLUDE col FROM tbl"#);
1652
1653
1654
- "sql parser error: Expected end of statement, found: EXCLUDE"
1655
1656
0 commit comments