mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-11 06:22:04 +00:00
Add support for MySQL MEMBER OF (#1917)
This commit is contained in:
parent
418b94227a
commit
be2d2f14e7
5 changed files with 65 additions and 0 deletions
|
@ -1124,6 +1124,8 @@ pub enum Expr {
|
|||
/// [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-lambda-functions.html)
|
||||
/// [DuckDb](https://duckdb.org/docs/sql/functions/lambda.html)
|
||||
Lambda(LambdaFunction),
|
||||
/// Checks membership of a value in a JSON array
|
||||
MemberOf(MemberOf),
|
||||
}
|
||||
|
||||
impl Expr {
|
||||
|
@ -1912,6 +1914,7 @@ impl fmt::Display for Expr {
|
|||
}
|
||||
Expr::Prior(expr) => write!(f, "PRIOR {expr}"),
|
||||
Expr::Lambda(lambda) => write!(f, "{lambda}"),
|
||||
Expr::MemberOf(member_of) => write!(f, "{member_of}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9831,6 +9834,27 @@ impl fmt::Display for NullInclusion {
|
|||
}
|
||||
}
|
||||
|
||||
/// Checks membership of a value in a JSON array
|
||||
///
|
||||
/// Syntax:
|
||||
/// ```sql
|
||||
/// <value> MEMBER OF(<array>)
|
||||
/// ```
|
||||
/// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_member-of)
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
|
||||
pub struct MemberOf {
|
||||
pub value: Box<Expr>,
|
||||
pub array: Box<Expr>,
|
||||
}
|
||||
|
||||
impl fmt::Display for MemberOf {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} MEMBER OF({})", self.value, self.array)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tokenizer::Location;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue