-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mqtt): Allow using field as topic name (#15673)
- Loading branch information
Showing
12 changed files
with
582 additions
and
62 deletions.
There are no files selected for viewing
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,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
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 | ||
|
||
set -euo pipefail | ||
|
||
echo "--- testing mqtt sink" | ||
sqllogictest -p 4566 -d dev './e2e_test/sink/mqtt_sink.slt' | ||
|
||
sleep 1 | ||
|
||
echo "--- Kill cluster" | ||
cargo make 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,115 @@ | ||
statement ok | ||
CREATE TABLE mqtt ( | ||
device_id varchar, | ||
temperature double, | ||
topic varchar as '/device/' || device_id | ||
); | ||
|
||
statement ok | ||
CREATE TABLE mqtt_nested ( | ||
info struct<device_id varchar, topic varchar>, | ||
temperature double | ||
); | ||
|
||
statement ok | ||
CREATE SINK mqtt_sink | ||
FROM | ||
mqtt | ||
WITH | ||
( | ||
connector='mqtt', | ||
url='tcp://mqtt-server', | ||
type = 'append-only', | ||
topic.field = 'topic', | ||
retain = 'true', | ||
qos = 'at_least_once', | ||
) FORMAT PLAIN ENCODE JSON ( | ||
force_append_only='true', | ||
); | ||
|
||
statement ok | ||
CREATE SINK mqtt_nested_sink | ||
FROM | ||
mqtt_nested | ||
WITH | ||
( | ||
connector='mqtt', | ||
url='tcp://mqtt-server', | ||
type = 'append-only', | ||
topic = '/nested/fallback', | ||
topic.field = 'info.topic', | ||
retain = 'true', | ||
qos = 'at_least_once', | ||
) FORMAT PLAIN ENCODE JSON ( | ||
force_append_only='true', | ||
); | ||
|
||
|
||
statement ok | ||
CREATE TABLE mqtt_source | ||
( | ||
device_id varchar, | ||
temperature double | ||
) | ||
WITH ( | ||
connector='mqtt', | ||
url='tcp://mqtt-server', | ||
topic= '/device/+', | ||
qos = 'at_least_once', | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
statement ok | ||
CREATE TABLE mqtt_nested_source | ||
( | ||
info struct<device_id varchar, topic varchar>, | ||
temperature double | ||
) | ||
WITH ( | ||
connector='mqtt', | ||
url='tcp://mqtt-server', | ||
topic= '/nested/fallback', | ||
qos = 'at_least_once', | ||
) FORMAT PLAIN ENCODE JSON; | ||
|
||
|
||
statement ok | ||
INSERT INTO mqtt (device_id, temperature) | ||
VALUES ( '12', 56.0 ); | ||
|
||
statement ok | ||
INSERT INTO mqtt (device_id, temperature) | ||
VALUES ( '12', 59.0 ); | ||
|
||
statement ok | ||
INSERT INTO mqtt (device_id, temperature) | ||
VALUES ( '13', 20.0 ); | ||
|
||
statement ok | ||
INSERT INTO mqtt (device_id, temperature) | ||
VALUES ( '13', 22.0 ); | ||
|
||
statement ok | ||
INSERT INTO mqtt_nested (info, temperature) | ||
VALUES( ROW('12', '/nested/12'), 56.0 ); | ||
|
||
statement ok | ||
INSERT INTO mqtt_nested (info, temperature) | ||
VALUES( ROW('13', null), 22.0 ); | ||
|
||
statement ok | ||
FLUSH; | ||
|
||
sleep 15s | ||
|
||
query IT rowsort | ||
SELECT device_id, temperature FROM mqtt ORDER BY device_id, temperature; | ||
---- | ||
12 56 | ||
12 59 | ||
13 20 | ||
13 22 | ||
|
||
query IT rowsort | ||
SELECT (info).device_id device_id, temperature from mqtt_nested_source ORDER BY device_id, temperature ; | ||
---- | ||
13 22 |
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.