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.
feat: derive monotonicity for date_truc with timezone when unit larger than day #20097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: derive monotonicity for date_truc with timezone when unit larger than day #20097
Changes from 1 commit
1fed4cc
c06b0c6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of the
const
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case SQL is standardized to use a language other than English in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just maintain it same as the expression's implementation
risingwave/src/expr/impl/src/scalar/date_trunc.rs
Lines 20 to 33 in c06b0c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean why not use those existing definition?
It doesn't make sense to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modification is a bit troublesome; we have to expose these const from a very deep level within expr... Since we might never modify it, I would rather make a copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could move these const from the deep mod into a upper layer, and import it in the original place. That should be easy to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am too lazy....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your brain will become rusty!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add an example to demonstrate the correctness?
What I can think of is like in a timezone with DST,
MM-dd 23:50:00
+ interval12 minutes
may beMM-dd 23:02:00
, while thedate_trunc('day', ...)
result beMM-dd 00:12:00
versusMM-dd (00:00:00)
. Seems this will break the correctness. Am I understanding it wrong?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it has all fields that are less significant than the selected one set to zero (or one, for day and month).
https://arc.net/l/quote/wfxyyukb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I know that.
I just got it. In my previous comment, I mixed
F(X + C)
withF(X) + C
. I think what we need to ensure here is that, ifX2 > X1
,F(X2) > F(X1)
, and vice versa. We don't need to compareF(X + C)
withF(X) + C
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related: #13201
In short:
redotz
boolean flag)date_trunc('day', x) > x
and the return value hashour != 0
There may be more tricky cases to think about carefully.
X2 > X1 implies F(X2) >= F(X1)
with the equal signF(X2) > F(X1) implies X2 > X1
by vice versa?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Thank for the
equal sign
though. To be clear, I think it should be:X2 >= X1
→F(X2) >= F(X1)
F(X2) >= F(X1)
→X2 >= X1
X2 <= X1
→F(X2) <= F(X1)
F(X2) <= F(X1)
→X2 <= X1
Only with the four all satisfied, we can say
F
maintains the monotonicity.