-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
changefeedccl: Add changefeed_creation_timestamp
function
#95179
Conversation
Bikeshed, I think |
203040f
to
5052438
Compare
easy enough to change -- done. |
changefeed_create_timestamp
functionchangefeed_creation_timestamp
function
Add `changefeed_creation_timestamp` function, which returns changefeed creation timestamp. Changefeed transformations restrict access to some of the standard functions, including `now()`. Without such function, it is difficult to express changefeeds that want to emit events restricted by time. This function makes it possible to do this. For example, to create a changefeed that emits events from the `accounts` table that `last_withdrawal` happen starting 12 hours ago, one could do: ``` CREATE CHANGEFEED ... AS SELECT * FROM accounts WHERE last_withdrawal > changefeed_creation_timestamp() - interval '12 hours' ``` Epic: CRDB-17161 Release note (enterprise change): Changefeed expressions support `changefeed_created_timestamp` function.
5052438
to
6b2207e
Compare
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.
Maybe cdc_now_timestamp()
or cdc_now()
aligns better with the other cdc internal thing we have (cdc_prev
). Also, using now
somewhere in the name aligns more with the standard now()
fn.
Reviewed 5 of 6 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @miretskiy)
pkg/ccl/changefeedccl/cdceval/expr_eval.go
line 115 at r1 (raw file):
rowCh: make(chan tree.Datums, 1), } e.rowEvalCtx.startTime = statementTS
It would be a neater to make a constructor for rowEvalCtx
which does this.
pkg/ccl/changefeedccl/cdceval/expr_eval.go
line 452 at r1 (raw file):
func (e *familyEvaluator) setupContextForRow(ctx context.Context, updated cdcevent.Row) error { e.rowEvalCtx.ctx = ctx e.rowEvalCtx.updatedRow = updated
Consider putting these lines in a function func (rec *rowEvalContext) updateForRow(ctx context.Context, updated cdcevent.Row)
.
Code quote:
e.rowEvalCtx.ctx = ctx
e.rowEvalCtx.updatedRow = updated
pkg/ccl/changefeedccl/cdceval/functions.go
line 133 at r1 (raw file):
"changefeed_creation_timestamp": cdcTimestampBuiltin( "changefeed_creation_timestamp", "Returns changefeed creation time",
nit: transaction timestamp
or timestamp
would be more clear.
Code quote:
eturns changefeed creation time
bors r+ |
Build succeeded: |
Add
changefeed_create_timestamp
function, which returns changefeed creation timestamp.Changefeed transformations restrict access to some of the standard functions, including
now()
.Without such function, it is difficult to express
changefeeds that want to emit events restricted
by time. This function makes it possible to do
this. For example, to create a changefeed that
emits events from the
accounts
table thatlast_withdrawal
happen starting 12 hours ago,one could do:
Epic: CRDB-17161
Release note (enterprise change): Changefeed expressions support
changefeed_create_timestamp
function.