Skip to content

type inference regression in window functions due to improper args ordering #6695

@nwoolmer

Description

@nwoolmer

To reproduce

Demo:

SELECT max(timestamp) OVER (PARTITION BY split_part(symbol, '-', 1), split_part(symbol, '_', 2))
as max
FROM (trades LIMIT 1000);

Error:

there is no matching function `split_part` with the argument types: (INT, CHAR, SYMBOL)

Looks suspiciously like the paramlist is being checked in reverse order, which can be easy to forget on those models. As proof:

SELECT max(timestamp) OVER (PARTITION BY substring(symbol, 1, 5), split_part(symbol, '_', 2))
as max
FROM (trades LIMIT 1000);

Error:

there is no matching function `substring` with the argument types: (INT, INT, SYMBOL)

Workaround is to subquery:

SELECT max(timestamp) OVER (PARTITION BY part1, part2) as max FROM (
  SELECT *, split_part(symbol, '-', 1) as part1, split_part(symbol, '-', 2) as part2
  FROM (trades LIMIT 1000)
);

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

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