alamb commented on code in PR #4579:
URL: https://github.com/apache/arrow-datafusion/pull/4579#discussion_r1045740486


##########
datafusion/sql/src/planner.rs:
##########
@@ -3646,7 +3646,20 @@ mod tests {
                    HAVING first_name = 'M'";
         let err = logical_plan(sql).expect_err("query should have failed");
         assert_eq!(
-            "Plan(\"having_expr: person.first_name = Utf8(\\\"M\\\") must 
appear in the GROUP BY clause or be used in an aggregate function\")",
+            "Plan(\"HAVING clause references: person.first_name = 
Utf8(\\\"M\\\") must appear in the GROUP BY clause or be used in an aggregate 
function\")",
+            format!("{:?}", err)
+        );
+    }
+
+    #[test]
+    fn select_with_having_refers_to_invalid_column() {
+        let sql = "SELECT id, MAX(age)
+                   FROM person
+                   GROUP BY id
+                   HAVING first_name = 'M'";
+        let err = logical_plan(sql).expect_err("query should have failed");
+        assert_eq!(
+            "Plan(\"HAVING clause references non-aggregate values: Expression 
person.first_name could not be resolved from available columns: person.id, 
MAX(person.age)\")",

Review Comment:
   Very nice!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to