Skip to content

ArrayIndexOutOfBoundsException in JOIN query #5700

@puzpuzpuz

Description

@puzpuzpuz

To reproduce

Run the following query

SELECT * FROM sys.telemetry_wal
LEFT OUTER JOIN (SELECT Id, table_name from tables()) t ON t.Id = tableId
where event = 105 and tableId = 87;

and observe the following unhandled error:

2025-05-28T11:10:38.138147Z C i.q.c.h.p.JsonQueryProcessorState [755914244391] internal error [ex=
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 16
	at io.questdb.std.ObjList.getQuick(ObjList.java:177)
	at io.questdb.cairo.AbstractRecordMetadata.getColumnMetadata(AbstractRecordMetadata.java:63)
	at io.questdb.cairo.AbstractRecordMetadata.getColumnType(AbstractRecordMetadata.java:73)
	at io.questdb.griffin.SqlCodeGenerator.generateSelectChoose(SqlCodeGenerator.java:3934)
	at io.questdb.griffin.SqlCodeGenerator.generateSelect(SqlCodeGenerator.java:3813)
	at io.questdb.griffin.SqlCodeGenerator.generateQuery0(SqlCodeGenerator.java:3366)
	at io.questdb.griffin.SqlCodeGenerator.generateQuery(SqlCodeGenerator.java:3354)
	at io.questdb.griffin.SqlCodeGenerator.generate(SqlCodeGenerator.java:531)
	at io.questdb.griffin.SqlCompilerImpl.generateSelectOneShot(SqlCompilerImpl.java:3957)
	at io.questdb.griffin.SqlCompilerImpl.generateSelectWithRetries(SqlCompilerImpl.java:427)
	at io.questdb.griffin.SqlCompilerImpl.compileUsingModel(SqlCompilerImpl.java:2590)
	at io.questdb.griffin.SqlCompilerImpl.compileInner(SqlCompilerImpl.java:2131)
	at io.questdb.griffin.SqlCompilerImpl.compile(SqlCompilerImpl.java:310)
	at io.questdb.cairo.pool.SqlCompilerPool$C.compile(SqlCompilerPool.java:138)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.compileAndExecuteQuery(JsonQueryProcessor.java:514)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.execute0(JsonQueryProcessor.java:225)
	at io.questdb.cutlass.http.processors.JsonQueryProcessor.onRequestComplete(JsonQueryProcessor.java:302)
	at io.questdb.cutlass.http.HttpConnectionContext.handleClientRecv(HttpConnectionContext.java:939)
	at io.questdb.cutlass.http.HttpConnectionContext.handleClientOperation(HttpConnectionContext.java:309)
	at io.questdb.cutlass.http.HttpServer.handleClientOperation(HttpServer.java:345)
	at io.questdb.cutlass.http.HttpServer$1.lambda$$0(HttpServer.java:129)
	at io.questdb.network.AbstractIODispatcher.processIOQueue(AbstractIODispatcher.java:216)
	at io.questdb.cutlass.http.HttpServer$1.run(HttpServer.java:133)
	at io.questdb.mp.Worker.run(Worker.java:152)
, q=`SELECT * FROM sys.telemetry_wal
LEFT OUTER JOIN (SELECT Id, table_name from tables()) t ON t.Id = tableId
where event = 105 and tableId = 87`]

QuestDB version:

latest master

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

Ubuntu 22.04

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

ext4

Full Name:

Andrei Pechkurov

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 execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions