Null

Provides examples on using nulls in Siddhi Apps.

For more information refer Siddhi query guide.

define stream ProductInputStream (item string, price double);

define Table ProductInfoTable (item string, discount double);

@info(name = 'Check-for-null')
from ProductInputStream [not(item is null)]
select item,
       price is null as isPriceNull
insert into ProductValidationStream;

@info(name = 'Outer-join-with-table')
from ProductInputStream as s
    left outer join ProductInfoTable as t
    on s.item == t.item
select s.item, s.price, t.discount,
       math:power(t.discount, 2) is null
            as isFunctionReturnsNull,
       t is null as isTNull,
       s is null as isSNull,
       t.discount is null as isTDiscountNull,
       s.item is null as isSItemNull
insert into DiscountValidationStream;
define stream ProductInputStream (item string, price double);
define Table ProductInfoTable (item string, discount double);

Empty ProductInfoTable with attributes item and discount.

@info(name = 'Check-for-null')
from ProductInputStream [not(item is null)]

Filter events with item not having null value.

select item,
       price is null as isPriceNull

Checks if price contains null value.

insert into ProductValidationStream;
@info(name = 'Outer-join-with-table')
from ProductInputStream as s
    left outer join ProductInfoTable as t
    on s.item == t.item
select s.item, s.price, t.discount,
       math:power(t.discount, 2) is null
            as isFunctionReturnsNull,

Check if math:power() returns null.

       t is null as isTNull,
       s is null as isSNull,

Check if streams t and s are null.

       t.discount is null as isTDiscountNull,
       s.item is null as isSItemNull

Check if streams attributes t.discount and s.item are null.

insert into DiscountValidationStream;

Input

Below event is sent to ProductInputStream,

['Cake', 12.0]

Output

After processing, the following events will be arriving at each stream:

  • ProductValidationStream:
    [Cake, false]
  • DiscountValidationStream:
    [Cake, 12.0, null, true, true, false, true, false]
Top