Skip to content

Commit 8804d3d

Browse files
committed
fix(native): Fix inserting decimal type values precision and scale
1 parent e948a9d commit 8804d3d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "presto_cpp/main/operators/ShuffleRead.h"
3636
#include "presto_cpp/main/operators/ShuffleWrite.h"
3737
#include "presto_cpp/main/types/TypeParser.h"
38+
#include "velox/connectors/hive/HiveDataSink.h"
3839
#include "velox/exec/TraceUtil.h"
3940

4041
using namespace facebook::velox;
@@ -75,6 +76,19 @@ RowTypePtr toRowType(
7576
return ROW(std::move(names), std::move(types));
7677
}
7778

79+
RowTypePtr toRowType(
80+
const std::vector<protocol::VariableReferenceExpression>& variables,
81+
const std::vector<TypePtr>& types) {
82+
VELOX_CHECK_EQ(types.size(), variables.size());
83+
std::vector<std::string> names;
84+
names.reserve(variables.size());
85+
for (const auto& variable : variables) {
86+
names.emplace_back(variable.name);
87+
}
88+
89+
return ROW(std::move(names), std::move(types));
90+
}
91+
7892
std::shared_ptr<connector::ColumnHandle> toColumnHandle(
7993
const protocol::ColumnHandle* column,
8094
const TypeParser& typeParser) {
@@ -1526,9 +1540,18 @@ VeloxQueryPlanConverterBase::toVeloxQueryPlan(
15261540
sourceVeloxPlan,
15271541
tableWriteInfo,
15281542
taskId);
1543+
1544+
std::vector<TypePtr> tableTypes;
1545+
auto inputColumns =
1546+
std::dynamic_pointer_cast<const connector::hive::HiveInsertTableHandle>(
1547+
insertTableHandle->connectorInsertTableHandle())
1548+
->inputColumns();
1549+
for (const auto& inputColumn : inputColumns) {
1550+
tableTypes.emplace_back(inputColumn->dataType());
1551+
}
15291552
return std::make_shared<core::TableWriteNode>(
15301553
node->id,
1531-
toRowType(node->columns, typeParser_),
1554+
toRowType(node->columns, tableTypes),
15321555
node->columnNames,
15331556
columnStatsSpec,
15341557
std::move(insertTableHandle),

0 commit comments

Comments
 (0)