Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ impl fmt::Display for TableFactor {
json_path.fmt(f)?;
}
if !partitions.is_empty() {
write!(f, "PARTITION ({})", display_comma_separated(partitions))?;
write!(f, " PARTITION ({})", display_comma_separated(partitions))?;
}
if let Some(args) = args {
write!(f, "(")?;
Expand Down
16 changes: 16 additions & 0 deletions tests/sqlparser_mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4946,3 +4946,19 @@ fn parse_adjacent_string_literal_concatenation() {
fn parse_group_by_with_rollup() {
mysql().verified_stmt("SELECT * FROM tbl GROUP BY col1, col2 WITH ROLLUP");
}

#[test]
fn parse_table_partition_selection() {
mysql_and_generic().verified_stmt("SELECT * FROM employees PARTITION (p0, p2)");
mysql_and_generic().verified_stmt("SELECT * FROM employees PARTITION (p0) AS e");
mysql_and_generic().verified_stmt(
"SELECT * FROM employees PARTITION (p0) JOIN departments PARTITION (p1) ON employees.dept_id = departments.id",
);
mysql_and_generic().verified_stmt("UPDATE employees PARTITION (p0) SET salary = 1");
mysql_and_generic().verified_stmt("DELETE FROM employees PARTITION (p0) WHERE id = 1");

let err = mysql_and_generic()
.parse_sql_statements("SELECT * FROM employees PARTITION")
.expect_err("expected an error");
assert_matches!(err, ParserError::ParserError(_));
}
Loading