-
Notifications
You must be signed in to change notification settings - Fork 590
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
feat(sink): use 'create sink ... format ... encode' to create redis sink #13003
Conversation
fix use string for timestamp
ed5498a
to
c8d0223
Compare
Codecov Report
@@ Coverage Diff @@
## main #13003 +/- ##
==========================================
+ Coverage 68.76% 68.78% +0.01%
==========================================
Files 1496 1496
Lines 250508 250555 +47
==========================================
+ Hits 172268 172343 +75
+ Misses 78240 78212 -28
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 11 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if matches!( | ||
self.format_desc.encode, | ||
super::catalog::SinkEncode::Template | ||
) { |
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.
Let's move check_string_format
as part of TemplateEncoder::new
, and just call SinkFormatterImpl::new_with_redis
here.
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.
We should be calling TemplateEncoder::new multiple times during the data injection process, but we only need to check the format when creating the sink. So, it might be more appropriate to place it outside.
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 is called once per actor, and you are right we only need to check the format once. My point was about TemplateEncoder
being self-contained. At least we can move the function definition into the TemplateEncoder
file.
For more context, proto / avro is doing heavier work in SinkFormatterImpl::new
, and we have opened an issue to discuss whether to optimize it from once-per-actor to only once on meta #12982
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.
May need to decide the name of this format from product's perspective. The name in current PR is TEMPLATE
cc @neverchanje .
)FORMAT PLAIN ENCODE TEMPLATE(force_append_only='true', redis_key_format = 'UserID:{user_id}', redis_value_format = 'TargetID:{target_id},EventTimestamp{event_timestamp}'); |
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.
May not add force_append_only='true'
here?
And may not have the redis_
prefix for both key_format and value_format.
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.
tried it, but without it, success cannot be achieved
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, for the SQL syntax, we should put the force_append_only
in the WITH
part of the SQL rather than in the properties of encoder.
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, for the SQL syntax, we should put the
force_append_only
in theWITH
part of the SQL rather than in the properties of encoder.
cc @xiangjinwu
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 is part of format plain
, so placed after it.
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.
force_append_only
is derived in frontend and stored as SinkType
separately in SinkDesc, and before the formatter, the sink executor will remove the delete and upsert delete when force_append_only
is true. And in the code of frontend, force_append_only
is derived only by the with options. Should we fix this? @xiangjinwu
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.
force_append_only
is derived only by the with options
Check line 236-245 below. It has been updated.
Regarding SinkType
, I actually plan to rename it to AppendOnlyState = [APPEND_ONLY, FORCE_APPEND_ONLY, NOT_APPEND_ONLY]
, given its current actual functionality is not aligned with type =
in old syntax / format
in new syntax. Its name has been confusing.
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 see. Good to know that.
de0df1e
to
712042e
Compare
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
use 'create sink ... format ... encode' to create redis sink like kafka.
And add Template encode to support custom format for strings input into redis
Checklist
Documentation
Release note
create table
create redis sink with append_only and json
create redis sink with upsert and json
create redis sink with append_only and template
create redis sink with upsert and template