mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-10 07:01:01 +00:00
Merge branch 'master' into paginate
This commit is contained in:
commit
9e69ee3534
2 changed files with 91 additions and 0 deletions
28
executor.go
28
executor.go
|
|
@ -1587,6 +1587,34 @@ type DistinctTimestamp struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
var _ proto.ToRowser = DistinctTimestamp{}
|
||||
|
||||
// ToRows implements the ToRowser interface.
|
||||
func (d DistinctTimestamp) ToRows(callback func(*proto.RowResponse) error) error {
|
||||
for _, ts := range d.Values {
|
||||
row := &proto.RowResponse{
|
||||
Headers: []*proto.ColumnInfo{
|
||||
{
|
||||
Name: d.Name,
|
||||
Datatype: "timestamp",
|
||||
},
|
||||
},
|
||||
Columns: []*proto.ColumnResponse{
|
||||
{
|
||||
ColumnVal: &proto.ColumnResponse_TimestampVal{
|
||||
TimestampVal: ts,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := callback(row); err != nil {
|
||||
return errors.Wrap(err, "calling callback")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Union returns the union of the values of `d` and `other`
|
||||
func (d *DistinctTimestamp) Union(other DistinctTimestamp) DistinctTimestamp {
|
||||
both := map[string]string{}
|
||||
|
|
|
|||
|
|
@ -8546,3 +8546,66 @@ func MinMaxTimestampNodeTester(t *testing.T, numNodes int) {
|
|||
t.Fatalf("incorrect max timestamp val. expected: %v, got %v\n", expected, min)
|
||||
}
|
||||
}
|
||||
|
||||
// DistinctTimestamp ToRows should properly encode the timestamp
|
||||
func TestDistinctTimestampToRows(t *testing.T) {
|
||||
d := pilosa.DistinctTimestamp{
|
||||
Values: []string{
|
||||
"2022-03-24T12:08:37Z",
|
||||
"2022-03-24T12:08:47Z",
|
||||
"2022-03-24T12:08:57Z",
|
||||
},
|
||||
Name: "timestamp",
|
||||
}
|
||||
|
||||
expectedHeaders := []*proto.ColumnInfo{
|
||||
{
|
||||
Name: d.Name,
|
||||
Datatype: "timestamp",
|
||||
},
|
||||
}
|
||||
expected := []*proto.RowResponse{
|
||||
{
|
||||
Headers: expectedHeaders,
|
||||
Columns: []*proto.ColumnResponse{
|
||||
{
|
||||
ColumnVal: &proto.ColumnResponse_TimestampVal{
|
||||
TimestampVal: "2022-03-24T12:08:37Z",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: expectedHeaders,
|
||||
Columns: []*proto.ColumnResponse{
|
||||
{
|
||||
ColumnVal: &proto.ColumnResponse_TimestampVal{
|
||||
TimestampVal: "2022-03-24T12:08:47Z",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Headers: expectedHeaders,
|
||||
Columns: []*proto.ColumnResponse{
|
||||
{
|
||||
ColumnVal: &proto.ColumnResponse_TimestampVal{
|
||||
TimestampVal: "2022-03-24T12:08:57Z",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
rows := []*proto.RowResponse{}
|
||||
d.ToRows(func(r *proto.RowResponse) error {
|
||||
rows = append(rows, r)
|
||||
return nil
|
||||
})
|
||||
|
||||
for i, row := range rows {
|
||||
if !reflect.DeepEqual(row, expected[i]) {
|
||||
t.Errorf("expected %v, got %v", expected[i], row)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue