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

fixing the single quoted literal in window function #13441

Merged
merged 1 commit into from
Jun 20, 2024

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 merged commit a30c0cb into apache:master Jun 20, 2024
20 checks passed
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants