mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
fixes #1823. Updates tests and docs for row range
This commit is contained in:
parent
01f54c1f70
commit
9f6d489be8
4 changed files with 29 additions and 9 deletions
|
|
@ -341,13 +341,12 @@ Row(stargazer=1)
|
|||
**Spec:**
|
||||
|
||||
```
|
||||
Row(<FIELD>=<ROW>, <TIMESTAMP>, <TIMESTAMP>)
|
||||
Row(<FIELD>=<ROW>, from=<TIMESTAMP>, to=<TIMESTAMP>)
|
||||
```
|
||||
|
||||
**Description:**
|
||||
|
||||
Similar to `Row`, but only returns bits which were set with timestamps
|
||||
between the given `start` (first) and `end` (second) timestamps.
|
||||
Similar to `Row`, but only returns bits which were set with timestamps between the given `from` (inclusive) and `to` (exclusive) timestamps. Both `from` and `to` parameters are optional. The default for `to` timestamp is current time + 1 day. If a later end timestamp is required, specify it explicitly.
|
||||
|
||||
**Result Type:** object with attrs and bits
|
||||
|
||||
|
|
@ -356,7 +355,7 @@ between the given `start` (first) and `end` (second) timestamps.
|
|||
|
||||
Query all columns with a bit set in row 1 of a field (repositories that a user has starred), within a date range:
|
||||
```request
|
||||
Row(stargazer=1, 2010-01-01T00:00, 2017-03-02T03:00)
|
||||
Row(stargazer=1, from='2010-01-01T00:00', to='2017-03-02T03:00')
|
||||
```
|
||||
```response
|
||||
{{"attrs":{},"columns":[10]}
|
||||
|
|
@ -836,7 +835,7 @@ GroupBy(<RowsCall>, [RowsCall...], limit=<UINT>, filter=<CALL>)
|
|||
|
||||
GroupBy returns the count of the intersection of every combination of rows
|
||||
taking one row each from the specified `Rows` calls. It returns only those
|
||||
combinations for which the count is greater than 0.
|
||||
combinations for which the count is greater than 0.
|
||||
|
||||
The optional `filter` argument takes any type of `Row` query (e.g. Row, Union,
|
||||
Intersect, etc.) which will be intersected with each result prior to returning
|
||||
|
|
|
|||
|
|
@ -1253,9 +1253,8 @@ func (e *executor) executeRowShard(ctx context.Context, index string, c *pql.Cal
|
|||
// Set maximum "to" value if only "from" is set. We don't need to worry
|
||||
// about setting the minimum "from" since it is the zero value if omitted.
|
||||
if toTime.IsZero() {
|
||||
// This is the maximum comparable time.Time value.
|
||||
// https://stackoverflow.com/a/32620397
|
||||
toTime = time.Unix(1<<63-62135596801, 999999999)
|
||||
// Set the end timestamp to current time + 1 day, in order to account for timezone differences.
|
||||
toTime = time.Now().AddDate(0, 0, 1)
|
||||
}
|
||||
|
||||
// Union bitmaps across all time-based views.
|
||||
|
|
|
|||
|
|
@ -1493,6 +1493,8 @@ func TestExecutor_Execute_Row_Range(t *testing.T) {
|
|||
Set(2, f=10, 2001-01-01T00:00)`
|
||||
readQueries := []string{
|
||||
`Row(f=1, from=1999-12-31T00:00, to=2002-01-01T03:00)`,
|
||||
`Row(f=1, from=1999-12-31T00:00)`,
|
||||
`Row(f=1, to=2002-01-01T02:00)`,
|
||||
`Clear( 2, f=1)`,
|
||||
`Row(f=1, from=1999-12-31T00:00, to=2002-01-01T03:00)`,
|
||||
}
|
||||
|
|
@ -1505,8 +1507,20 @@ func TestExecutor_Execute_Row_Range(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("From", func(t *testing.T) {
|
||||
if columns := responses[1].Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{2, 3, 4, 5, 6, 7}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("To", func(t *testing.T) {
|
||||
if columns := responses[2].Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{2, 3, 4, 5, 6}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Clear", func(t *testing.T) {
|
||||
if columns := responses[2].Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{3, 4, 5, 6, 7}) {
|
||||
if columns := responses[4].Results[0].(*pilosa.Row).Columns(); !reflect.DeepEqual(columns, []uint64{3, 4, 5, 6, 7}) {
|
||||
t.Fatalf("unexpected columns: %+v", columns)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -248,6 +248,14 @@ func TestPEGWorking(t *testing.T) {
|
|||
name: "RangeTimeQuotes",
|
||||
input: `Row(a=4, from='2010-07-04T00:00', to="2010-08-04T00:00")`,
|
||||
ncalls: 1},
|
||||
{
|
||||
name: "RangeTimeFromQuotes",
|
||||
input: `Row(a=4, from='2010-07-04T00:00')`,
|
||||
ncalls: 1},
|
||||
{
|
||||
name: "RangeTimeToQuotes",
|
||||
input: `Row(a=4, to="2010-08-04T00:00")`,
|
||||
ncalls: 1},
|
||||
{
|
||||
name: "Dashed Frame",
|
||||
input: "Set(1, my-frame=9)",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue