Skip to content

Conversation

@xiangfu0
Copy link
Contributor

@xiangfu0 xiangfu0 commented Jun 19, 2024

When literal arguments are singled quoted, it's parsed to WindowNode inputs, as a literal, not constants.

Sample query:

WITH tmp AS (
  select count(*) as num_trips,
    DaysSinceEpoch
  from airlineStats
  GROUP BY DaysSinceEpoch
)

SELECT DaysSinceEpoch,
  num_trips,
  LAG(num_trips, '2') OVER (
    ORDER BY DaysSinceEpoch
  ) AS previous_num_trips,
  num_trips - LAG(num_trips, '2') OVER (
    ORDER BY DaysSinceEpoch
  ) AS difference
FROM tmp;

Before:
image

Caused by: java.lang.IllegalArgumentException: Second operand (offset) of LAG function must be a literal
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
	at org.apache.pinot.query.runtime.operator.window.value.LagValueWindowFunction.<init>(LagValueWindowFunction.java:43)
	... 24 more

After:
image

@xiangfu0 xiangfu0 requested a review from Jackie-Jiang June 19, 2024 19:25
@xiangfu0 xiangfu0 merged commit a30c0cb into apache:master Jun 20, 2024
@xiangfu0 xiangfu0 deleted the single-quoted-literal-window branch June 20, 2024 17:27
suyashpatel98 pushed a commit to suyashpatel98/pinot that referenced this pull request Jul 6, 2024
@yashmayya yashmayya added the window-functions Related to SQL window functions on the multi-stage query engine label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix window-functions Related to SQL window functions on the multi-stage query engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants