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

Abierto
#504 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
cpp
Área
databases

Línea de trabajo

Comienza en clickhouse/columns/factory.cpp, alrededor del manejo de Nullable, y compáralo con ut/roundtrip_tests.cpp en Map_LowCardinalityTString_LowCardinalityTNullableString_. Inspecciona ColumnRef::As y GetType().GetName() para las columnas recibidas de ClickHouse, en lugar de examinar únicamente las columnas construidas localmente. La tarea está terminada cuando los datos LowCardinality(Nullable(String)) se puedan leer de una respuesta real de ClickHouse y exista una prueba de regresión.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
C
Estrellas
388
Forks
220
Merge medio
1 d 25 min
PR fusionados (30 d)
16

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ClickHouse/clickhouse-cpp

Todos los issues de ClickHouse/clickhouse-cpp

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.