Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
support decimal in SMJ
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
  • Loading branch information
zhouyuan committed Mar 9, 2021
1 parent 3211ec7 commit 3b47d46
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ case class ColumnarSortMergeJoinExec(
for (attr <- left.output) {
try {
ConverterUtils.checkIfTypeSupported(attr.dataType)
if (attr.dataType.isInstanceOf[DecimalType])
throw new UnsupportedOperationException(s"Unsupported data type: ${attr.dataType}")
} catch {
case e: UnsupportedOperationException =>
throw new UnsupportedOperationException(
Expand All @@ -358,8 +356,6 @@ case class ColumnarSortMergeJoinExec(
for (attr <- right.output) {
try {
ConverterUtils.checkIfTypeSupported(attr.dataType)
if (attr.dataType.isInstanceOf[DecimalType])
throw new UnsupportedOperationException(s"Unsupported data type: ${attr.dataType}")
} catch {
case e: UnsupportedOperationException =>
throw new UnsupportedOperationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,6 @@ object ColumnarSortMergeJoin extends Logging {
conditionOption: Option[Expression]): TreeNode = {
/////// Build side ///////
val buildInputFieldList: List[Field] = buildInputAttributes.toList.map(attr => {
if (attr.dataType.isInstanceOf[DecimalType])
throw new UnsupportedOperationException(
s"Decimal type is not supported in ColumnarShuffledHashJoin.")
Field
.nullable(s"${attr.name}#${attr.exprId.id}", CodeGeneration.getResultType(attr.dataType))
})
Expand All @@ -687,9 +684,6 @@ object ColumnarSortMergeJoin extends Logging {
})
/////// Streamed side ///////
val streamedInputFieldList: List[Field] = streamedInputAttributes.toList.map(attr => {
if (attr.dataType.isInstanceOf[DecimalType])
throw new UnsupportedOperationException(
s"Decimal type is not supported in ColumnarShuffledHashJoin.")
Field
.nullable(s"${attr.name}#${attr.exprId.id}", CodeGeneration.getResultType(attr.dataType))
})
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/codegen/arrow_compute/ext/merge_join_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,16 @@ class ConditionedJoinArraysKernel::Impl {
}
std::string GetResultIteratorPrepare() {
std::stringstream ss;
if (data_type_->id() == arrow::Type::DECIMAL) {
ss << "builder_" << indice_ << "_ = std::make_shared<"
<< GetTypeString(data_type_, "Builder")
<< ">(arrow::" << GetArrowTypeDefString(data_type_)
<< ", ctx_->memory_pool());" << std::endl;
} else {
ss << "builder_" << indice_ << "_ = std::make_shared<"
<< GetTypeString(data_type_, "Builder") << ">(ctx_->memory_pool());"
<< std::endl;
}
return ss.str();
}
std::string GetProcessFinish() {
Expand Down
1 change: 1 addition & 0 deletions cpp/src/codegen/common/relation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ arrow::Status MakeHashRelationColumn(uint32_t data_type_id,
PROCESS(arrow::DoubleType) \
PROCESS(arrow::Date32Type) \
PROCESS(arrow::Date64Type) \
PROCESS(arrow::Decimal128Type) \
PROCESS(arrow::StringType)
arrow::Status MakeRelationColumn(uint32_t data_type_id,
std::shared_ptr<RelationColumn>* out) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/codegen/common/relation_column.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "precompile/type_traits.h"

using sparkcolumnarplugin::precompile::enable_if_number;
using sparkcolumnarplugin::precompile::enable_if_number_or_decimal;
using sparkcolumnarplugin::precompile::enable_if_string_like;
using sparkcolumnarplugin::precompile::StringArray;
using sparkcolumnarplugin::precompile::TypeTraits;
Expand All @@ -45,7 +45,7 @@ template <typename T, typename Enable = void>
class TypedRelationColumn {};

template <typename DataType>
class TypedRelationColumn<DataType, enable_if_number<DataType>> : public RelationColumn {
class TypedRelationColumn<DataType, enable_if_number_or_decimal<DataType>> : public RelationColumn {
public:
using T = typename TypeTraits<DataType>::CType;
TypedRelationColumn() {}
Expand Down

0 comments on commit 3b47d46

Please sign in to comment.