influxdata / influxdata/influxdb

FIRST(),LAST() do not return the relevant timestamp with * or multiple fields

Open
#20,979 2 comments 0 reactions 0 assignees View on GitHub
area/influxql area/queries
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

The last() function returns different values for:
1. Select one field -- Correct value
2. Select two field in same record -- Wrong value 1970-01-01T00:00:00Z
3. With $timefilter -- Wrong value. The current time
4. Without $timefilter -- Wrong value 1970-01-01T00:00:00Z

> SELECT last("HDB_INST_DWC_POC") FROM "tenant_memory"
name: tenant_memory
time last
---- ----
2021-03-17T03:47:21.942393088Z 2.68
> SELECT last("HDB_INST_DWC_POC"), last("TOTAL") FROM "tenant_memory"
name: tenant_memory
time last last_1
---- ---- ------
1970-01-01T00:00:00Z 2.68 2.68
> SELECT last(*) FROM "tenant_memory"
name: tenant_memory
time last_HDB_INST_DWC_POC last_SUBDOMAIN last_TOTAL last_Tenant last_dev-hdb-general-01
---- --------------------- -------------- ---------- ----------- -----------------------
1970-01-01T00:00:00Z 2.68 - 2.68 x-template-srv-spring-boot-db-update-test 0
>
> SELECT last(*) FROM "tenant_memory" WHERE time > now()-6h
name: tenant_memory
time last_HDB_INST_DWC_POC last_SUBDOMAIN last_TOTAL last_Tenant last_dev-hdb-general-01
---- --------------------- -------------- ---------- ----------- -----------------------
2021-03-17T00:35:30.081580047Z 2.68 - 2.68 x-template-srv-spring-boot-db-update-test 0
> / # date
Wed Mar 17 06:36:20 UTC 2021

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported FIRST() and LAST() queries against the tenant_memory measurement, both with and without the time filter, and compare the returned timestamps. Then trace the query handling for single-field, multi-field, and wildcard selections. Done means all forms return the timestamp associated with the selected last record rather than the epoch or current time.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.