Comments (8)
The \\n
seem to be added when the object is converted to JSON for submission. They should be converted back when executed on the backend. This appears to be a bug in the backend's JSON conversion.
from emqx.
I created a ticket for the double quote string issue: https://emqx.atlassian.net/browse/EMQX-11971
@zmstone
from emqx.
It's work as:
rule_test {
actions = []
description = ""
enable = true
metadata {created_at = 1708919800638}
name = ""
sql = """~
SELECT
tokens(payload, '
')
FROM "x/3
"~"""
}
if we want to use \n
as delimiter. just pass \n
to http api. not \\n
.
but as @wivwiv say:
<<"SELECT\n tokens(payload, '\\n\\t')\n FROM \"x/4\\n\"">>
<<"SELECT\n tokens(payload, '\n\t')\n FROM \"x/4\n\"">>
should has the same result.
from emqx.
Expected results:
SELECT
tokens('1
2
3
4', '\n') as c
FROM 't/#'
-- output
{ "c": ["1", "2", "3", "4"] }
SELECT
tokens('1
2
3
4', '
') as c
FROM 't/#'
-- output
{ "c": ["1", "2", "3", "4"] }
from emqx.
The issue seems to be the lack of escape sequence support.
which can be addressed in two ways:
- Add a
unescape
functionSELECT tokens(payload, unescape('\n')) as val
- Add a new quote syntax like Python's
b"..."
quote.SELECT tokens(payload, b"\n") as val
from emqx.
for internal ref: https://emqx.atlassian.net/browse/EMQX-11847
from emqx.
@zmstone, you are right that the issue seems to be lack of escape sequence support in the strings in the SQL like language. Another interesting thing I found is that it looks like double quote strings are supported but they get evaluated to undefined
! However, double quote strings seems to work fine in the FROM clause. I wonder if we could have single quote strings to mean literal strings and use double quote strings to mean strings with escape sequence support?
Anyway I think an unescape
function seems like a good first step solution as it kind of solves the problem but still allows us to extend the syntax of the SQL like language if we want to.
SELECT
'\n' as single_q,
"\n" as double_q,
'
' as newline
FROM
"t/#"
RESULT:
{
"double_q": "undefined",
"newline": "\n ",
"single_q": "\\n"
}
from emqx.
Thank you for the fix @kjellwinblad
I remember there is a issue or ticket about double quotes, but I cannot find it.
Anyways, double quotes handling is a separate matter, should create a new ticket to track it.
from emqx.
Related Issues (20)
- The client is powered off, but one month later EMQX still shows that the client is connected HOT 3
- bad_cert,hostname_check_failed HOT 5
- Plugin hook points not called when auto-booting plugin in a cluster HOT 5
- The retained message function in EMQX is controlled by two switches
- emqx_authn_pgsql resource down: unknown reason HOT 8
- Setting hibernate_after for tcp connection HOT 2
- Return wrong Receive Maximum
- The message queue size may exceed the maximum limit after setting topic priority HOT 2
- Setting max_heap_size to 0 causes function_clause HOT 1
- 在服务区上部署EMQX这一步出现以下问题 HOT 2
- 在云服务器连接实例后部署EMQX遇到问题, HOT 1
- 在软路由“”爱快(ikuai)”(debian12系统)上docker中安装eqmx启动报错 HOT 7
- "Mnesia is overloaded" messaggio di warning HOT 3
- Variable in header HOT 4
- EMQXWebSocket 客户端连接错误 HOT 8
- 配置SSL,8883,单向证书问题 HOT 2
- jwt过期导致无法发送遗嘱 HOT 6
- Exclusive subscriptions rejected with QuotaExceeded for no reason? HOT 16
- can't get real ipaddress of clients HOT 4
- receive a huge of connect and disconnect events from one client with no reasons HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emqx.