Simple Query
A simple query retrieves raw time-series rows from CrateDB. You choose which columns to return and can apply filters, sorting, and time range restrictions. This is the most fundamental stream data query type — use it when you need individual data points rather than aggregated summaries.
Transient Simple Query
A transient query lets you specify query parameters directly in the request without saving a query definition first. Use the transientStreamDataQuery field under streamData.
Basic Usage
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage", "power"]
) {
totalCount
pageInfo {
hasNextPage
endCursor
}
items {
rtId
ckTypeId
timestamp
rtWellKnownName
cells {
items {
attributePath
value
}
}
}
}
}
}
Response:
{
"data": {
"streamData": {
"transientStreamDataQuery": {
"totalCount": 4826,
"pageInfo": {
"hasNextPage": true,
"endCursor": "YXJyYXljb25uZWN0aW9uOjI0"
},
"items": [
{
"rtId": "65dc6d24cc529cdc46c84fcc",
"ckTypeId": "Industry.Energy/EnergyMeter",
"timestamp": "2024-03-21T16:22:47.676Z",
"rtWellKnownName": "EnergyMeter-001",
"cells": {
"items": [
{ "attributePath": "voltage", "value": 230.5 },
{ "attributePath": "power", "value": 1450.2 }
]
}
},
{
"rtId": "65dc6d24cc529cdc46c84fcc",
"ckTypeId": "Industry.Energy/EnergyMeter",
"timestamp": "2024-03-21T16:23:50.675Z",
"rtWellKnownName": "EnergyMeter-001",
"cells": {
"items": [
{ "attributePath": "voltage", "value": 231.1 },
{ "attributePath": "power", "value": 1465.8 }
]
}
}
]
}
}
}
}
Each result row contains the system fields (rtId, ckTypeId, timestamp, rtWellKnownName) and a cells connection with the requested column values.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| ckId | String! | Yes | The CK type to query (e.g., "Industry.Energy/EnergyMeter") |
| columnPaths | [String!]! | Yes | Data stream attribute names to return (e.g., ["voltage", "power"]) |
| arg | StreamDataArguments | No | Time range and limit overrides |
| fieldFilter | [FieldFilter] | No | Field-level comparison filters |
| sortOrder | [Sort] | No | Sort specification |
| rtIds | [OctoObjectId] | No | Scope results to specific runtime entity IDs |
| first | Int | No | Maximum number of items to return (pagination) |
| after | String | No | Cursor for pagination (from pageInfo.endCursor) |
Column Paths
The columnPaths parameter specifies which data stream attributes to include in the result. Use the attribute names as defined in the CK type.
# Single column
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage"]
)
# Multiple columns
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage", "power", "current", "frequency"]
)
The system fields rtId, ckTypeId, timestamp, and rtWellKnownName are always included regardless of the column paths specified.
Filtering
Use fieldFilter to restrict results based on attribute values. Each filter specifies an attribute path, an operator, and a comparison value.
Filter by Attribute Value
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage", "power"]
fieldFilter: [
{
attributePath: "voltage"
operator: GREATER_THAN
comparisonValue: 220
}
]
) {
totalCount
items {
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
Multiple Filters
Multiple filters are combined with AND logic:
fieldFilter: [
{
attributePath: "voltage"
operator: GREATER_EQUAL_THAN
comparisonValue: 220
},
{
attributePath: "voltage"
operator: LESS_EQUAL_THAN
comparisonValue: 240
}
]
Available Filter Operators
| Operator | Description |
|---|---|
EQUALS | Exact match |
NOT_EQUALS | Not equal |
GREATER_THAN | Greater than |
GREATER_EQUAL_THAN | Greater than or equal |
LESS_THAN | Less than |
LESS_EQUAL_THAN | Less than or equal |
LIKE | Pattern match (use % as wildcard) |
MATCH_REG_EX | Regular expression match |
IN | Value in list |
NOT_IN | Value not in list |
ANY_EQ | Any element equals (for array fields) |
ANY_LIKE | Any element matches pattern (for array fields) |
Time Range Filtering
Use StreamDataArguments to restrict results to a specific time window:
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage"]
arg: {
queryMode: DEFAULT
from: "2024-03-21T00:00:00Z"
to: "2024-03-22T00:00:00Z"
limit: 1000
}
) {
totalCount
items {
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
| Field | Description |
|---|---|
| from | Start of the time range (inclusive) |
| to | End of the time range (inclusive) |
| limit | Maximum number of data points to return from CrateDB |
| queryMode | Set to DEFAULT for standard queries |
The limit in StreamDataArguments controls how many rows CrateDB returns before pagination is applied. The first parameter on the query field controls how many items are returned per page.
Sorting
Use sortOrder to control the order of results:
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage"]
sortOrder: [
{ attributePath: "timestamp", sortOrder: DESCENDING }
]
) {
items {
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
This returns the most recent data points first. You can sort by any column in the result set.
Scoping to Specific Entities
Use rtIds to limit results to data from specific runtime entities:
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage", "power"]
rtIds: [
"65dc6d24cc529cdc46c84fcc",
"65dc6d24cc529cdc46c84fcd"
]
) {
totalCount
items {
rtId
rtWellKnownName
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
This returns stream data only for the two specified energy meters.
Pagination
All stream data queries use cursor-based pagination. Use first to set the page size and after to fetch subsequent pages.
First Page
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage"]
first: 50
) {
totalCount
pageInfo {
hasNextPage
endCursor
}
items {
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
Next Page
Use the endCursor value from the previous response as the after parameter:
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage"]
first: 50
after: "YXJyYXljb25uZWN0aW9uOjQ5"
) {
totalCount
pageInfo {
hasNextPage
endCursor
}
items {
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
Continue fetching pages until hasNextPage is false.
Combining Parameters
All parameters can be combined. This example queries the last 24 hours of voltage data for a specific energy meter, filtered to values above 220V, sorted by timestamp descending, with pagination:
query {
streamData {
transientStreamDataQuery(
ckId: "Industry.Energy/EnergyMeter"
columnPaths: ["voltage", "power"]
arg: {
queryMode: DEFAULT
from: "2024-03-20T16:00:00Z"
to: "2024-03-21T16:00:00Z"
limit: 5000
}
rtIds: ["65dc6d24cc529cdc46c84fcc"]
fieldFilter: [
{ attributePath: "voltage", operator: GREATER_THAN, comparisonValue: 220 }
]
sortOrder: [
{ attributePath: "timestamp", sortOrder: DESCENDING }
]
first: 100
) {
totalCount
pageInfo {
hasNextPage
endCursor
}
items {
rtId
rtWellKnownName
timestamp
cells {
items {
attributePath
value
}
}
}
}
}
}
Typed vs Transient
For a comparison of typed and transient query approaches, see the Stream Data Access overview. In summary:
| Typed | Transient | |
|---|---|---|
| Column selection | All attributes of the type | Explicit columnPaths parameter |
| Result format | Named fields (e.g., voltage) | cells with attributePath / value pairs |
| Type safety | GraphQL schema validation | Runtime validation |
| Use case | Known type, all attributes needed | Dynamic column selection, ad-hoc analysis |