Skip to content

fix(sql): fix sample by first/last keyed by non-symbol column#2972

Merged
bluestreak01 merged 6 commits intomasterfrom
bz_fix_sample_by_first_last
Feb 22, 2023
Merged

fix(sql): fix sample by first/last keyed by non-symbol column#2972
bluestreak01 merged 6 commits intomasterfrom
bz_fix_sample_by_first_last

Conversation

@bziobrowski
Copy link
Contributor

@bziobrowski bziobrowski commented Feb 7, 2023

Fixes #2636

PR improves logic of sample by factory selection .
It doesn't allow using SampleByFirstLastRecordCursorFactory when column list contains anything other than :

  • first/last aggregates
  • designated timestamp column
  • filtered symbol column

It also enables order by geohash columns .

In master branch SQL such as :

CREATE TABLE pos (
  id int
  geo GEOHASH(5b)
);
insert into pos  values ( 1,##00001), ( 2,##00010), ( 3, ##00011 ), ( 16, ##10000 );
select * from pos order by geo desc;

triggers:

java.lang.UnsupportedOperationException at io.questdb.griffin.engine.functions.AbstractGeoHashFunction.getSymbolB(AbstractGeoHashFunction.java:154) at io.questdb.cairo.sql.VirtualRecord.getSymB(VirtualRecord.java:198) at io.questdb.griffin.engine.orderby.LongTreeChain.put(LongTreeChain.java:75) at io.questdb.griffin.engine.orderby.SortedLightRecordCursor.buildChain(SortedLightRecordCursor.java:130) at io.questdb.griffin.engine.orderby.SortedLightRecordCursor.hasNext(SortedLightRecordCursor.java:79) at io.questdb.cutlass.http.processors.JsonQueryProcessorState.onQuerySetupFirstRecord(JsonQueryProcessorState.java:755) at io.questdb.cutlass.http.processors.JsonQueryProcessorState.doFirstRecordLoop(JsonQueryProcessorState.java:463) at io.questdb.cutlass.http.processors.JsonQueryProcessorState.onQueryPrefix(JsonQueryProcessorState.java:719) at io.questdb.cutlass.http.processors.JsonQueryProcessorState.resume(JsonQueryProcessorState.java:864) at io.questdb.cutlass.http.processors.JsonQueryProcessor.doResumeSend(JsonQueryProcessor.java:306) at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeSelect(JsonQueryProcessor.java:550) at io.questdb.cutlass.http.processors.JsonQueryProcessor.executeNewSelect(JsonQueryProcessor.java:534) at io.questdb.cutlass.http.processors.JsonQueryProcessor.compileQuery(JsonQueryProcessor.java:423) at io.questdb.cutlass.http.processors.JsonQueryProcessor.execute0(JsonQueryProcessor.java:186) at io.questdb.cutlass.http.processors.JsonQueryProcessor.onRequestComplete(JsonQueryProcessor.java:236) 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)

because comparator uses default (symbol) type .

ideoma
ideoma previously approved these changes Feb 8, 2023
@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Feb 13, 2023
@ideoma
Copy link
Collaborator

ideoma commented Feb 22, 2023

[PR Coverage check]

😍 pass : 46 / 46 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/orderby/RecordComparatorCompiler.java 16 16 100.00%
🔵 io/questdb/griffin/SqlCodeGenerator.java 30 30 100.00%

@bluestreak01 bluestreak01 merged commit 020e0e7 into master Feb 22, 2023
@bluestreak01 bluestreak01 deleted the bz_fix_sample_by_first_last branch February 22, 2023 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

incorrect FILL results

4 participants