Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected result with s-string including UNNEST #4385

Open
2 tasks done
snth opened this issue Apr 12, 2024 · 1 comment
Open
2 tasks done

Unexpected result with s-string including UNNEST #4385

snth opened this issue Apr 12, 2024 · 1 comment
Labels
bug Invalid compiler output or panic

Comments

@snth
Copy link
Member

snth commented Apr 12, 2024

What happened?

I was just being lazy and thought I'd try out a potentially more ergonomic way of writing some example data when I encountered the following unexpected output.

PRQL input

from s"SELECT UNNEST([0.1, 0.2, 0.3, 1, 2, 4])"

SQL output

WITH table_0 AS (
  SELECT
    UNNEST([0.1, 0.2, 0.3, 1, 2, 4])
)
SELECT
  *
FROM
  table_0

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

Expected SQL output

WITH table_0 AS (
  SELECT
    UNNEST([0.1, 0.2, 0.3, 1, 2, 4])
)
SELECT
  *
FROM
  table_0

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

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

The SQL looks fine but the Query Results are surprising:

unnest(main.list_value(0.1, 0.2, 0.3, 1, 2, 4))

1
2
3
10
20
40

Compare this with the results from shell.duckdb.org:

duckdb> from unnest([0.1, 0.2, 0.3, 1, 2, 3]);
┌─────────────────────────────────────────┐
│ main.list_value(0.1, 0.2, 0.3, 1, 2, 3) │
╞═════════════════════════════════════════╡
│                                     0.1 │
│                                     0.2 │
│                                     0.3 │
│                                     1.0 │
│                                     2.0 │
│                                     3.0 │
└─────────────────────────────────────────┘
@snth snth added the bug Invalid compiler output or panic label Apr 12, 2024
@snth
Copy link
Member Author

snth commented Apr 12, 2024

Looks like something in the web/js bindings because even the following produces the same results:

PRQL

from [{a=0.1}, {a=1}]

SQL

WITH table_0 AS (
  SELECT
    0.1 AS a
  UNION
  ALL
  SELECT
    1 AS a
)
SELECT
  a
FROM
  table_0

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

Query Results

[
  {"a": 1},
  {"a": 10}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Invalid compiler output or panic
Projects
None yet
Development

No branches or pull requests

1 participant