Repository navigation
fix bucket() returning constant values unchanged - #7713
Merged
Merged
Conversation
mattnibs
approved these changes
Nov 23, 2026
nwt
reviewed
Nov 23, 2026
| typ := b.resultType(tsVec) | ||
| ts := vector.IntValue(tsVec, 0) | ||
| ts := int64(nano.Ts(vector.IntValue(tsVec, 0)).Trunc(bin)) | ||
| return vector.NewConstInt(typ, ts, tsVec.Len()) |
Collaborator
There was a problem hiding this comment.
return vector.NewConst(b.constBinFlat(tsVec.Any, bin), tsVec.Len())
Contributor
Author
There was a problem hiding this comment.
Thanks @nwt. I went with your suggestion.
bucket() returned a constant vector's value without truncating it, so a literal, a BSUP column whose frame has the same value in every row, or a SQL cast of a constant to DATE wasn't truncated. Truncate it like the other cases.
philrz
force-pushed
the
bucket-const-vector
branch
from
November 23, 2026 23:13
47c2b69 to
d6e612b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
bucket()returned its first argument unchanged, not rounded down to the bucket, whenever that argument was a constant vector. That happens for a literal or other constant expression, and for a column in a BSUP file when a frame holds the same value in every row. So, e.g., bucketing the timestamps in such a file by1dreturned the original timestamps. A SQLCAST(... AS DATE)of a constant, which usesbucket(), kept its time of day the same way. The constant case now truncates like the others.Trying it out
On current tip of
main, commit 85073ef:On this branch, commit d6e612b:
Testing
bucket.yamlbucket a constant timestamp and a constant duration, and cast a constant timestamp toDATEin SQL. Both fail onmain.make test-unit,make test-systemand the book's mdtests pass.I found this while checking the function docs against
main. It's a regression: the truncation was dropped from the constant case in #6723, and it became visible when #7072 moved constant expressions to the vector runtime and #7105 changed how files named on the command line are read.v0.3.0gives the right answers for both commands above.