MCPcopy Create free account
hub / github.com/PRQL/prql / test_variable_after_aggregate

Function test_variable_after_aggregate

prqlc/prqlc/src/sql/gen_query.rs:768–800  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

766
767 #[test]
768 fn test_variable_after_aggregate() {
769 let query = &r#"
770 from employees
771 group {title, emp_no} (
772 aggregate {emp_salary = average salary}
773 )
774 group {title} (
775 aggregate {avg_salary = average emp_salary}
776 )
777 "#;
778
779 let sql_ast = crate::tests::compile(query).unwrap();
780
781 assert_snapshot!(sql_ast, @"
782 WITH table_0 AS (
783 SELECT
784 title,
785 AVG(salary) AS _expr_0
786 FROM
787 employees
788 GROUP BY
789 title,
790 emp_no
791 )
792 SELECT
793 title,
794 AVG(_expr_0) AS avg_salary
795 FROM
796 table_0
797 GROUP BY
798 title
799 ");
800 }
801
802 #[test]
803 fn test_derive_filter() {

Callers

nothing calls this directly

Calls 1

compileFunction · 0.70

Tested by

no test coverage detected