Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid ROW_NUMBER() OVER clause generated for SnowflakeΒ #5580

@julien-pinchelimouroux

Description

@julien-pinchelimouroux

What happened?

Hi there πŸ‘‹

PRQL generates an invalid clause for Snowflake dialect.
According to Snowflake's documentation, the ROW_NUMBER always needs the ORDER BY, which is missing in current generated SQL.

Currently the following error occurs:
Window function type [ROW_NUMBER] requires ORDER BY in window specification.

PRQL input

from invoices
group { this.`customer_id` } (take 1)

SQL output

WITH table_0 AS (
  SELECT
    *,
    ROW_NUMBER() OVER (PARTITION BY customer_id) AS _expr_0
  FROM
    invoices
)
SELECT
  *
FROM
  table_0
WHERE
  _expr_0 <= 1

Expected SQL output

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