Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

stats by do not support date_format function #1079

Open
chyun opened this issue Mar 24, 2021 · 3 comments
Open

stats by do not support date_format function #1079

chyun opened this issue Mar 24, 2021 · 3 comments
Labels
enhancement New feature or request PPL

Comments

@chyun
Copy link

chyun commented Mar 24, 2021

I input PPL "search source=210324|stats max(event_duration) by date_format(inbuilt_meta.log_timestamp, 'yyyy-MM-dd HH')".
Got the error
{ "error": { "reason": "Invalid Query", "details": "Failed to parse query due to offending symbol [date_format] at: 'search source=*210324*|stats max(event_duration) by date_format' <--- HERE... More details: Expecting tokens in {'D', '.', '', 'AVG', 'COUNT', 'MAX', 'MIN', 'SUM', 'FIRST', 'LAST', 'DATE', 'TIME', 'TIMESTAMP', ID, BQUOTA_STRING}",
"type": "SyntaxCheckException"
},
"status": 400
}`

It looks like stats by do not support very much function

@chyun
Copy link
Author

chyun commented Mar 24, 2021

I can use "search source=210324|fields event_duration, inbuilt_meta.log_timestamp|eval day_str=date_format(inbuilt_meta.log_timestamp, 'yyyy-MM-dd HH')" to get the right answer, but the method do not aggregate all of data, it just aggregate the head part of data

@dai-chen dai-chen added the PPL label Mar 24, 2021
@dai-chen
Copy link
Member

Thanks for reporting the issue! Investigating

@dai-chen
Copy link
Member

It seems BY clause only accepts field name: https://github.com/opendistro-for-elasticsearch/sql/blob/develop/ppl/src/main/antlr/OpenDistroPPLParser.g4#L107. We need to check if this can be enabled easily. For now, could you try to append stats to your eval command. Note that this may have performance issue on big data set. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request PPL
Projects
None yet
Development

No branches or pull requests

2 participants