-
Notifications
You must be signed in to change notification settings - Fork 541
stream-processing: getting-started: check-keys-null-values: general cleanup #1628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexakreizinger
merged 2 commits into
master
from
alexakreizinger/sc-123160/update-stream-processing-check-keys-null-values
May 2, 2025
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 9 additions & 13 deletions
22
stream-processing/getting-started/check-keys-null-values.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,34 @@ | ||
| # Check Keys and NULL values | ||
| # Check keys and null values | ||
|
|
||
| > Feature available on Fluent Bit >= 1.2 | ||
| 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. | ||
|
|
||
| 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_. | ||
| 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: | ||
|
|
||
| [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: | ||
| ## Check if a key value is null | ||
|
|
||
| ## Check if a key value IS NULL | ||
|
|
||
| The following SQL statement can be used to retrieve all records from stream _test_ where the key called _phone_ has a _null_ value: | ||
| The following statement retrieves all records from the stream `test` where the key `phone` has a value of `null`: | ||
|
|
||
| ```sql | ||
| SELECT * FROM STREAM:test WHERE phone IS NULL; | ||
| ``` | ||
|
|
||
| ## Check if a key value IS NOT NULL | ||
| ## Check if a key value is not null | ||
|
|
||
| Similar to the example above, there are cases where we want to retrieve all records that certain key value have something different than _null_: | ||
| 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: | ||
|
|
||
| ```sql | ||
| SELECT * FROM STREAM:test WHERE phone IS NOT NULL; | ||
| ``` | ||
|
|
||
| ## Check if a key exists | ||
|
|
||
| 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: | ||
|
|
||
| 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: | ||
| ```text | ||
| @record.contains(key) | ||
| ``` | ||
|
|
||
| The following example query all records that contains a key called _phone_: | ||
| For example, the following statement retrieves all records that contain a key called `phone`: | ||
|
|
||
| ```sql | ||
| SELECT * FROM STREAM:test WHERE @record.contains(phone); | ||
| ``` | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.