mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 12:27:52 +00:00
fix presentation of timestamps from a groupby pql call
This commit is contained in:
parent
96dfe845d3
commit
9e570c9e84
2 changed files with 17 additions and 6 deletions
17
executor.go
17
executor.go
|
|
@ -3064,10 +3064,11 @@ func applyLimitAndOffsetToGroupByResult(c *pql.Call, results []GroupCount) ([]Gr
|
|||
|
||||
// FieldRow is used to distinguish rows in a group by result.
|
||||
type FieldRow struct {
|
||||
Field string `json:"field"`
|
||||
RowID uint64 `json:"rowID"`
|
||||
RowKey string `json:"rowKey,omitempty"`
|
||||
Value *int64 `json:"value,omitempty"`
|
||||
Field string `json:"field"`
|
||||
RowID uint64 `json:"rowID"`
|
||||
RowKey string `json:"rowKey,omitempty"`
|
||||
Value *int64 `json:"value,omitempty"`
|
||||
FieldOptions *FieldOptions `json:"-"`
|
||||
}
|
||||
|
||||
func (fr *FieldRow) Clone() (clone *FieldRow) {
|
||||
|
|
@ -3081,6 +3082,11 @@ func (fr *FieldRow) Clone() (clone *FieldRow) {
|
|||
v := *fr.Value
|
||||
clone.Value = &v
|
||||
}
|
||||
if fr.FieldOptions != nil {
|
||||
// deep copy, for Extra Safety
|
||||
v := *fr.FieldOptions
|
||||
clone.FieldOptions = &v
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -7738,6 +7744,8 @@ func newGroupByIterator(executor *executor, qcx *Qcx, rowIDs []RowIDs, children
|
|||
return nil, newNotFoundError(ErrFieldNotFound, fieldName)
|
||||
}
|
||||
gbi.fields[i].Field = fieldName
|
||||
options := field.Options()
|
||||
gbi.fields[i].FieldOptions = &options
|
||||
|
||||
switch field.Type() {
|
||||
case FieldTypeSet, FieldTypeMutex, FieldTypeBool:
|
||||
|
|
@ -7971,7 +7979,6 @@ func (gbi *groupByIterator) Next(ctx context.Context) (ret GroupCount, done bool
|
|||
ret.Group = make([]FieldRow, len(gbi.rows))
|
||||
copy(ret.Group, gbi.fields)
|
||||
for i, r := range gbi.rows {
|
||||
|
||||
ret.Group[i].RowID = r.id
|
||||
ret.Group[i].Value = r.value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,7 +331,11 @@ func pgWriteGroupCount(w pg.QueryResultWriter, counts *pilosa.GroupCounts) error
|
|||
var v string
|
||||
switch {
|
||||
case g.Value != nil:
|
||||
v = strconv.FormatInt(*g.Value, 10)
|
||||
if g.FieldOptions.Type == pilosa.FieldTypeTimestamp {
|
||||
v = time.Unix(0, (int64(*g.Value)+int64(g.FieldOptions.Base))*pilosa.TimeUnitNanos(g.FieldOptions.TimeUnit)).UTC().Format(time.RFC3339Nano)
|
||||
} else {
|
||||
v = strconv.FormatInt(*g.Value, 10)
|
||||
}
|
||||
case g.RowKey != "":
|
||||
v = g.RowKey
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue