Skip to content

Support nullable complex types such as Tuple/Array/Map  #52562

Open

Description

@taiyang-li

Use case
Currently CH doesn't support nullable complext types, but nullable complex types exist widely in formats like ORC/Parquet, and OLAP systems like Hive/Spark. From the perspective of users, nullable complex types are necessary because null and empty values of complex types are different in sematics.

If you are interested in this topic, we are glad to contribute to it for we had some works on it previously in gluten @alexey-milovidov . cc @baibaichen @zhanglistar

Activity

  1. baibaichen commented on Jul 26, 2023

    @baibaichen
    Contributor

    @alexey-milovidov would you please take a look at this issue?

  2. canhld94 commented on Aug 11, 2023

    @canhld94
    Contributor

    I don't understand why CH doesn't allow nullable Array in the first place if nested type is neither nullable nor complex. From storage and column POV, it should could have been supported without any code change. The only issue I can foresee is when enable optimize_functions_to_subcolumns, if it's nullable array then we need to read both size0 and null.

  3. canhld94 commented on Aug 11, 2023

    @canhld94
    Contributor

    I don't understand why CH doesn't allow nullable Array in the first place if nested type is neither nullable nor complex. From storage and column POV, it should could have been supported without any code change. The only issue I can foresee is when enable optimize_functions_to_subcolumns, if it's nullable array then we need to read both size0 and null.

    @baibaichen @taiyang-li pls enlighten me if I'm wrong [THANKS]!

  4. taiyang-li commented on Aug 11, 2023

    @taiyang-li
    ContributorAuthor

    @canhld94 it is not that easy. AFSIS,

    • many functions(including aggregate/window functions) which process complex types would has compatiability issues
    • Transformation between Arrow/ORC/Arrow and CH Columns would also meet compatiability issues
  5. taiyang-li commented on Aug 11, 2023

    @taiyang-li
    ContributorAuthor

    @alexey-milovidov If you has any opinion about this topic, pls let us knonw, thanks very much !

  6. canhld94 commented on Aug 14, 2023

    @canhld94
    Contributor

    @taiyang-li @baibaichen I think this is a valuable feature (at least for us, it will make our life much easier). Hope to see your PR soon!

  7. alexey-milovidov commented on Aug 14, 2023

    @alexey-milovidov
    Member

    A long time ago (around 2014), Nullable types were implemented in a non-generic way, and we forbid Nullable complex types to avoid code explosion. Then it was generalized, but the restrictions remain. Now it could make sense to allow Nullable complex types, but it is still in doubt.

  8. alexey-milovidov commented on Aug 14, 2023

    @alexey-milovidov
    Member

    The way is to allow them in a pull request and see what will happen.

  9. taiyang-li commented on Aug 14, 2023

    @taiyang-li
    ContributorAuthor

    @alexey-milovidov I'll create a PR soon.

  10. UnamedRus commented on Aug 15, 2023

    @UnamedRus
    Contributor

    Currently Array(LowCardinality(Nullable(String))) data type produce 6 files on disk.

    -rw-r-----   1 clickhouse clickhouse 9.7K Aug 15 13:56 value.bin
    -rw-r-----   1 clickhouse clickhouse 3.1K Aug 15 13:56 value.mrk2
    -rw-r-----   1 clickhouse clickhouse   43 Aug 15 13:56 value.dict.bin
    -rw-r-----   1 clickhouse clickhouse 3.1K Aug 15 13:56 value.dict.mrk2
    -rw-r-----   1 clickhouse clickhouse  37K Aug 15 13:56 value.size0.bin
    -rw-r-----   1 clickhouse clickhouse 3.1K Aug 15 13:56 value.size0.mrk2
    

    And for Array(Nullable(String))

    -rw-r-----  1 clickhouse clickhouse  13K Aug 15 14:00 value.bin
    -rw-r-----  1 clickhouse clickhouse 1.7K Aug 15 14:00 value.mrk2
    -rw-r-----  1 clickhouse clickhouse 5.0K Aug 15 14:00 value.null.bin
    -rw-r-----  1 clickhouse clickhouse 1.7K Aug 15 14:00 value.null.mrk2
    -rw-r-----  1 clickhouse clickhouse  20K Aug 15 14:00 value.size0.bin
    -rw-r-----  1 clickhouse clickhouse 1.7K Aug 15 14:00 value.size0.mrk2
    

    Are you going to embed them in value.null.* files or create another pair of files? (6 files is already quite a few to read for single column, adding even more may affect performance.)

  11. taiyang-li commented on Aug 16, 2023

    @taiyang-li
    ContributorAuthor

    @UnamedRus sorry, we have not thought about this issue yet. Currently the most important thing for us is to keep all tests in ci passed, and there is a lot of works to do.

  12. panthony commented on Apr 24, 2024

    @panthony

    Stumbled upon this issue too, we are looking to transition part of our stack to ClickHouse and the absence of nullable array is a bummer.

    There is a huge difference between saying "I don't know" and "There is nothing".

    Adding a new field to hold that info for every Array() field manually is not somewhere I'm willing to go.

  13. alexey-milovidov commented on Jan 29, 2026

    @alexey-milovidov
    Member

    Nullable(Tuple) is implemented. Next step: Nullable(Array) and Nullable(Map).

  14. ViktorPetrovski commented on Jan 30, 2026

    @ViktorPetrovski

    Hey @alexey-milovidov great update! Do you have any ETA when Nullable(Array) would be implemented? Our team is really hitting a wall because of this problem and we are eagerly waiting for a good solution

  15. ibindlish commented on Apr 23, 2026

    @ibindlish

    Also interested in Nullable(Array) here if you have any updates!

  16. added
    comp-datatype-wrapper
    on Sep 4, 2026
  17. added
    external
    on Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-datatype-wrapperexternalfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions