Skip to content

Unconsistent missing rows when using SAMPLE BY + FILL in subquery #6436

@agpenas

Description

@agpenas

To reproduce

Whenever I try to manipulate an intermediate table with filled rows, the ones that have been filled seem to disappear.
In order to easily reproduce the behavior, you can create a dummy table:

CREATE TABLE weather (
    ts TIMESTAMP,
    temperature DOUBLE,
    humidity INTEGER
) TIMESTAMP(ts);

INSERT INTO weather (ts, temperature, humidity) VALUES
    ('2024-01-01T00:00:00Z', 10.0, 10),
    ('2024-01-01T00:03:00Z', 11.5, 11),
    ('2024-01-01T00:04:00Z', 12.0, 12),
    ('2024-01-01T00:07:00Z', 13.0, 13);

Imputing the missing rows with this query will give the expected behavior:

SELECT
        ts,
        last(temperature) AS temperature,
        last(humidity) As humidity
    FROM weather
    SAMPLE BY 1m FILL(prev)
Image

While this nested query will not:

WITH imputed AS (
    SELECT
        ts,
        last(temperature) AS temperature,
        last(humidity) As humidity
    FROM weather
    SAMPLE BY 1m FILL(prev)
)
SELECT ts, humidity
FROM imputed
Image

To make things even more interesting, replacing humidity by temperature will work:

WITH imputed AS (
    SELECT
        ts,
        last(temperature) AS temperature,
        last(humidity) As humidity
    FROM weather
    SAMPLE BY 1m FILL(prev)
)
SELECT ts, temperature
FROM imputed
Image

QuestDB version:

9.1.0

OS, in case of Docker specify Docker and the Host OS:

Ubuntu 24.04 (Docker)

File System, in case of Docker specify Host File System:

ext4

Full Name:

Abel Garcia Penas

Affiliation:

N/A

Have you followed Linux, MacOs kernel configuration steps to increase Maximum open files and Maximum virtual memory areas limit?

  • Yes, I have

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions