Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cannot access array of tuples generated by groupArray() #32

@clifarr

Description

@clifarr

It appears that there's an issue in accessing data returned by a query containing groupArray().

I have a table which contains a nested array named "eventz". The following is part of the create statement as returned by the "show create table" command:

eventz.EventCode` Array(UInt16) CODEC(LZ4HC(9)), `eventz.EventCnt` Array(UInt32) CODEC(LZ4HC(9)))

Trying the following query from the command-line clickhouse-client works just fine:

SELECT groupArray((`eventz.EventCode`, `eventz.EventCnt`)) from db1.tupletest array join eventz group by cl limit 10;

It returns:

┌─groupArray(tuple(eventz.EventCode, eventz.EventCnt))───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [(123,10),(456,100),(789,1000),(123,10),(456,100),(789,1000),(123,10),(456,100),(789,1000),(123,10),(456,100),(789,1000)]                                                                                                                                  │
│ [(123,10),(456,100),(789,1000),(123,10),(456,100),(789,1000)]         

...

However, from a C++ application using the Clickhouse C++ client library, I get a NULL pointer when I try calling GetAsColumn(). Consider the following code:

client.Select("SELECT groupArray((`eventz.EventCode`, `eventz.EventCnt`)) from db1.tupletest array join eventz group by cl limit 10", [] (const Block& block) mutable
    {
        size_t rows = block.GetRowCount();
        for (int i=0; i < rows; i++){
            std::cout << block[0]->As<ColumnArray>() << "\n";
            std::cout << block[0]->As<ColumnArray>()->Size() << "\n";
            std::cout << block[0]->As<ColumnArray>()->GetAsColumn(i);

...

Returns the following:

0x105d6c0
10
0

...

As you can see, GetAsColumn returned 0 (NULL) instead of a correct pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneed-infoAwaiting extra info from community/issue creator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions