Skip to content

Commit eb545cc

Browse files
tomershaniiiayman-sigma
authored andcommitted
Support qualified column names in MATCH AGAINST clause (apache#1774)
1 parent 7686722 commit eb545cc

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/ast/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ pub enum Expr {
10341034
/// [(1)]: https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html#function_match
10351035
MatchAgainst {
10361036
/// `(<col>, <col>, ...)`.
1037-
columns: Vec<Ident>,
1037+
columns: Vec<ObjectName>,
10381038
/// `<expr>`.
10391039
match_value: Value,
10401040
/// `<search modifier>`

src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,7 @@ impl<'a> Parser<'a> {
27042704
/// This method will raise an error if the column list is empty or with invalid identifiers,
27052705
/// the match expression is not a literal string, or if the search modifier is not valid.
27062706
pub fn parse_match_against(&mut self) -> Result<Expr, ParserError> {
2707-
let columns = self.parse_parenthesized_column_list(Mandatory, false)?;
2707+
let columns = self.parse_parenthesized_qualified_column_list(Mandatory, false)?;
27082708

27092709
self.expect_keyword_is(Keyword::AGAINST)?;
27102710

tests/sqlparser_mysql.rs

+29
Original file line numberDiff line numberDiff line change
@@ -3454,3 +3454,32 @@ fn parse_cast_integers() {
34543454
.run_parser_method("CAST(foo AS UNSIGNED INTEGER(3))", |p| p.parse_expr())
34553455
.expect_err("CAST doesn't allow display width");
34563456
}
3457+
3458+
#[test]
3459+
fn parse_match_against_with_alias() {
3460+
let sql = "SELECT tbl.ProjectID FROM surveys.tbl1 AS tbl WHERE MATCH (tbl.ReferenceID) AGAINST ('AAA' IN BOOLEAN MODE)";
3461+
match mysql().verified_stmt(sql) {
3462+
Statement::Query(query) => match *query.body {
3463+
SetExpr::Select(select) => match select.selection {
3464+
Some(Expr::MatchAgainst {
3465+
columns,
3466+
match_value,
3467+
opt_search_modifier,
3468+
}) => {
3469+
assert_eq!(
3470+
columns,
3471+
vec![ObjectName::from(vec![
3472+
Ident::new("tbl"),
3473+
Ident::new("ReferenceID")
3474+
])]
3475+
);
3476+
assert_eq!(match_value, Value::SingleQuotedString("AAA".to_owned()));
3477+
assert_eq!(opt_search_modifier, Some(SearchModifier::InBooleanMode));
3478+
}
3479+
_ => unreachable!(),
3480+
},
3481+
_ => unreachable!(),
3482+
},
3483+
_ => unreachable!(),
3484+
}
3485+
}

0 commit comments

Comments
 (0)