-
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] Fix temporal function tag application bug #2231
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d97347c
[query] Fix temporal function tag application bug
arnikola 75dd8ae
Merge branch 'master' into arnikola/temporal-tag-fix
arnikola e923e27
Print nan and inf points correctly
arnikola 39135b5
Fix remaining temporal function issues with added regression tests
arnikola 3ac2b69
Merge branch 'master' into arnikola/temporal-tag-fix
arnikola eaf1249
Update kubefile version
arnikola 2fcb4c2
Removed channel on execute expression
arnikola 0b0b1b7
Merge branch 'arnikola/temporal-tag-fix' of github.com:m3db/m3 into a…
arnikola e93b792
Merge branch 'master' into arnikola/temporal-tag-fix
arnikola 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2020 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The abovale copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package parser | ||
|
||
import ( | ||
"encoding/json" | ||
"math" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestElectionStateJSONMarshal(t *testing.T) { | ||
for _, input := range []struct { | ||
val Value | ||
str string | ||
}{ | ||
{val: 1231243.123123, str: `"1.231243123123e+06"`}, | ||
{val: 0.000000001, str: `"1e-09"`}, | ||
{val: Value(math.NaN()), str: `"NaN"`}, | ||
{val: Value(math.Inf(1)), str: `"+Inf"`}, | ||
{val: Value(math.Inf(-1)), str: `"-Inf"`}, | ||
} { | ||
b, err := json.Marshal(input.val) | ||
require.NoError(t, err) | ||
assert.Equal(t, input.str, string(b)) | ||
|
||
var val Value | ||
json.Unmarshal([]byte(input.str), &val) | ||
if math.IsNaN(float64(input.val)) { | ||
assert.True(t, math.IsNaN(float64(val))) | ||
} else if math.IsInf(float64(input.val), 1) { | ||
assert.True(t, math.IsInf(float64(val), 1)) | ||
} else if math.IsInf(float64(input.val), -1) { | ||
assert.True(t, math.IsInf(float64(val), -1)) | ||
} else { | ||
assert.Equal(t, input.val, val) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -22,24 +22,83 @@ package block | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
"github.com/m3db/m3/src/query/cost" | ||
"github.com/m3db/m3/src/query/models" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/uber-go/tally" | ||
) | ||
|
||
func TestColumnBuilderInfoTypes(t *testing.T) { | ||
ctx := models.NewQueryContext(context.Background(), | ||
tally.NoopScope, cost.NoopChainedEnforcer(), | ||
models.QueryContextOptions{}) | ||
var ctx = models.NewQueryContext(context.Background(), | ||
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. super nit: Maybe make this a method? In case contexts conflict across tests? |
||
tally.NoopScope, cost.NoopChainedEnforcer(), | ||
models.QueryContextOptions{}) | ||
|
||
func TestColumnBuilderInfoTypes(t *testing.T) { | ||
builder := NewColumnBlockBuilder(ctx, Metadata{}, []SeriesMeta{}) | ||
block := builder.Build() | ||
assert.Equal(t, BlockDecompressed, block.Info().blockType) | ||
|
||
block = builder.BuildAsType(BlockScalar) | ||
assert.Equal(t, BlockScalar, block.Info().blockType) | ||
} | ||
|
||
func TestSetRow(t *testing.T) { | ||
buildMeta := func(i int) SeriesMeta { | ||
name := fmt.Sprint(i) | ||
|
||
return SeriesMeta{ | ||
Name: []byte(name), | ||
Tags: models.MustMakeTags("name", name), | ||
} | ||
} | ||
|
||
size := 10 | ||
metas := make([]SeriesMeta, size) | ||
for i := range metas { | ||
metas[i] = buildMeta(i) | ||
} | ||
|
||
builder := NewColumnBlockBuilder(ctx, Metadata{ | ||
Bounds: models.Bounds{StepSize: time.Minute, Duration: time.Minute}, | ||
}, metas) | ||
|
||
require.NoError(t, builder.AddCols(1)) | ||
builder.PopulateColumns(size) | ||
// NB: set the row metas backwards. | ||
j := 0 | ||
for i := size - 1; i >= 0; i-- { | ||
err := builder.SetRow(j, []float64{float64(i)}, metas[i]) | ||
require.NoError(t, err) | ||
j++ | ||
} | ||
|
||
bl := builder.Build() | ||
it, err := bl.StepIter() | ||
require.NoError(t, err) | ||
|
||
actualMetas := it.SeriesMeta() | ||
for i, m := range actualMetas { | ||
ex := fmt.Sprint(size - 1 - i) | ||
assert.Equal(t, ex, string(m.Name)) | ||
require.Equal(t, 1, m.Tags.Len()) | ||
tag, found := m.Tags.Get([]byte("name")) | ||
require.True(t, found) | ||
assert.Equal(t, ex, string(tag)) | ||
} | ||
|
||
assert.True(t, it.Next()) | ||
exVals := make([]float64, size) | ||
for i := range exVals { | ||
exVals[i] = float64(size - 1 - i) | ||
} | ||
|
||
vals := it.Current().Values() | ||
assert.Equal(t, exVals, vals) | ||
assert.False(t, it.Next()) | ||
assert.NoError(t, it.Err()) | ||
} |
Oops, something went wrong.
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.
Should we add test coverage that this is always size of cols now? Seems like was just missing before?
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.
Yeah, luckily the new test fails without this statement 👍