-
Notifications
You must be signed in to change notification settings - Fork 591
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): Support Mongodb sink #17102
Merged
Merged
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8a9e865
save work
ly9chee b307b1a
save work
ly9chee 861a654
save work
ly9chee 2fda3b7
save work
ly9chee e23c399
Merge branch 'mongodb-sink' of https://github.com/ly9chee/risingwave …
ly9chee 1901d80
add e2e tests
ly9chee d5d799c
fix e2e tests
ly9chee a1763b8
update Cargo.lock
ly9chee 4c36a53
merge main
ly9chee 2404c76
fix fmt
ly9chee 63bc960
fix dylint
ly9chee 05a186a
merge pk checking logic
ly9chee 27bb797
support compound pk & fix upsert
ly9chee 4c87a9b
fix fmt
ly9chee c7d9151
moving encoding logic to bson.rs & minor refactors
ly9chee e5f7ad0
add license header
ly9chee 73c88e0
Merge branch 'main' into mongodb-sink
ly9chee 7c4ad31
warning when non-insert op received in append-only mode
ly9chee 2d413a7
refactor is_append_only dispatching logic
ly9chee b461ce3
add comment for MONGODB_BULK_WRITE_SIZE_LIMIT
ly9chee b8ec448
Merge branch 'main' into mongodb-sink
wenym1 6e9d968
remove preserve_order from serde_json introduced by bson
ly9chee 623c7e4
Merge branch 'mongodb-sink' of https://github.com/ly9chee/risingwave …
ly9chee de04e01
Merge branch 'main' into mongodb-sink
wenym1 19e43b2
Merge branch 'main' into mongodb-sink
ly9chee 90bc3f3
fix lint
ly9chee d3d31db
Merge branch 'main' into mongodb-sink
ly9chee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exits as soon as any line fails. | ||
set -euo pipefail | ||
|
||
source ci/scripts/common.sh | ||
|
||
while getopts 'p:' opt; do | ||
case ${opt} in | ||
p ) | ||
profile=$OPTARG | ||
;; | ||
\? ) | ||
echo "Invalid Option: -$OPTARG" 1>&2 | ||
exit 1 | ||
;; | ||
: ) | ||
echo "Invalid option: $OPTARG requires an argument" 1>&2 | ||
;; | ||
esac | ||
done | ||
shift $((OPTIND -1)) | ||
|
||
download_and_prepare_rw "$profile" source | ||
|
||
echo "--- starting risingwave cluster" | ||
cargo make ci-start ci-sink-test | ||
sleep 1 | ||
|
||
# install the mongo shell | ||
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb | ||
wget https://repo.mongodb.org/apt/ubuntu/dists/focal/mongodb-org/4.4/multiverse/binary-amd64/mongodb-org-shell_4.4.28_amd64.deb | ||
dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb | ||
dpkg -i mongodb-org-shell_4.4.28_amd64.deb | ||
|
||
echo '> ping mongodb' | ||
echo 'db.runCommand({ping: 1})' | mongo mongodb://mongodb:27017 | ||
echo '> rs config' | ||
echo 'rs.conf()' | mongo mongodb://mongodb:27017 | ||
echo '> run mongodb sink test..' | ||
|
||
sqllogictest -p 4566 -d dev './e2e_test/sink/mongodb_sink.slt' | ||
sleep 1 | ||
|
||
append_only_result=$(mongo mongodb://mongodb:27017 --eval 'db.getSiblingDB("demo").t1.countDocuments({})' | tail -n 1) | ||
if [ "$append_only_result" != "1" ]; then | ||
echo "The append-only output is not as expected." | ||
exit 1 | ||
fi | ||
|
||
upsert_and_dynamic_coll_result1=$(mongo mongodb://mongodb:27017 --eval 'db.getSiblingDB("demo").t2.countDocuments({})' | tail -n 1) | ||
if [ "$upsert_and_dynamic_coll_result1" != "1" ]; then | ||
echo "The upsert output is not as expected." | ||
exit 1 | ||
fi | ||
|
||
upsert_and_dynamic_coll_result2=$(mongo mongodb://mongodb:27017 --eval 'db.getSiblingDB("shard_2024_01").tenant_1.countDocuments({})' | tail -n 1) | ||
if [ "$upsert_and_dynamic_coll_result2" != "1" ]; then | ||
echo "The upsert output is not as expected." | ||
exit 1 | ||
fi | ||
|
||
compound_pk_result=$(mongo mongodb://mongodb:27017 --eval 'db.getSiblingDB("demo").t3.countDocuments({})' | tail -n 1) | ||
if [ "$compound_pk_result" != "1" ]; then | ||
echo "The upsert output is not as expected." | ||
exit 1 | ||
fi | ||
|
||
echo "Mongodb sink check passed" | ||
|
||
echo "--- Kill cluster" | ||
risedev ci-kill |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
statement ok | ||
create table t1( | ||
a smallint, | ||
b int, | ||
c bigint, | ||
d rw_int256, | ||
e real, | ||
f double precision, | ||
g varchar, | ||
h bytea, | ||
i date, | ||
j time, | ||
k timestamp, | ||
l timestamptz, | ||
m interval, | ||
n STRUCT <b STRUCT<c INTEGER>, d INTEGER>, | ||
o varchar[], | ||
p jsonb | ||
) append only; | ||
|
||
statement ok | ||
create sink t1_sink from t1 | ||
with ( | ||
connector='mongodb', | ||
type = 'append-only', | ||
mongodb.url = 'mongodb://mongodb:27017/?replicaSet=rs0', | ||
collection.name = 'demo.t1', | ||
mongodb.bulk_write.max_entries = '1024' | ||
); | ||
|
||
statement ok | ||
insert into t1 values(1, 2, 3, 4, 5.0, 6.0, '7', '\xDe00BeEf', date '2022-04-08', time '18:20:49', | ||
'2022-03-13 01:00:00'::timestamp, '2022-03-13 01:00:00Z'::timestamptz, interval '4 hour', | ||
ROW(ROW(8), 9), ARRAY['a', 'b', 'c'], '{"a": [{"b": 1}], "c": true}'::jsonb); | ||
|
||
statement ok | ||
create table t2( | ||
_id bigint primary key, | ||
collection_name varchar, | ||
value varchar | ||
); | ||
|
||
statement ok | ||
create sink t2_sink from t2 | ||
with ( | ||
connector='mongodb', | ||
type = 'upsert', | ||
mongodb.url = 'mongodb://mongodb:27017/?replicaSet=rs0', | ||
collection.name = 'demo.t2', | ||
mongodb.bulk_write.max_entries = '1024', | ||
collection.name.field = 'collection_name', | ||
collection.name.field.drop = 'true', | ||
primary_key='_id' | ||
); | ||
|
||
statement ok | ||
insert into t2 values(1, 'shard_2024_01.tenant_1', 'data'); | ||
|
||
statement ok | ||
insert into t2 values(2, '', 'data'); | ||
|
||
statement ok | ||
create table t3( | ||
a int, | ||
b int, | ||
value text, | ||
primary key (a,b) | ||
); | ||
|
||
statement ok | ||
create sink t3_sink from t3 | ||
with ( | ||
connector='mongodb', | ||
type = 'upsert', | ||
mongodb.url = 'mongodb://mongodb:27017/?replicaSet=rs0', | ||
collection.name = 'demo.t3', | ||
mongodb.bulk_write.max_entries = '1024', | ||
primary_key='a,b' | ||
); | ||
|
||
statement ok | ||
delete from t3 where a = 1 and b = 2; | ||
|
||
statement ok | ||
insert into t3 values(1, 2, 'abc'); | ||
|
||
statement ok | ||
FLUSH; | ||
|
||
statement ok | ||
DROP SINK t1_sink; | ||
|
||
statement ok | ||
DROP TABLE t1; | ||
|
||
statement ok | ||
DROP SINK t2_sink; | ||
|
||
statement ok | ||
DROP TABLE t2; | ||
|
||
statement ok | ||
DROP SINK t3_sink; | ||
|
||
statement ok | ||
DROP TABLE t3; |
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.
Oops, something went wrong.
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.
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.
Please revert these unintended changes, maybe by your formatter.