Skip to content

Filtering on unnested data doesn't get quoted properly #977

@mgd722

Description

@mgd722

I have data like:

(id INT, type VARCHAR, tags VARCHAR[])
(1, 'Edit', ['Roads', 'Lakes'])
(2, 'Tool', ['Buildings', 'Dimension Lines'])

I want to make an event type chart and an unnested tags chart that crossfilter each other. The tag chart renders as expected with this code:

const tagPlot = vg.plot(
  vg.barX(vg.from('events', { filterBy: $filter, unnest: 'tags' }), {
    x: vg.count(),
    y: 'tags',
    fill: '#1f77b4',
    sort: { y: '-x', limit: 15 },
  }),
  vg.toggleY({ as: $filter }),
  vg.width(tagChartContainer.clientWidth || 500),
  vg.height(300),
  vg.marginLeft(120),
);

but when I hover/click a bar to filter the chart I get an error:

Error: Parser Error: syntax error at or near "Lines"
LINE 2: ... "events" AS "source" WHERE ("tags" IN (Dimension Lines)) GROUP BY "type"
                                                             ^

It seems that the unnested tag isn't getting quoted in the where clause.

Codepen example

The unnesting doesn't seem to work at all in my example-- I would expect each tag to have its own bar in the chart?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions