-
Notifications
You must be signed in to change notification settings - Fork 454
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
[query] Implemented the Graphite interpolate
function
#2650
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
78e126f
Added Graphite's interpolate function
teddywahle 5283b93
Ran go fmt
teddywahle 49b56ee
Merge branch 'master' into graphite-interpolate
teddywahle 6b184e1
Merge branch 'master' into graphite-interpolate
teddywahle 1f9ce3a
Update src/query/graphite/native/builtin_functions.go
teddywahle db59583
Added i=0 test case
teddywahle c7a0a1d
added preceding NaNs test case
teddywahle c6d8c1b
Merge branch 'master' into graphite-interpolate
teddywahle 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1941,10 +1941,52 @@ func TestIntegral(t *testing.T) { | |
} | ||
} | ||
|
||
/* | ||
seriesList = self._gen_series_list_with_data(key='test',start=0,end=600,step=60,data=[None, 1, 2, 3, 4, 5, None, 6, 7, 8]) | ||
expected = [TimeSeries("integralByInterval(test,'2min')", 0, 600, 60, [0, 1, 2, 5, 4, 9, 0, 6, 7, 15])] | ||
*/ | ||
func TestInterpolate(t *testing.T) { | ||
ctx := common.NewTestContext() | ||
defer ctx.Close() | ||
|
||
tests := []struct { | ||
values []float64 | ||
output []float64 | ||
}{ | ||
{ | ||
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. nit: mind adding a test where there's more nans than limit, and maybe one with a bunch of preceeding nans (to flex the 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. added both |
||
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0}, | ||
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0}, | ||
}, | ||
{ | ||
[]float64{math.NaN(), 2.0, math.NaN(), 4.0, math.NaN(), 6.0, math.NaN(), 8.0, math.NaN(), 10.0, math.NaN(), 12.0, math.NaN(), 14.0, math.NaN(), 16.0, math.NaN(), 18.0, math.NaN(), 20.0}, | ||
[]float64{math.NaN(), 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0}, | ||
}, | ||
{ | ||
[]float64{1.0, 2.0, math.NaN(), math.NaN(), math.NaN(), 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, math.NaN(), math.NaN(), math.NaN()}, | ||
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, math.NaN(), math.NaN(), math.NaN()}, | ||
}, | ||
{ | ||
[]float64{1.0, 2.0, 3.0, 4.0, math.NaN(), 6.0, math.NaN(), math.NaN(), 9.0, 10.0, 11.0, math.NaN(), 13.0, math.NaN(), math.NaN(), math.NaN(), math.NaN(), 18.0, 19.0, 20.0}, | ||
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0}, | ||
}, | ||
{ | ||
[]float64{1.0, 2.0, math.NaN(), math.NaN(), math.NaN(), 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, math.NaN(), math.NaN()}, | ||
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, math.NaN(), math.NaN()}, | ||
}, | ||
} | ||
|
||
start := time.Now() | ||
step := 100 | ||
for _, test := range tests { | ||
input := []common.TestSeries{{"foo", test.values}} | ||
expected := []common.TestSeries{{"interpolate(foo)", test.output}} | ||
timeSeries := generateSeriesList(ctx, start, input, step) | ||
output, err := interpolate(ctx, singlePathSpec{ | ||
Values: timeSeries, | ||
}, | ||
-1) | ||
require.NoError(t, err) | ||
common.CompareOutputsAndExpected(t, step, start, | ||
expected, output.Values) | ||
} | ||
} | ||
|
||
func TestIntegralByInterval(t *testing.T) { | ||
ctx := common.NewTestContext() | ||
defer ctx.Close() | ||
|
@@ -3288,6 +3330,7 @@ func TestFunctionsRegistered(t *testing.T) { | |
"identity", | ||
"integral", | ||
"integralByInterval", | ||
"interpolate", | ||
"isNonNull", | ||
"keepLastValue", | ||
"legendValue", | ||
|
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.
nit: can we explicitly call out that it won't interpolate at the end or the start? Graphite isn't very clear on this in their docs but would be useful to have here
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.
added