Skip to content

filter disappears when comment is added to a query #6671

@nwoolmer

Description

@nwoolmer

To reproduce

Okay:

SELECT 
    (timestamp / 1000000)::long AS time,
    avg(price) as price,
    NULL AS other_value
FROM trades
WHERE
    timestamp > dateadd('d', -60, now())
    AND symbol = 'BTC-USD'
    AND side ~ 'buy' 
    AND side IN ('buy', '') 
    AND amount >= -50 
    AND amount <= 60
GROUP BY timestamp;

Plan:

VirtualRecord
  functions: [timestamp/1000000,price,null]
    Async Group By workers: 46
      keys: [timestamp]
      values: [avg(price)]
      filter: ((symbol='BTC-USD' and side ~ buy and side in [buy,] and amount>=-50) and 60>=amount)
        PageFrame
            Row forward scan
            Interval forward scan on: trades
              intervals: [("2025-11-20T17:21:02.290734Z","MAX")]

Not okay:

SELECT 
    (timestamp / 1000000)::long AS time,
    avg(price) as price,
    NULL AS other_value
FROM trades
WHERE
    timestamp > dateadd('d', -60, now())
    AND symbol = 'BTC-USD'
    -- magic '
    AND side ~ 'buy' 
    AND side IN ('buy', '') 
    AND amount >= -50 
    AND amount <= 60
GROUP BY timestamp;

Plan:

VirtualRecord
  functions: [timestamp/1000000,price,null]
    Async JIT Group By workers: 46
      keys: [timestamp]
      values: [avg(price)]
      filter: (symbol='BTC-USD' and amount>=-50 and 60>=amount)
        PageFrame
            Row forward scan
            Interval forward scan on: trades
              intervals: [("2025-11-20T17:19:54.772711Z","MAX")]

Oops!

QuestDB version:

9.3.1

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

N/A

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

N/A

Full Name:

Nick Woolmer

Affiliation:

QuestDB

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

    BugIncorrect or unexpected behaviorSQLIssues or changes relating to SQL executionexternal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions