removing LC in AVRO input format if needed

This commit is contained in:
myrrc 2020-10-29 20:24:54 +03:00
parent 46db8a2d51
commit 68b47f5f61

View File

@ -1,4 +1,5 @@
#include "AvroRowInputFormat.h"
#include "DataTypes/DataTypeLowCardinality.h"
#if USE_AVRO
#include <numeric>
@ -174,7 +175,10 @@ static std::string nodeName(avro::NodePtr node)
AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(avro::NodePtr root_node, DataTypePtr target_type)
{
WhichDataType target(target_type);
const WhichDataType target = target_type->getTypeId() == TypeIndex::LowCardinality
? removeLowCardinality(target_type)
: target_type;
switch (root_node->type())
{
case avro::AVRO_STRING: [[fallthrough]];
@ -384,7 +388,8 @@ AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(avro::Node
}
throw Exception(
"Type " + target_type->getName() + " is not compatible with Avro " + avro::toString(root_node->type()) + ":\n" + nodeToJson(root_node),
"Type " + target_type->getName() + " is not compatible with Avro " + avro::toString(root_node->type()) + ":\n"
+ nodeToJson(root_node),
ErrorCodes::ILLEGAL_COLUMN);
}