8000 `aggregate` clause after `append` clause · Issue #3184 · PRQL/prql · GitHub
[go: up one dir, main page]

Skip to content

aggregate clause after append clause #3184

@YuxiLing

Description

@YuxiLing

What happened?

PRQL compiler version:0.9.2

This issue is similar to an existing one, #2680. But I'm not sure if the root causes of those two issues are the same. So I open a new one.

I found that the aggregate clause also affects the translation of the append clause.

In the following example, assuming tb1 and tb2 have the same columns, we append tb2 to tb1, and get the minimum c0. But in the SQL code, it selects the target column before the union operation. Then the union operation fails.

error message from the database: "each UNION query must have the same number of columns"

PRQL input

from tb1
append tb2
aggregate {new_col1 = min c0}

SQL output

WITH table_0 AS (
  SELECT
    c0
  FROM
    tb1
  UNION
  ALL
  SELECT
    *
  FROM
    tb2
)
SELECT
  MIN(c0) AS new_col1
FROM
  table_0

-- Generated by PRQL compiler version:0.9.2 (https://prql-lang.org)

Expected SQL output

WITH table_0 AS (
  SELECT
    c0
  FROM
    tb1
  UNION
  ALL
  SELECT
    c0
  FROM
    tb2
)
SELECT
  MIN(c0) AS new_col1
FROM
  table_0

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugInvalid compiler output or panic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0