MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / initializeTransformCache

Function initializeTransformCache

src/Functions/transform.cpp:711–844  ·  view source on GitHub ↗

Initialize the transform cache from the constant arguments.

Source from the content-addressed store, hash-verified

709
710 /// Initialize the transform cache from the constant arguments.
711 TransformCachePtr initializeTransformCache(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type)
712 {
713 auto cache = std::make_shared<TransformCache>();
714
715 const DataTypePtr & from_type = arguments[0].type;
716
717 if (from_type->onlyNull())
718 {
719 cache->is_empty = true;
720 return cache;
721 }
722
723 const ColumnArray * array_from = checkAndGetColumnConstData<ColumnArray>(arguments[1].column.get());
724 const ColumnArray * array_to = checkAndGetColumnConstData<ColumnArray>(arguments[2].column.get());
725
726 if (!array_from || !array_to)
727 throw Exception(
728 ErrorCodes::ILLEGAL_COLUMN, "Second and third arguments of function {} must be constant arrays", "transform");
729
730 const ColumnPtr & from_column_uncast = array_from->getDataPtr();
731
732 cache->from_column = castColumn(
733 {
734 from_column_uncast,
735 typeid_cast<const DataTypeArray &>(*arguments[1].type).getNestedType(),
736 arguments[1].name
737 },
738 from_type);
739
740 cache->to_column = castColumn(
741 {
742 array_to->getDataPtr(),
743 typeid_cast<const DataTypeArray &>(*arguments[2].type).getNestedType(),
744 arguments[2].name
745 },
746 result_type);
747
748 const size_t size = cache->from_column->size();
749 if (0 == size)
750 {
751 cache->is_empty = true;
752 return cache;
753 }
754
755 if (cache->to_column->size() != size)
756 throw Exception(
757 ErrorCodes::BAD_ARGUMENTS, "Second and third arguments of function {} must be arrays of same size", "transform");
758
759 /// Whether the default value is set.
760 if (arguments.size() == 4)
761 {
762 const IColumn * default_col = arguments[3].column.get();
763 if (default_col && isColumnConst(*default_col))
764 {
765 if (default_col->onlyNull())
766 {
767 auto default_column = result_type->createColumn();
768 default_column->insertDefault();

Callers 2

executeImplMethod · 0.85
buildImplMethod · 0.85

Calls 15

castColumnFunction · 0.85
isColumnConstFunction · 0.85
accurateEqualsFunction · 0.85
memcpyFunction · 0.85
getNestedTypeMethod · 0.80
isDecimal32Method · 0.80
isDecimal64Method · 0.80
isEnumMethod · 0.80
ExceptionClass · 0.50
onlyNullMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected