Skip to content

An error occurred after query about LATEST ON <timestamp> PARTITION BY <symbol> #3026

@BartoszPluta

Description

@BartoszPluta

Describe the bug

After using the WHERE clause in a query combined with the LATEST ON clause, an error occurs when we set a BYTE type column as the first or any subsequent value in the PARTITION BY clause. Removing the WHERE clause enables the execution of the query. Similarly, using the WHERE clause along with a SYMBOL type column in PARTITION BY produces a positive result.

To reproduce

  1. Run local server with Questdb version 7.0.0
  2. Go to Questdb console
  3. Use my schema as example:
CREATE TABLE history_P4v (
  devid SYMBOL,
  address SHORT,
  value SHORT,
  value_decimal BYTE,
  created_at DATE,
  ts TIMESTAMP
) timestamp(ts) PARTITION BY DAY;
  1. Run query on empty table (any data are not required)
SELECT * FROM 'history_P4v'
WHERE
  devid = 'LLLAHFZHYA'
LATEST ON ts PARTITION BY address
  1. You should expect error like: "An error occured, please try again"

Expected Behavior

I expect using the LATEST ON clause to not pose a problem with using it with different combinations of column types and to work in conjunction with the WHERE clause.

Environment

- **QuestDB version**: 7.0.0
- **OS**: Linux
- **Browser**: EDGE

Additional context

Logs:

2023-02-25T13:10:27.479419Z I i.q.g.SqlCompiler plan [q=`select-choose devid, address, value, value_decimal, created_at, ts from (select [devid, address, value, value_decimal, created_at, ts] from history_P4v where devid = 'LLLAHFZHYA' latest on ts partition by address)`, fd=2220]
2023-02-25T13:10:27.490227Z I i.q.c.h.p.JsonQueryProcessorState [2220] execute-new [skip: 0, stop: 1000]
2023-02-25T13:10:27.490353Z C i.q.c.h.p.JsonQueryProcessorState [2220] Uh-oh. Error!
java.lang.NullPointerException
	at io.questdb.griffin.engine.table.AbstractDataFrameRecordCursor.getSymbolTable(AbstractDataFrameRecordCursor.java:76)
	at io.questdb.griffin.engine.table.AbstractDataFrameRecordCursor.getSymbolTable(AbstractDataFrameRecordCursor.java:37)
	at io.questdb.griffin.engine.functions.columns.SymbolColumn.init(SymbolColumn.java:91)
	at io.questdb.griffin.engine.functions.eq.EqSymStrFunctionFactory$ConstSymIntCheckFunc.init(EqSymStrFunctionFactory.java:165)
	at io.questdb.griffin.engine.table.LatestByAllFilteredRecordCursor.of(LatestByAllFilteredRecordCursor.java:74)
	at io.questdb.griffin.engine.table.AbstractTreeSetRecordCursorFactory.getCursorInstance(AbstractTreeSetRecordCursorFactory.java:61)
	at io.questdb.griffin.engine.table.AbstractDataFrameRecordCursorFactory.getCursor(AbstractDataFrameRecordCursorFactory.java:57)
	at io.questdb.griffin.engine.table.LatestByAllFilteredRecordCursorFactory.getCursor(LatestByAllFilteredRecordCursorFactory.java:42)
	at io.questdb.cutlass.http.processors.JsonQueryProcessorState.of(JsonQueryProcessorState.java:814)
	at io.questdb.cutlass.http.processors.JsonQueryProcessorState.of(JsonQueryProcessorState.java:800)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeSelect(JsonQueryProcessor.java:546)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeNewSelect(JsonQueryProcessor.java:532)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.compileQuery(JsonQueryProcessor.java:421)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.execute0(JsonQueryProcessor.java:184)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.onRequestComplete(JsonQueryProcessor.java:234)
	at io.questdb.cutlass.http.HttpConnectionContext.handleClientRecv(HttpConnectionContext.java:600)
	at io.questdb.cutlass.http.HttpConnectionContext.handleClientOperation(HttpConnectionContext.java:203)
	at io.questdb.cutlass.http.HttpServer$1.lambda$$0(HttpServer.java:86)
	at io.questdb.network.AbstractIODispatcher.processIOQueue(AbstractIODispatcher.java:178)
	at io.questdb.cutlass.http.HttpServer$1.run(HttpServer.java:101)
	at io.questdb.mp.Worker.run(Worker.java:118)

2023-02-25T13:10:27.490553Z I i.q.c.h.HttpConnectionContext kicked out [fd=2220]
2023-02-25T13:10:27.490565Z I http-server scheduling disconnect [fd=2220, reason=5]
2023-02-25T13:10:27.490679Z I http-server disconnected [ip=127.0.0.1, fd=2220, src=queue]

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