iffyio commented on code in PR #1917:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1917#discussion_r2177413405
##########
tests/sqlparser_mysql.rs:
##########
@@ -4109,3 +4109,9 @@ fn parse_alter_table_drop_index() {
AlterTableOperation::DropIndex { name } if name.value == "idx_index"
);
}
+
+#[test]
+fn parse_json_member_of() {
+ mysql().verified_stmt(r#"SELECT 17 MEMBER OF('[23, "abc", 17, "ab",
10]')"#);
Review Comment:
For one of the tests can we assert the reurned expr that it contains the
expected values in the expected fields in the AST?
##########
src/parser/mod.rs:
##########
@@ -3609,6 +3609,16 @@ impl<'a> Parser<'a> {
self.expected("IN or BETWEEN after NOT",
self.peek_token())
}
}
+ Keyword::MEMBER => {
+ if self.parse_keyword(Keyword::OF) {
+ let _ = self.expect_token(&Token::LParen);
+ let expr2 = self.parse_expr()?;
+ let _ = self.expect_token(&Token::RParen);
Review Comment:
It looks like we're dropping potential error returned by the expect_token
calls (we should probably add a test case for this behavior)?
##########
src/ast/mod.rs:
##########
@@ -1124,6 +1124,14 @@ 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
+ ///
+ /// Syntax:
+ /// ```sql
+ /// <value> MEMBER OF(<array>)
+ /// ```
+ ///
[MySQL](https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_member-of)
+ MemberOf(Box<Expr>, Box<Expr>),
Review Comment:
Can we introduce a struct for the expression e.g. `MemberOf(MemberOf{ value,
json })`? That way it would be less breaking if spans or other options are
added to the expression later on
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]