Skip to content

Commit 20164ec

Browse files
committed
support allowDecimalPrecisionLoss
Signed-off-by: Yuan Zhou <[email protected]>
1 parent 94c8e7e commit 20164ec

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

cpp/core/config/GlutenConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const std::string kLegacySize = "spark.sql.legacy.sizeOfNull";
3434

3535
const std::string kSessionTimezone = "spark.sql.session.timeZone";
3636

37+
const std::string kAllowPrecisionLoss = "spark.sql.decimalOperations.allowPrecisionLoss";
38+
3739
const std::string kIgnoreMissingFiles = "spark.sql.files.ignoreMissingFiles";
3840

3941
const std::string kDefaultSessionTimezone = "spark.gluten.sql.session.timeZone.default";

cpp/velox/compute/WholeStageResultIterator.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ std::unordered_map<std::string, std::string> WholeStageResultIterator::getQueryC
444444
veloxCfg_->get<std::string>(kSessionTimezone, defaultTimezone);
445445
// Adjust timestamp according to the above configured session timezone.
446446
configs[velox::core::QueryConfig::kAdjustTimestampToTimezone] = std::to_string(true);
447+
// To align with Spark's behavior, allow decimal precision loss or not.
448+
configs[velox::core::QueryConfig::kAllowPrecisionLoss] = getConfigValue(confMap_, kAllowPrecisionLoss, "true");
447449
// Align Velox size function with Spark.
448450
configs[velox::core::QueryConfig::kSparkLegacySizeOfNull] = std::to_string(veloxCfg_->get<bool>(kLegacySize, true));
449451

ep/build-velox/src/get_velox.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
set -exu
1818

19-
VELOX_REPO=https://github.com/oap-project/velox.git
20-
VELOX_BRANCH=2024_02_27
19+
VELOX_REPO=https://github.com/zhouyuan/velox.git
20+
VELOX_BRANCH=wip_decimal_precision_loss
2121
VELOX_HOME=""
2222

2323
#Set on run gluten on HDFS

gluten-core/src/main/scala/io/glutenproject/expression/ExpressionConverter.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,6 @@ object ExpressionConverter extends SQLConfHelper with Logging {
471471
replaceWithExpressionTransformerInternal(_, attributeSeq, expressionsMap)),
472472
expr)
473473
case b: BinaryArithmetic if DecimalArithmeticUtil.isDecimalArithmetic(b) =>
474-
// PrecisionLoss=true: velox support / ch not support
475-
// PrecisionLoss=false: velox not support / ch support
476-
// TODO ch support PrecisionLoss=true
477-
if (!BackendsApiManager.getSettings.allowDecimalArithmetic) {
478-
throw new UnsupportedOperationException(
479-
s"Not support ${SQLConf.DECIMAL_OPERATIONS_ALLOW_PREC_LOSS.key} " +
480-
s"${conf.decimalOperationsAllowPrecisionLoss} mode")
481-
}
482474
val rescaleBinary = if (BackendsApiManager.getSettings.rescaleDecimalLiteral) {
483475
DecimalArithmeticUtil.rescaleLiteral(b)
484476
} else {

0 commit comments

Comments
 (0)