From fc96870253552851f94c8e60fa22906946ec4428 Mon Sep 17 00:00:00 2001 From: jtan6 Date: Tue, 10 Mar 2026 16:59:32 -0700 Subject: [PATCH 1/2] Replace throw std::invalid_argument with VELOX_USER_FAIL in presto-native-execution Summary: 3 production sites throw raw `std::invalid_argument`, which bypasses `VeloxToPrestoExceptionTranslator` and misclassifies user errors as `GENERIC_INTERNAL_ERROR`. Replace them with `VELOX_USER_FAIL` so they are properly translated to user-facing Presto error codes. Sites fixed: - `PrestoExchangeSource.cpp` - invalid task ID in remote split URL - `PrestoToVeloxExpr.cpp:131` - unexpected Block type - `PrestoToVeloxExpr.cpp:905` - unsupported RowExpression type Differential Revision: D96025465 --- .../presto_cpp/main/PrestoExchangeSource.cpp | 3 +-- .../presto_cpp/main/types/PrestoToVeloxExpr.cpp | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp b/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp index 53d847cbc15c7..df2e28dd98dba 100644 --- a/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp +++ b/presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp @@ -38,8 +38,7 @@ std::string extractTaskId(const std::string& path) { VLOG(1) << "Failed to extract task ID from remote split: " << path; - throw std::invalid_argument( - fmt::format("Cannot extract task ID from remote split URL: {}", path)); + VELOX_FAIL("Cannot extract task ID from remote split URL: {}", path); } void onFinalFailure( diff --git a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp index 9108561395e8c..5f7cb4b62883b 100644 --- a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp +++ b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp @@ -128,8 +128,7 @@ velox::variant VeloxExprConverter::getConstantValue( std::string(valueVector->as>() ->valueAt(0))); default: - throw std::invalid_argument( - fmt::format("Unexpected Block type: {}", typeKind)); + VELOX_UNSUPPORTED("Unexpected Block type: {}", typeKind); } } @@ -902,8 +901,7 @@ TypedExprPtr VeloxExprConverter::toVeloxExpr( return toVeloxExpr(lambda); } - throw std::invalid_argument( - "Unsupported RowExpression type: " + pexpr->_type); + VELOX_UNSUPPORTED("Unsupported RowExpression type: {}", pexpr->_type); } } // namespace facebook::presto From 7ad50bbd4e11c16343dffee720b7eace4ff0dc9b Mon Sep 17 00:00:00 2001 From: Jialiang Tan Date: Tue, 10 Mar 2026 17:14:29 -0700 Subject: [PATCH 2/2] Replace raw assert() with VELOX_CHECK in PrestoToVeloxConnectorUtils (#27306) Summary: Pull Request resolved: https://github.com/prestodb/presto/pull/27306 2 raw C `assert()` calls are no-ops in release builds (NDEBUG), meaning these invariant checks silently disappear in production. Replace with `VELOX_CHECK_LE` and `VELOX_CHECK_GT` which are always active and provide better error messages on failure. Reviewed By: kewang1024 Differential Revision: D95995395 --- .../main/connectors/PrestoToVeloxConnectorUtils.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnectorUtils.cpp b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnectorUtils.cpp index a33075ab503e8..0cf8624456f35 100644 --- a/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnectorUtils.cpp +++ b/presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnectorUtils.cpp @@ -16,6 +16,7 @@ #include #include "presto_cpp/main/types/TypeParser.h" +#include "velox/common/base/Exceptions.h" #include "velox/connectors/hive/TableHandle.h" #include "velox/type/fbhive/HiveTypeParser.h" @@ -389,7 +390,8 @@ std::unique_ptr combineIntegerRanges( if (bigintFilters.size() == 2 && bigintFilters[0]->lower() == std::numeric_limits::min() && bigintFilters[1]->upper() == std::numeric_limits::max()) { - assert(bigintFilters[0]->upper() + 1 <= bigintFilters[1]->lower() - 1); + VELOX_CHECK_LE( + bigintFilters[0]->upper() + 1, bigintFilters[1]->lower() - 1); return std::make_unique( bigintFilters[0]->upper() + 1, bigintFilters[1]->lower() - 1, @@ -398,7 +400,7 @@ std::unique_ptr combineIntegerRanges( bool allNegatedValues = true; bool foundMaximum = false; - assert(bigintFilters.size() > 1); // true by size checks on ranges + VELOX_CHECK_GT(bigintFilters.size(), 1); std::vector rejectedValues; // check if int64 min is a rejected value