-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add sql + ingestion compatibility for first/last on numeric values #15607
Merged
LakshSingla
merged 5 commits into
apache:master
from
ankit0811:feature_sql_compatibility_last_first_numeric_value
Jan 10, 2024
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a0667d
add sql compatibility for first/last on numeric values
ankit0811 18a479f
update test cases
ankit0811 fda6b26
update test cases
ankit0811 de6e912
update metric-spec.tsx to support string first/last agg
ankit0811 b5294a3
addressing comments + add more test case
ankit0811 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,12 @@ const KNOWN_TYPES = [ | |
'longMax', | ||
'doubleMax', | ||
'floatMax', | ||
'longFirst', | ||
'longLast', | ||
'doubleFirst', | ||
'doubleLast', | ||
'floatFirst', | ||
'floatLast', | ||
'stringFirst', | ||
'stringLast', | ||
'thetaSketch', | ||
|
@@ -97,10 +103,14 @@ export const METRIC_SPEC_FIELDS: Field<MetricSpec>[] = [ | |
group: 'max', | ||
suggestions: ['longMax', 'doubleMax', 'floatMax'], | ||
}, | ||
// Do not show first and last aggregators as they can not be used in ingestion specs and this definition is only used in the data loader. | ||
// Ref: https://druid.apache.org/docs/latest/querying/aggregations.html#first--last-aggregator | ||
// Should the first / last aggregators become usable at ingestion time, reverse the changes made in: | ||
// https://github.com/apache/druid/pull/10794 | ||
{ | ||
group: 'first', | ||
suggestions: ['longFirst', 'doubleFirst', 'floatFirst', 'stringFirst'], | ||
}, | ||
{ | ||
group: 'last', | ||
suggestions: ['longLast', 'doubleLast', 'floatLast', 'stringLast'], | ||
}, | ||
'thetaSketch', | ||
'arrayOfDoublesSketch', | ||
{ | ||
|
@@ -129,6 +139,14 @@ export const METRIC_SPEC_FIELDS: Field<MetricSpec>[] = [ | |
'longMax', | ||
'doubleMax', | ||
'floatMax', | ||
'longFirst', | ||
'longLast', | ||
'doubleFirst', | ||
'doubleLast', | ||
'floatFirst', | ||
'floatLast', | ||
'stringFirst', | ||
'stringLast', | ||
Comment on lines
+142
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this change isn't required. |
||
'thetaSketch', | ||
'arrayOfDoublesSketch', | ||
'HLLSketchBuild', | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? Shouldn't we be returning the scalar return type then? Why are we not doing this for string as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return the same for String but since its return type is already string which is handled in the below if condition, I dint bother changing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT LATEST_BY("last_float_added", "__time") + 4.0 FROM "wikiticker_long_string_last_first"
This doesn't work because the return type is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the input type is complex, it should return the scalar value for that complex type (float for longFloatPair etc), else if the input is numeric, it should return that numeric type, else it should return varchar (in unknown complex, string and any other sql type cases)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this @LakshSingla
updated the PR