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 ee707c72 Support wildcard metrics for `SEMANTIC_VIEW` (#2016)
ee707c72 is described below

commit ee707c72a7a99cf84ea107f201ed7d58c4a75ed3
Author: Simon Sawert <si...@sawert.se>
AuthorDate: Thu Aug 28 12:18:03 2025 +0200

    Support wildcard metrics for `SEMANTIC_VIEW` (#2016)
---
 src/ast/query.rs          | 2 +-
 src/parser/mod.rs         | 7 +++++--
 tests/sqlparser_common.rs | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/ast/query.rs b/src/ast/query.rs
index 967af85c..ffc9ce66 100644
--- a/src/ast/query.rs
+++ b/src/ast/query.rs
@@ -1429,7 +1429,7 @@ pub enum TableFactor {
         /// List of dimensions or expression referring to dimensions (e.g. 
DATE_PART('year', col))
         dimensions: Vec<Expr>,
         /// List of metrics (references to objects like orders.value, value, 
orders.*)
-        metrics: Vec<ObjectName>,
+        metrics: Vec<Expr>,
         /// List of facts or expressions referring to facts or dimensions.
         facts: Vec<Expr>,
         /// WHERE clause for filtering
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 761bc312..a563e174 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -13958,7 +13958,7 @@ impl<'a> Parser<'a> {
                         "METRICS clause can only be specified 
once".to_string(),
                     ));
                 }
-                metrics = self.parse_comma_separated(|parser| 
parser.parse_object_name(true))?;
+                metrics = 
self.parse_comma_separated(Parser::parse_wildcard_expr)?;
             } else if self.parse_keyword(Keyword::FACTS) {
                 if !facts.is_empty() {
                     return Err(ParserError::ParserError(
@@ -13975,7 +13975,10 @@ impl<'a> Parser<'a> {
                 where_clause = Some(self.parse_expr()?);
             } else {
                 return parser_err!(
-                    "Expected one of DIMENSIONS, METRICS, FACTS or WHERE",
+                    format!(
+                        "Expected one of DIMENSIONS, METRICS, FACTS or WHERE, 
got {}",
+                        self.peek_token().token
+                    ),
                     self.peek_token().span.start
                 )?;
             }
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index 2e2d9bfd..516df5be 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -16951,6 +16951,7 @@ fn test_parse_semantic_view_table_factor() {
             "SELECT * FROM SEMANTIC_VIEW(model METRICS orders.col, 
orders.col2)",
             None,
         ),
+        ("SELECT * FROM SEMANTIC_VIEW(model METRICS orders.*)", None),
         // We can parse in any order but will always produce a result in a 
fixed order.
         (
             "SELECT * FROM SEMANTIC_VIEW(model WHERE x > 0 DIMENSIONS dim1)",
@@ -16980,7 +16981,6 @@ fn test_parse_semantic_view_table_factor() {
     let invalid_sqls = [
         "SELECT * FROM SEMANTIC_VIEW(model DIMENSIONS dim1 INVALID inv1)",
         "SELECT * FROM SEMANTIC_VIEW(model DIMENSIONS dim1 DIMENSIONS dim2)",
-        "SELECT * FROM SEMANTIC_VIEW(model METRICS SUM(met1.avg))",
     ];
 
     for sql in invalid_sqls {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to