Просмотр исходного кода

fix(iotdb): fixed `data_type` case problem and update changes

firest 1 год назад
Родитель
Сommit
8d9395d802

+ 1 - 1
apps/emqx_bridge_iotdb/src/emqx_bridge_iotdb_connector.erl

@@ -837,7 +837,7 @@ preproc_data_template(DataList) ->
             #{
                 timestamp => emqx_placeholder:preproc_tmpl(Atom2Bin(Timestamp)),
                 measurement => emqx_placeholder:preproc_tmpl(Measurement),
-                data_type => Atom2Bin(DataType),
+                data_type => string:uppercase(Atom2Bin(DataType)),
                 value => emqx_placeholder:preproc_tmpl(Value)
             }
         end,

+ 16 - 0
apps/emqx_bridge_iotdb/test/emqx_bridge_iotdb_impl_SUITE.erl

@@ -630,6 +630,20 @@ t_sync_query_unmatched_type(Config) ->
 t_thrift_auto_recon(Config) ->
     emqx_bridge_v2_testlib:t_on_get_status(Config).
 
+t_sync_query_with_lowercase(Config) ->
+    DeviceId = iotdb_device(Config),
+    Payload = make_iotdb_payload(DeviceId, "temp", "int32", "36"),
+    MakeMessageFun = make_message_fun(iotdb_topic(Config), Payload),
+    ok = emqx_bridge_v2_testlib:t_sync_query(
+        Config, MakeMessageFun, fun is_success_check/1, iotdb_bridge_on_query
+    ),
+    Query = <<"select temp from ", DeviceId/binary>>,
+    {ok, {{_, 200, _}, _, IoTDBResult}} = iotdb_query(Config, Query),
+    ?assertMatch(
+        #{<<"values">> := [[36]]},
+        emqx_utils_json:decode(IoTDBResult)
+    ).
+
 is_empty(null) -> true;
 is_empty([]) -> true;
 is_empty([[]]) -> true;
@@ -662,5 +676,7 @@ test_case_data_type(t_device_id) ->
     <<"BOOLEAN">>;
 test_case_data_type(t_sync_query_unmatched_type) ->
     <<"BOOLEAN">>;
+test_case_data_type(t_sync_query_with_lowercase) ->
+    <<"int32">>;
 test_case_data_type(_) ->
     <<"INT32">>.

+ 0 - 6
changes/ee/breaking-14295.en.md

@@ -1,6 +0,0 @@
-Refactored IoTD connector, the following are no longer supported:
-- The self-describing template has been removed
-- One rule can only carry one `payload`, arrays of payloads are no longer supported
-- The `data type` is now a plain value, not a template value
-- The REST API driver only supports IoTDB 1.3.x and later
-- Thrift driver has add support for "batch" mode

+ 18 - 0
changes/ee/breaking-14370.en.md

@@ -0,0 +1,18 @@
+## Breaking Changes
+For IoTDB the following are no longer supported:
+- The self-describing template has been removed.
+
+  EMQX now only uses the configured data templates to process messages and no longer attempts to extract the template from the payload.
+
+- One message can only carry one `payload`, arrays of payloads are no longer be supported
+
+  Now, a MQTT message is processed as an atomic insert operation (a sigle or a batch insert) to IoTDB, and it is no longer possible to generate multiple IoTDB operations from a single MQTT message.
+
+- The `data type` is now a plain value, not a template value
+- The REST API driver only supports IoTDB 1.3.x and later
+
+## Enhancements
+- Thrift driver has add support for "batch" mode
+
+**NOTE**:
+To avoid overlapping timestamps in a batch, it is better to use the MQTT message timestamp (`${timestamp}`) or carry a certain time in the payload (for example `${payload.time}`) in batch mode.