Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions runtime/expr/function/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ func (b *Bucket) constBin(tsVec vector.Any, bin nano.Duration) vector.Any {
}
switch tsVec := tsVec.(type) {
case *vector.Const:
typ := b.resultType(tsVec)
ts := vector.IntValue(tsVec, 0)
return vector.NewConstInt(typ, ts, tsVec.Len())
return vector.NewConst(b.constBinFlat(tsVec.Any, bin), tsVec.Len())
case *vector.View:
return vector.NewView(b.constBinFlat(tsVec.Any, bin), tsVec.Index)
case *vector.Dict:
Expand Down
18 changes: 18 additions & 0 deletions runtime/ztests/expr/function/bucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@ output: |
null
error({message:"bucket: first argument is not a timestamp or duration",on:"foo"})
error({message:"bucket: second argument is not a duration",on:"bar"})

---

# Constant arguments take the constant-vector path.
spq: values bucket(2020-05-26T15:27:47Z, 1h), bucket(3s, 2s), bucket(2020-05-26T15:27:47Z, 0s)

output: |
2020-05-26T15:00:00Z
2s
2020-05-26T15:27:47Z

---

# A SQL cast of a constant to DATE truncates with bucket.
spq: SELECT CAST(TIMESTAMP '2020-05-26 15:27:47' AS DATE) AS d

output: |
{d:2020-05-26T00:00:00Z}
Loading