ibis icon indicating copy to clipboard operation
ibis copied to clipboard

feat: Windowing/aggregating over literals

Open TrevorBergeron opened this issue 1 year ago • 2 comments

Is your feature request related to a problem?

No response

What is the motivation behind your request?

I'm a developer of BigQuery Dataframes . I would like to programatically build SQL queries using ibis. It is challenging to build compact sql involving windows over constant expressions, as the ibis literal API does not allow building of windowed expressions over literals, despite this being legal in GoogleSql.

Right now, I'm forced to select the literal, and then apply the window afterwards, generating a new CTE, and therefore producing more verbose SQL.

Describe the solution you'd like

I'd like to apply aggregate functions to literal expressions in the context of select. For example table.select(ibis.literal(3).sum().over(some_window)).

What version of ibis are you running?

8.0.0

What backend(s) are you using, if any?

BigQuery

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

TrevorBergeron avatar Aug 05 '24 22:08 TrevorBergeron

Yep, the ability to do things that are only allowed on columns currently, but on scalars, comes up sometimes.

This seems like a reasonable request to me.

Implementation wise, it'll probably involve moving a handful of methods into the base Value class.

cpcloud avatar Aug 05 '24 23:08 cpcloud

@TrevorBergeron Do you have an example that demonstrates the difference in output SQL? It'd be good to know just how much worse it is before we go down this path.

cpcloud avatar Aug 07 '24 13:08 cpcloud