Skip to content

Support UNPIVOT #830

Open
Open
@robinicole

Description

@robinicole

Could we add support for UNPIVOT in order to be able to generate a query such as

SELECT
  a,
  metric,
  value
FROM your_table
UNPIVOT(
  value FOR metric IN (m1, m2, m3, m4)
)

I think implementation should be similar to a the GROUP_BY statement
where this

Query._from("your_table").select(
Field("a"), 
Field("metric"), 
Field("vaslue")
).unpivot(Field("value"), "metric", (table.m1, table.m2, table.m3, table.m4) 

would generate

SELECT
  a,
  metric,
  value
FROM your_table
UNPIVOT(
  value FOR metric IN (m1, m2, m3, m4)
)

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