Skip to content

feat: add support for query type options in IoTDB queries - #129

Merged
JackieTien97 merged 1 commit into
apache:masterfrom
CoollZzz:feat/iotdb-instant-query-support
Aug 28, 2026
Merged

feat: add support for query type options in IoTDB queries#129
JackieTien97 merged 1 commit into
apache:masterfrom
CoollZzz:feat/iotdb-instant-query-support

Conversation

@CoollZzz

@CoollZzz CoollZzz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

This pull request adds Instant query support for IoTDB Table Model SQL in the Grafana plugin. Instant queries execute SQL over the complete Grafana query range, then select the latest row at or before the range end for each series and normalize its timestamp to that evaluation time. It also adds explicit $__evaluationTime and $__evaluationTime() macros for window constructs such as HOP(... ORIGIN => ...), while preserving existing Range behavior.

Query Modes and Point-in-Time Evaluation:

  • Added instant and range query flags for Table Model SQL. instant: true with range: false enables Instant mode, while instant: true with range: true enables Both mode. Queries without instant remain backward-compatible Range queries.
  • Instant mode selects the latest eligible row for each series at or before the Grafana query end time and normalizes the returned timestamp to that evaluation time.
  • Both mode executes Range and Instant queries independently and returns their results in distinct frames.
  • Added the explicit $__evaluationTime and $__evaluationTime() macros, which expand to the Grafana query range end timestamp. These macros can be used by SQL constructs that require an explicit evaluation boundary, such as HOP(... ORIGIN => ...).

Query Processing and Data Preparation:

  • Added Instant result processing for multi-series results, preserving series labels, value types, and zero-valued samples.
  • Added synthetic evaluation-time timestamps for scalar results without a timestamp column.
  • Empty results and NULL-only time-series results continue to be reported as no data.
  • Ordinary Table Model SQL continues to execute over the complete Grafana time range; Instant mode does not rewrite user-authored time predicates or ORIGIN values.

Testing and Documentation:

  • Added unit tests covering Range multi-point results, single-point Instant results, query-end timestamps, multi-series Instant queries, zero values, NULL and empty results, backward compatibility, explicit evaluation-time macros, and Both mode frame separation.
  • Updated the query model, query editor, README, and backend processing flow to document and support the new query modes.

These changes provide consistent point-in-time result semantics for IoTDB Table Model queries while keeping existing Range queries unchanged.

@JackieTien97
JackieTien97 merged commit 28f3032 into apache:master Aug 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants