lf-edge / ekuiper

Lightweight data stream processing engine for IoT edge
https://ekuiper.org
Apache License 2.0
1.47k stars 413 forks source link

unknown field $default.nil issue #914

Closed malepurakesh closed 3 years ago

malepurakesh commented 3 years ago

Hi, I have built the kuiper from source in my target board, which is of RISC-V architecture. I am facing below error.

root@rakesh-3:~ # kuiper show rules Connecting to 127.0.0.1:20498... [ { "id": "cmplx_motor_off", "status": "Stopped: canceled manually or by error." } ] root@rakesh-3:~ # kuiper restart rule cmplx_motor_off Connecting to 127.0.0.1:20498... unknown field $default.nil root@root-3:~#

I searched in google but , didn't get the solution. While creating the stream, there is no error. But, while creating the rule, it is creating but stopping and getting above error (unknown field). How can I resolve this issue and run the rule successfully.? Thanks in advance.

ngjaying commented 3 years ago

Could you provide your stream and rule definition? Thanks

malepurakesh commented 3 years ago

stream : kuiper create stream temperature_stream'(temperaturedata bigint) WITH (FORMAT="JSON", DATASOURCE="events",TYPE="edgex")'

rule :

root@rakesh : ~/EDGEX/EdgeX_kuiper/edgex_and_kuiper_poc/semi_edgex/kuiper_rules# cat cmplx_motor_off.txt { "id": "cmplx_motor_off", "sql": "SELECT avg(temperaturedata) AS avg_temp FROM temperature_stream WHERE temperaturedata != nil GROUP BY TUMBLINGWINDOW(ss, 5) HAVING avg(temperaturedata) <= 28", "actions":[ { "rest": { "url":"http://192.168.1.74:49999/api/v1/device/name/Motor/WriteMsg", "method": "POST", "dataTemplate": "{\"Message\":\"OFF\"}", "sendSingle":true, "debugResp": true, "bodyType": "json" } }, { "mqtt": { "server":"tcp://192.168.2.57:1883", "topic":"status", "clientId":"app_003", "sendSingle": true, "dataTemplate": "0" } } ] }

ngjaying commented 3 years ago

@malepurakesh The rule json seems invalid. The dataTemplate must add escape for quotes: "dataTemplate": "{\"Message\":\"OFF\"}",. With this change, my rules can run successfully. I did not feed data to the rule because it seems your problem happens before feeding data. Also, what's the version do you use? Any findings in the log?

malepurakesh commented 3 years ago

@ngjaying sorry, I have given that escapes for quotes, it was a typo mistake

malepurakesh commented 3 years ago

The version of Kuiper is, Kuiper version 0.0.2-1168-g693886c

Here is the log file, when I am trying to restart the rule, it is getting same error unknown field $default.nil stream_log_2021-07-30_00-00-00.txt

ngjaying commented 3 years ago

The version is weird. v0.0.2 does not have the planner but your logs have. What is the latest commit (Use git log to get the commit id) in the source code copy which you built this kuiper instance? If you create another rule with the same SQL, will you have the same problem.

malepurakesh commented 3 years ago

hi @ngjaying, sorry for late response. I am not facing problem, while creating other rules. Here I found the reason of the error unknown field $default.nil issue. Actually I am using nil in sql query (WHERE temperaturedata != nil), for that getting error.

But in older version nil is accepting and rules creating properly. (check below)

root@xxxxxxx-3:~/EDGEX/EdgeX_kuiper/edgex_and_kuiper/semi_edgex/kuiper/_build/kuiper-52c3533-linux-riscv64/bin# ./kuiper --version Connecting to 127.0.0.1:20498... Kuiper version 52c3533

-----------------------------------------------------------------------------------------------------------------------------

In other versions , nil is not working(check below). root@xxxxxxxxx-3:~# kuiper --version Connecting to 127.0.0.1:20498... Kuiper version 0.0.2-1168-g693886c

Hope you understand my points. My question is, what is the alternative for nil in sql query for these versions.

"sql": "SELECT avg(temperaturedata) AS avg_temp FROM temperature_stream WHERE temperaturedata != nil GROUP BY TUMBLINGWINDOW(ss, 5) HAVING avg(temperaturedata) <= 28"

Thanks in advance.

ngjaying commented 3 years ago

Hi @malepurakesh Please use isNull(temperature) = false.
nil is not a keyword in SQL so it is parsed as a field but not exist.

malepurakesh commented 3 years ago

Thanks @ngjaying it is working, but it was worked in older version of kuiper.

ngjaying commented 3 years ago

@malepurakesh Great. I think that is considered as a bug and "fixed"

malepurakesh commented 3 years ago

Thanks @ngjaying for your support.