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

Support UNPIVOT #830

Open
robinicole opened this issue Feb 28, 2025 · 1 comment
Open

Support UNPIVOT #830

robinicole opened this issue Feb 28, 2025 · 1 comment

Comments

@robinicole
Copy link

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)
)
@robinicole
Copy link
Author

I am happy to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant