Skip to content

Compiler crash when joining a zero-row relation #5988

Description

@kgutwin

What happened?

Context: support for relations created by from_text that have zero rows was added in #4693 and discussed in #4421.

The PRQL below crashes on compilation with:

Message:  called `Option::unwrap()` on a `None` value
Location: prqlc/prqlc/src/semantic/resolver/transforms.rs:579

PRQL input

from foo
select {bar}
join side:left map = (
  from_text format:json '{"columns":["key","value"],"data":[]}'
) this.bar == that.key

SQL output

N/A

Expected SQL output

WITH table_0 AS (
  SELECT
    NULL AS "key",
    NULL AS value
  WHERE
    false
)
SELECT
  foo.bar,
  table_0."key",
  table_0.value
FROM
  foo
  LEFT OUTER JOIN table_0 ON foo.bar = table_0."key"

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

The analogous PRQL code with more than one row does compile successfully:

from foo
select {bar}
join side:left map = (
  from_text format:json '{"columns":["key","value"],"data":[["x","y"]]}'
) this.bar == that.key

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugInvalid compiler output or panic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions