712 B
712 B
Two new built-in functions sparkplug_decode
and sparkplug_encode
have been added to the rule engine SQL like language. These functions are used to decode and encode Sparkplug B messages. The functions are used as follows:
Decode a Sparkplug B message:
select
sparkplug_decode(payload) as decoded
from t
Encode a Sparkplug B message:
select
sparkplug_encode(json_decode(payload)) as encoded
from t
One can also specify a Sparkplug B message type by specifying it as the second argument to the sparkplug_decode
and sparkplug_encode
functions. The default is Payload
:
select
sparkplug_encode(sparkplug_decode(payload, 'Payload'), 'Payload') as encoded
from t