You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve performance of queries of the form SELECT *, CASE ... END #18056
Is your feature request related to a problem or challenge?
A query of the form SELECT *, CASE ... END adds an extra column to an existing relation. The current implementation of case will take the entire input relation (i.e. all columns) and filter the entire records batch and all its columns for each when branch. This is done regardless of whether the when, then or else expressions use any of these columns or not. The implication is that the implementation may end up needlessly filtering columns that will never be read. For wide queries with many columns this has a significant impact on case evaluation.
As an example assume a query SELECT *, CASE c1 WHEN 1 THEN 'foo' WHEN 2 THEN 'bar' ELSE 'baz' END FROM t where t has 100 columns named c1 to c100. Since the case expression is only dependent on c1 it is pointless and wasteful to filter columns c2 through c100.
Describe the solution you'd like
Investigate if there are ways to optimize case evaluation.
Activity
pepijnve commentedon Oct 14, 2025
take
rluvaton commentedon Oct 20, 2025
Can you please add more to the description, I'm not sure I understand
pepijnve commentedon Oct 20, 2025
@rluvaton add some more detail. The PR (which I'm afraid has stalled a bit on my end) gives some ideas on how I think we could improve this.
Project record batches to avoid filtering unused columns in `CASE` ev…
Project record batches to avoid filtering unused columns in `CASE` ev…
Project record batches to avoid filtering unused columns in `CASE` ev…
Project record batches to avoid filtering unused columns in `CASE` ev…