Skip to content

Commit c6c8364

Browse files
committed
Support wildcard metrics for SEMANTIC_VIEW
This adds support for the valid syntax of using wildcard metrics. It also improves the error message on unexpected tokens.
1 parent bc478b0 commit c6c8364

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/parser/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13958,7 +13958,8 @@ impl<'a> Parser<'a> {
1395813958
"METRICS clause can only be specified once".to_string(),
1395913959
));
1396013960
}
13961-
metrics = self.parse_comma_separated(|parser| parser.parse_object_name(true))?;
13961+
metrics = self
13962+
.parse_comma_separated(|parser| parser.parse_object_name_inner(true, true))?;
1396213963
} else if self.parse_keyword(Keyword::FACTS) {
1396313964
if !facts.is_empty() {
1396413965
return Err(ParserError::ParserError(
@@ -13975,7 +13976,10 @@ impl<'a> Parser<'a> {
1397513976
where_clause = Some(self.parse_expr()?);
1397613977
} else {
1397713978
return parser_err!(
13978-
"Expected one of DIMENSIONS, METRICS, FACTS or WHERE",
13979+
format!(
13980+
"Expected one of DIMENSIONS, METRICS, FACTS or WHERE, got {}",
13981+
self.peek_token().token
13982+
),
1397913983
self.peek_token().span.start
1398013984
)?;
1398113985
}

tests/sqlparser_common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16951,6 +16951,7 @@ fn test_parse_semantic_view_table_factor() {
1695116951
"SELECT * FROM SEMANTIC_VIEW(model METRICS orders.col, orders.col2)",
1695216952
None,
1695316953
),
16954+
("SELECT * FROM SEMANTIC_VIEW(model METRICS orders.*)", None),
1695416955
// We can parse in any order but will always produce a result in a fixed order.
1695516956
(
1695616957
"SELECT * FROM SEMANTIC_VIEW(model WHERE x > 0 DIMENSIONS dim1)",

0 commit comments

Comments
 (0)