Merge pull request #11620 from zmstone/0915-add-bytesize-rule-sql-func

feat: add bytesize rule sql function
This commit is contained in:
Zaiming (Stone) Shi 2023-09-16 11:30:22 +02:00 committed by GitHub
commit 3aa5c9c5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -89,6 +89,7 @@
bitsl/2,
bitsr/2,
bitsize/1,
bytesize/1,
subbits/2,
subbits/3,
subbits/6
@ -405,6 +406,9 @@ find_topic_filter(Filter, TopicFilters, Func) ->
null() ->
undefined.
bytesize(IoList) ->
erlang:iolist_size(IoList).
%%------------------------------------------------------------------------------
%% Arithmetic Funcs
%%------------------------------------------------------------------------------

View File

@ -759,6 +759,10 @@ t_bitsize(_) ->
?assertEqual(8, apply_func(bitsize, [<<"a">>])),
?assertEqual(4, apply_func(bitsize, [<<15:4>>])).
t_bytesize(_) ->
?assertEqual(1, apply_func(bytesize, [<<"a">>])),
?assertEqual(0, apply_func(bytesize, [<<>>])).
t_subbits(_) ->
?assertEqual(1, apply_func(subbits, [<<255:8>>, 1])),
?assertEqual(3, apply_func(subbits, [<<255:8>>, 2])),

View File

@ -0,0 +1 @@
Add a new rule-engine SQL function `bytesize` to get the size of a byte-string. e.g. ``SELECT * FROM "t/#" WHERE bytesize(payload) > 10`