Skip to content

Commit cba7fe8

Browse files
Merge pull request #1628 from fluent/alexakreizinger/sc-123160/update-stream-processing-check-keys-null-values
2 parents b9e63f1 + 3725ff9 commit cba7fe8

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
1-
# Check Keys and NULL values
1+
# Check keys and null values
22

3-
> Feature available on Fluent Bit >= 1.2
3+
When working with structured messages (also known as records), there are certain cases where you might want to confirm whether a key exists, and whether its value is null or not null.
44

5-
When working with structured messages \(records\), there are certain cases where we want to know if a key exists, if it value is _null_ or have a value different than _null_.
5+
In Fluent Bit, records are a binary serialization of maps with keys and value. A value can be `null`, which is a valid data type. The following statements can be applied in Fluent Bit SQL:
66

7-
[Fluent Bit](https://fluentbit.io) internal records are a binary serialization of maps with keys and values. A value can be _null_ which is a valid data type. In our SQL language we provide the following statements that can be applied to the conditionals statements:
7+
## Check if a key value is null
88

9-
## Check if a key value IS NULL
10-
11-
The following SQL statement can be used to retrieve all records from stream _test_ where the key called _phone_ has a _null_ value:
9+
The following statement retrieves all records from the stream `test` where the key `phone` has a value of `null`:
1210

1311
```sql
1412
SELECT * FROM STREAM:test WHERE phone IS NULL;
1513
```
1614

17-
## Check if a key value IS NOT NULL
15+
## Check if a key value is not null
1816

19-
Similar to the example above, there are cases where we want to retrieve all records that certain key value have something different than _null_:
17+
The following statement is similar to the previous example, but instead retrieves all records from the stream `test` where the key `phone` has a non-null value:
2018

2119
```sql
2220
SELECT * FROM STREAM:test WHERE phone IS NOT NULL;
2321
```
2422

2523
## Check if a key exists
2624

27-
Another common use-case is to check if certain key exists in the record. We provide specific record functions that can be used in the conditional part of the SQL statement. The prototype of the function to check if a key exists in the record is the following:
28-
25+
You can also confirm whether a certain key exists in a record at all, regardless of its value. Fluent Bit provides specific record functions that you can use in the condition part of the SQL statement. The following function determines whether `key` exists in a record:
2926
```text
3027
@record.contains(key)
3128
```
3229

33-
The following example query all records that contains a key called _phone_:
30+
For example, the following statement retrieves all records that contain a key called `phone`:
3431

3532
```sql
3633
SELECT * FROM STREAM:test WHERE @record.contains(phone);
3734
```
38-

0 commit comments

Comments
 (0)