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

Cast with Alias is not recognized in group by #14590

Open
xiangfu0 opened this issue Dec 4, 2024 · 1 comment
Open

Cast with Alias is not recognized in group by #14590

xiangfu0 opened this issue Dec 4, 2024 · 1 comment

Comments

@xiangfu0
Copy link
Contributor

xiangfu0 commented Dec 4, 2024

Sampe query:

SELECT 
    CAST(DATE_TRUNC('day', CAST(DATETIMECONVERT(ts, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '1:MILLISECONDS') AS TIMESTAMP)) AS TIMESTAMP) AS day_epoch_ms,
    sum(met) AS "sumMet"
FROM mytable
GROUP BY 
    CAST(DATE_TRUNC('day', CAST(DATETIMECONVERT(ts, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '1:MILLISECONDS') AS TIMESTAMP)) AS TIMESTAMP)
ORDER BY 
    sum(met) DESC
LIMIT 10000;

Exception:

Error: {'errorCode': 150,
 'message': 'SQLParsingError:\n'
            'org.apache.pinot.sql.parsers.SqlCompilationException: '
            "'as(cast(datetrunc('day', cast(datetimeconvert(ts, "
            "'1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', "
            "'1:MILLISECONDS'), 'TIMESTAMP')), 'TIMESTAMP'), day_epoch_ms)' should "
            'appear in GROUP BY clause.\n'
@cutiepie-10
Copy link

cutiepie-10 commented Dec 16, 2024

Hi @xiangfu0 ,
May you please provide more info about the issue becuase I am getting correct output for similar query as above mentioned by you.
Screenshot from 2024-12-16 21-08-16

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

No branches or pull requests

2 participants