This is an automated email from the ASF dual-hosted git repository.

iffyio pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 17e22f0a Add support for the SQL OVERLAPS predicate (#1638)
17e22f0a is described below

commit 17e22f0a60788c68952630024e2cb77db5be3c56
Author: Yoav Cohen <[email protected]>
AuthorDate: Mon Jan 6 16:35:24 2025 +0100

    Add support for the SQL OVERLAPS predicate (#1638)
---
 src/ast/operator.rs       | 6 ++++++
 src/dialect/mod.rs        | 1 +
 src/parser/mod.rs         | 1 +
 tests/sqlparser_common.rs | 5 +++++
 4 files changed, 13 insertions(+)

diff --git a/src/ast/operator.rs b/src/ast/operator.rs
index e44ea2bf..1f9a6b82 100644
--- a/src/ast/operator.rs
+++ b/src/ast/operator.rs
@@ -248,6 +248,11 @@ pub enum BinaryOperator {
     /// See [CREATE 
OPERATOR](https://www.postgresql.org/docs/current/sql-createoperator.html)
     /// for more information.
     PGCustomBinaryOperator(Vec<String>),
+    /// The `OVERLAPS` operator
+    ///
+    /// Specifies a test for an overlap between two datetime periods:
+    /// 
<https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#overlaps-predicate>
+    Overlaps,
 }
 
 impl fmt::Display for BinaryOperator {
@@ -304,6 +309,7 @@ impl fmt::Display for BinaryOperator {
             BinaryOperator::PGCustomBinaryOperator(idents) => {
                 write!(f, "OPERATOR({})", display_separated(idents, "."))
             }
+            BinaryOperator::Overlaps => f.write_str("OVERLAPS"),
         }
     }
 }
diff --git a/src/dialect/mod.rs b/src/dialect/mod.rs
index 9ffbd8ed..025b5b35 100644
--- a/src/dialect/mod.rs
+++ b/src/dialect/mod.rs
@@ -512,6 +512,7 @@ pub trait Dialect: Debug + Any {
             Token::Word(w) if w.keyword == Keyword::IS => Ok(p!(Is)),
             Token::Word(w) if w.keyword == Keyword::IN => Ok(p!(Between)),
             Token::Word(w) if w.keyword == Keyword::BETWEEN => Ok(p!(Between)),
+            Token::Word(w) if w.keyword == Keyword::OVERLAPS => 
Ok(p!(Between)),
             Token::Word(w) if w.keyword == Keyword::LIKE => Ok(p!(Like)),
             Token::Word(w) if w.keyword == Keyword::ILIKE => Ok(p!(Like)),
             Token::Word(w) if w.keyword == Keyword::RLIKE => Ok(p!(Like)),
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 170f3439..7776c66a 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -3060,6 +3060,7 @@ impl<'a> Parser<'a> {
                 Keyword::AND => Some(BinaryOperator::And),
                 Keyword::OR => Some(BinaryOperator::Or),
                 Keyword::XOR => Some(BinaryOperator::Xor),
+                Keyword::OVERLAPS => Some(BinaryOperator::Overlaps),
                 Keyword::OPERATOR if dialect_is!(dialect is PostgreSqlDialect 
| GenericDialect) => {
                     self.expect_token(&Token::LParen)?;
                     // there are special rules for operator names in
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index 4b307e8d..791fa38c 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -12805,3 +12805,8 @@ fn parse_update_from_before_select() {
         parse_sql_statements(query).unwrap_err()
     );
 }
+
+#[test]
+fn parse_overlaps() {
+    verified_stmt("SELECT (DATE '2016-01-10', DATE '2016-02-01') OVERLAPS 
(DATE '2016-01-20', DATE '2016-02-10')");
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to