-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Sink): support redis sink (#11999)
- Loading branch information
Showing
16 changed files
with
731 additions
and
86 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Demo: Sinking to Redis | ||
|
||
In this demo, we want to showcase how RisingWave is able to sink data to Redis. | ||
|
||
1. Launch the cluster: | ||
|
||
```sh | ||
docker compose up -d | ||
``` | ||
|
||
The cluster contains a RisingWave cluster and its necessary dependencies, a datagen that generates the data, a Redis for sink. | ||
|
||
|
||
2. Execute the SQL queries in sequence: | ||
|
||
- create_source.sql | ||
- create_mv.sql | ||
- create_sink.sql | ||
|
||
3. Execute a simple query: | ||
|
||
```sh | ||
docker compose exec redis redis-ctl keys * | ||
|
||
``` | ||
We also can use 'get' to query value | ||
|
||
```sql | ||
select user_id, count(*) from default.demo_test group by user_id | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE MATERIALIZED VIEW bhv_mv AS | ||
SELECT | ||
user_id, | ||
target_id, | ||
event_timestamp | ||
FROM | ||
user_behaviors; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CREATE SINK bhv_redis_sink_1 | ||
FROM | ||
bhv_mv WITH ( | ||
primary_key = 'user_id', | ||
connector = 'redis', | ||
type = 'append-only', | ||
force_append_only='true', | ||
redis.url= 'redis://127.0.0.1:6379/', | ||
); | ||
|
||
CREATE SINK bhv_redis_sink_2 | ||
FROM | ||
bhv_mv WITH ( | ||
primary_key = 'user_id', | ||
connector = 'redis', | ||
type = 'append-only', | ||
force_append_only='true', | ||
redis.url= 'redis://127.0.0.1:6379/', | ||
redis.keyformat='user_id:{user_id}', | ||
redis.valueformat='username:{username},event_timestamp{event_timestamp}' | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE table user_behaviors ( | ||
user_id INT, | ||
target_id VARCHAR, | ||
target_type VARCHAR, | ||
event_timestamp TIMESTAMP, | ||
behavior_type VARCHAR, | ||
parent_target_type VARCHAR, | ||
parent_target_id VARCHAR, | ||
PRIMARY KEY(user_id) | ||
) WITH ( | ||
connector = 'datagen', | ||
fields.user_id.kind = 'sequence', | ||
fields.user_id.start = 1, | ||
fields.user_id.end = 100, | ||
datagen.rows.per.second = '100' | ||
) FORMAT PLAIN ENCODE JSON; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
version: "3" | ||
services: | ||
redis: | ||
image: 'redis:latest' | ||
expose: | ||
- 6379 | ||
healthcheck: | ||
test: ["CMD", "redis-cli", "ping"] | ||
interval: 5s | ||
timeout: 30s | ||
retries: 50 | ||
compactor-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: compactor-0 | ||
compute-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: compute-node-0 | ||
etcd-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: etcd-0 | ||
frontend-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: frontend-node-0 | ||
grafana-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: grafana-0 | ||
meta-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: meta-node-0 | ||
minio-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: minio-0 | ||
prometheus-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: prometheus-0 | ||
message_queue: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: message_queue | ||
datagen: | ||
build: ../datagen | ||
depends_on: [message_queue] | ||
command: | ||
- /bin/sh | ||
- -c | ||
- /datagen --mode clickstream --qps 2 kafka --brokers message_queue:29092 | ||
restart: always | ||
container_name: datagen | ||
volumes: | ||
compute-node-0: | ||
external: false | ||
etcd-0: | ||
external: false | ||
grafana-0: | ||
external: false | ||
minio-0: | ||
external: false | ||
prometheus-0: | ||
external: false | ||
message_queue: | ||
external: false | ||
name: risingwave-compose |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.