Skip to content

MIN/MAX for nested type compares string cast, not values #1888

@hawkfish

Description

@hawkfish

What does happen?
The code for the MIN and MAX aggregates does not have any specialisation for nested types.
Instead, the compiler inserts a cast to string and the result is the maximum string, which doesn't work
when there are integers of varying sizes.
It also appears that the Value comparison operators for nested types are not consistent with the current positional comparison semantics.

What should happen?
Nested types should be compared using the positional sorting semantics. This goes for both Value comparisons as well as MIN and MAX .

To Reproduce
Steps to reproduce the behavior. Bonus points if those are only SQL queries.

  1. sql select max(struct_pack(i := i + 2, j := i + 4)) from range(10) tbl(i);
  2. Expected: {'i': 11, 'j': 13}
  3. Actual: {'i': 9, 'j': 11}

Environment (please complete the following information):

  • OS: OSX
  • DuckDB Version 0.26

Before submitting

  • Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
  • Have you tried this on the latest master branch? In case you cannot compile, you may find some binaries here: https://github.com/duckdb/duckdb/releases/tag/master-builds

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