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 53aba68e Support qualified column names in `MATCH AGAINST` clause
(#1774)
53aba68e is described below
commit 53aba68e2dc758e591292115b1dd5faf71374346
Author: tomershaniii <[email protected]>
AuthorDate: Tue Mar 25 11:13:11 2025 +0200
Support qualified column names in `MATCH AGAINST` clause (#1774)
---
src/ast/mod.rs | 2 +-
src/parser/mod.rs | 2 +-
tests/sqlparser_mysql.rs | 29 +++++++++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 3264cf03..f187df99 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -1027,7 +1027,7 @@ pub enum Expr {
/// [(1)]:
https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html#function_match
MatchAgainst {
/// `(<col>, <col>, ...)`.
- columns: Vec<Ident>,
+ columns: Vec<ObjectName>,
/// `<expr>`.
match_value: Value,
/// `<search modifier>`
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 7d8417f3..65d536f7 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -2704,7 +2704,7 @@ impl<'a> Parser<'a> {
/// This method will raise an error if the column list is empty or with
invalid identifiers,
/// the match expression is not a literal string, or if the search
modifier is not valid.
pub fn parse_match_against(&mut self) -> Result<Expr, ParserError> {
- let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
+ let columns =
self.parse_parenthesized_qualified_column_list(Mandatory, false)?;
self.expect_keyword_is(Keyword::AGAINST)?;
diff --git a/tests/sqlparser_mysql.rs b/tests/sqlparser_mysql.rs
index d52619d5..3d318f70 100644
--- a/tests/sqlparser_mysql.rs
+++ b/tests/sqlparser_mysql.rs
@@ -3454,3 +3454,32 @@ fn parse_cast_integers() {
.run_parser_method("CAST(foo AS UNSIGNED INTEGER(3))", |p|
p.parse_expr())
.expect_err("CAST doesn't allow display width");
}
+
+#[test]
+fn parse_match_against_with_alias() {
+ let sql = "SELECT tbl.ProjectID FROM surveys.tbl1 AS tbl WHERE MATCH
(tbl.ReferenceID) AGAINST ('AAA' IN BOOLEAN MODE)";
+ match mysql().verified_stmt(sql) {
+ Statement::Query(query) => match *query.body {
+ SetExpr::Select(select) => match select.selection {
+ Some(Expr::MatchAgainst {
+ columns,
+ match_value,
+ opt_search_modifier,
+ }) => {
+ assert_eq!(
+ columns,
+ vec![ObjectName::from(vec![
+ Ident::new("tbl"),
+ Ident::new("ReferenceID")
+ ])]
+ );
+ assert_eq!(match_value,
Value::SingleQuotedString("AAA".to_owned()));
+ assert_eq!(opt_search_modifier,
Some(SearchModifier::InBooleanMode));
+ }
+ _ => unreachable!(),
+ },
+ _ => unreachable!(),
+ },
+ _ => unreachable!(),
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]