Skip to content

"unnested record must have two fields" error with input from file #6563

@philrz

Description

@philrz

The SPQ from the "walk" example at the bottom of the Subqueries docs has started rejecting some input from files after the merge of the changes in #6531.

Details

Repro is with super commit 39cec10.

File walk.spq contains the query text from the bottom example in the Subqueries docs:

fn walk(node, visit):
  case kind(node)
  when "array" then
    [unnest node | walk(this, visit)]
  when "record" then
    unflatten([unnest flatten(node) | {key,value:walk(value, visit)}])
  when "union" then
    walk(under(node), visit)
  else visit(node)
  end
fn addOne(node): case typeof(node) when <int64> then node+1 else node end
values walk(this, &addOne)

And input file foo.sup:

{n:1}

This works:

$ super -version
Version: 39cec10d8

$ cat foo.sup | super -I walk.spq -
{n:2}

But this doesn't.

$ super -I walk.spq foo.sup
unnested record must have two fields in walk.spq at line 4, column 13:
    [unnest node | walk(this, visit)]
            ~~~~

A binary search reveals that this started happening with the merge of the changes in #6531. If we go back to the commit right before that merged, it works as expected even when the input comes from the file.

$ super -version
Version: 6205ec1a0

$ super -I walk.spq foo.sup
{n:2}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions