Reading LowCardinality(Nullable(String)) column is not supported (for the data received from ClickHouse)

Aberta
#504 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Pouca atividade
Stack de tecnologia
cpp
Domínio
databases

Direção de pesquisa

Comece em clickhouse/columns/factory.cpp, na parte referente ao tratamento de Nullable, e compare com ut/roundtrip_tests.cpp em Map_LowCardinalityTString_LowCardinalityTNullableString_. Inspecione ColumnRef::As e GetType().GetName() para as colunas recebidas do ClickHouse, em vez de considerar apenas as colunas construídas localmente. A tarefa estará concluída quando dados LowCardinality(Nullable(String)) puderem ser lidos de uma resposta real do ClickHouse e houver um teste de regressão.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug data-types documentation

Please see https://github.com/ClickHouse/clickhouse-cpp/pull/339

This one confirms that it works

Perhaps, it would be helpful to know the real type of column at run-time with:


column->GetType().GetName()

Originally posted by @Enmk in #326

The test Map_LowCardinalityTString_LowCardinalityTNullableString might succeed, but this is only true because you create the column with the type ColumnLowCardinalityT<ColumnNullableT<ColumnString>> explicitly in the test.

However, for the real data received from ClickHouse the type of the underlying column will be simply ColumnLowCardinality. This is probably due to the logic implemented in https://github.com/ClickHouse/clickhouse-cpp/pull/182:

case Type::Nullable:
    return std::make_shared<ColumnLowCardinality>(
        std::make_shared<ColumnNullable>(
            CreateColumnFromAst(GetASTChildElement(nested, 0), settings),
            std::make_shared<ColumnUInt8>()
        )
    );

Therefore the dynamic_cast inside column->As<ColumnLowCardinalityT<ColumnNullableT<ColumnString>>>() will yield nullptr.

This is easily illustrated with a simple typeid check (assume that column is an instance of a ColumnRef pointer).

This is what we have for LowCardinality(String) column:

// ColumnRef column;

auto type_name = column->GetType().GetName(); // "LowCardinality(String)"

auto type_id = typeid(*column).name(); // clickhouse::ColumnLowCardinalityT<clickhouse::ColumnString> ("N10clickhouse21ColumnLowCardinalityTINS_12ColumnStringEEE")

And this is the result for LowCardinality(Nullable(String)):

// ColumnRef column;

auto type_name = column->GetType().GetName(); // "LowCardinality(Nullable(String))"

auto type_id = typeid(*column).name(); // clickhouse::ColumnLowCardinality ("N10clickhouse20ColumnLowCardinalityE")

The conclusion is that it's not possible to read LowCardinality(Nullable(String)) column in the current version of clickhouse-cpp (v2.6.1):

  1. column->As<ColumnLowCardinalityT<ColumnNullableT<ColumnString>>>() doesn't work for the reasons explained above.
  2. While column->As<ColumnLowCardinality>() does work, it's of no help: trying to wrap the result into ColumnLowCardinalityT<ColumnNullableT<ColumnString>> will also fail because the nested type is ColumnNullable (not ColumnNullableT<ColumnString>).
  3. Declaring ColumnLowCardinalityT<ColumnNullable> is not possible because there's no ValueType alias in ColumnNullable.
Linguagem predominante
C
Estrelas
388
Forks
220
Merge médio
1d 25min
PRs com merge (30d)
16

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de ClickHouse/clickhouse-cpp

Todas as issues de ClickHouse/clickhouse-cpp

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.