Skip to content

The app crash when decode an empty low cardinality array #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huyphams opened this issue May 12, 2022 · 3 comments
Closed

The app crash when decode an empty low cardinality array #178

huyphams opened this issue May 12, 2022 · 3 comments

Comments

@huyphams
Copy link
Contributor

After this merge #173 now I can decode the array of low cardinality, however it will crash when decoding an empty array.

  1. Create a table with a column array of low cardinality.
CREATE TABLE array_lowcardinality
(
    `country` Array(LowCardinality(String)),
)
ENGINE = MergeTree
  1. Insert some rows with an empty array.
  2. Select from that table

=> Crash.

@arthurpassos
Copy link
Contributor

arthurpassos commented May 17, 2022

Thanks for reporting this. Do you happen to have a full example? Or at least your select statement. I have tried using the existing unit tests with an extra empty array at the end and it's not crashing.

const auto testData = std::vector<std::vector<std::string>> {
    { "aa", "bb" },
    { "cc" },
    {},
    { "dd" },
    {},
};

...

client.Select("SELECT * FROM array_lc", [&](const Block& bl) {
    for (size_t c = 0; c < bl.GetRowCount(); ++c) {
        auto col = bl[0]->As<ColumnArray>()->GetAsColumn(c);
        for (size_t i = 0; i < col->Size(); ++i) {
            auto stringColumn = col->As<ColumnString>();
            const auto string = stringColumn->At(i);

            ASSERT_EQ(testData[c][i], string);
        }
    }
});

@Enmk
Copy link
Collaborator

Enmk commented Jun 3, 2022

Seems to be resolved and tested. Feel free to reopen with an example.

@Enmk Enmk closed this as completed Jun 3, 2022
@huyphams
Copy link
Contributor Author

huyphams commented Jun 8, 2022

I'm still getting this error. When I connect to the ClickHouse default system database and then run this query below:

SELECT roles FROM "system"."session_log" LIMIT 2 OFFSET 0;

I will get this error:

can't load column 'roles' of type Array(LowCardinality(String))

Note some weird behaviors:

  1. If the first object is an empty array, it will crash the app.
  2. If the first object is not empty (ex: has 1 element), it works.

I think it has something to do with the format where the first object is an empty array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants