Skip to content
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

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

Closed
timoll opened this issue Nov 22, 2021 · 1 comment · Fixed by #126
Closed

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

timoll opened this issue Nov 22, 2021 · 1 comment · Fixed by #126

Comments

@timoll
Copy link
Contributor

timoll commented Nov 22, 2021

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;
}
@timoll
Copy link
Contributor Author

timoll commented Dec 13, 2021

The issue seems to be, that ColumnTuple has no implementation of Append

void Append(ColumnRef) override { }

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

Successfully merging a pull request may close this issue.

1 participant