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

Skip to content

Appending an Array of Tuples to a Column fails. #115

@timoll

Description

@timoll

This could be related to #32.

When I try to fill a Column that has type Array(Tuple(UInt64, String)) with AppendAsColumn then no actual data is added and the insert fails.

#include <clickhouse/client.h>

using namespace std;
using namespace clickhouse;

int main()
{

    Block block;

    Client client(ClientOptions().SetHost("localhost"));
    client.Execute("CREATE TABLE mynumbers (tupleArray Array(Tuple(UInt64, String))) ENGINE = Memory");

    auto tupleArray = make_shared<ColumnArray>(
                make_shared<ColumnTuple>(
                    vector<ColumnRef>({
                                          make_shared<ColumnUInt64>(),
                                          make_shared<ColumnString>()
                                      })
                    )
                );
    auto tupleArrayEntry1 = make_shared<ColumnTuple>(
                vector<ColumnRef>({
                                      make_shared<ColumnUInt64>(),
                                      make_shared<ColumnString>()
                                  })
                );
    auto tupleArrayEntry2 = make_shared<ColumnTuple>(
                vector<ColumnRef>({
                                      make_shared<ColumnUInt64>(),
                                      make_shared<ColumnString>()
                                  })
                );

    (*tupleArrayEntry1)[0]->As<ColumnUInt64>()->Append(2);
    (*tupleArrayEntry1)[1]->As<ColumnString>()->Append("2");
    (*tupleArrayEntry2)[0]->As<ColumnUInt64>()->Append(10);
    (*tupleArrayEntry2)[1]->As<ColumnString>()->Append("10");
    (*tupleArrayEntry2)[0]->As<ColumnUInt64>()->Append(11);
    (*tupleArrayEntry2)[1]->As<ColumnString>()->Append("11");

    tupleArray->AppendAsColumn(tupleArrayEntry1);
    tupleArray->AppendAsColumn(tupleArrayEntry2);

    block.AppendColumn("tupleArray", tupleArray);

    client.Insert("mynumbers", block);

    return 0;
}

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