Skip to content

refactor: Replace throw std::invalid_argument with VELOX_USER_FAIL in presto-native-execution#27308

Merged
tanjialiang merged 1 commit intoprestodb:masterfrom
tanjialiang:export-D96025465
Mar 11, 2026
Merged

refactor: Replace throw std::invalid_argument with VELOX_USER_FAIL in presto-native-execution#27308
tanjialiang merged 1 commit intoprestodb:masterfrom
tanjialiang:export-D96025465

Conversation

@tanjialiang
Copy link
Copy Markdown
Contributor

@tanjialiang tanjialiang commented Mar 10, 2026

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

Summary by Sourcery

Normalize error handling in Presto native execution by replacing raw std::invalid_argument throws with Velox error macros for proper Presto error translation.

Bug Fixes:

  • Ensure invalid remote split URLs surface as proper Presto user errors by replacing std::invalid_argument with VELOX_FAIL in task ID extraction.
  • Classify unexpected Block types and unsupported RowExpression types as Velox user errors by converting std::invalid_argument throws to VELOX_UNSUPPORTED.
== NO RELEASE NOTE ==

@tanjialiang tanjialiang requested review from a team as code owners March 10, 2026 22:26
@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Mar 10, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Replaces raw std::invalid_argument throws in Presto native execution with Velox error macros so errors are properly classified and translated by Velox/Presto infrastructure, and refines the choice of macro based on whether the error is an unsupported feature or a generic failure.

Sequence diagram for updated error translation using Velox macros

sequenceDiagram
    actor User
    participant PrestoClient
    participant PrestoCoordinator
    participant PrestoWorker
    participant VeloxOperator
    participant VeloxToPrestoExceptionTranslator

    User->>PrestoClient: Submit query
    PrestoClient->>PrestoCoordinator: Send SQL query
    PrestoCoordinator->>PrestoWorker: Schedule tasks with splits

    PrestoWorker->>VeloxOperator: Process split / expression

    alt Invalid remote split URL (PrestoExchangeSource_extractTaskId)
        VeloxOperator->>VeloxOperator: VELOX_FAIL Cannot extract task ID
    else Unexpected Block type (VeloxExprConverter_getConstantValue)
        VeloxOperator->>VeloxOperator: VELOX_UNSUPPORTED Unexpected Block type
    else Unsupported RowExpression type (VeloxExprConverter_toVeloxExpr)
        VeloxOperator->>VeloxOperator: VELOX_UNSUPPORTED Unsupported RowExpression type
    end

    VeloxOperator-->>VeloxToPrestoExceptionTranslator: Propagate VeloxException
    VeloxToPrestoExceptionTranslator-->>PrestoWorker: Map to Presto user error code
    PrestoWorker-->>PrestoCoordinator: Return classified user error
    PrestoCoordinator-->>PrestoClient: Return Presto error response
    PrestoClient-->>User: Display user-facing error with proper code
Loading

File-Level Changes

Change Details Files
Replace raw exceptions in Presto-to-Velox expression conversion with Velox unsupported-error macros.
  • In getConstantValue, replace std::invalid_argument throw on unexpected Block type with VELOX_UNSUPPORTED using formatted type kind.
  • In toVeloxExpr, replace std::invalid_argument throw on unsupported RowExpression type with VELOX_UNSUPPORTED using formatted type string.
presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp
Replace raw exception in task ID extraction from remote split URL with Velox failure macro.
  • In extractTaskId, replace std::invalid_argument throw on failure to extract task ID with VELOX_FAIL using formatted URL path and keep existing logging.
presto-native-execution/presto_cpp/main/PrestoExchangeSource.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The commit message and summary mention replacing std::invalid_argument with VELOX_USER_FAIL, but the code uses VELOX_FAIL and VELOX_UNSUPPORTED; consider aligning the implementation and description and ensuring the chosen macros actually route these conditions to the intended user-facing error classification.
  • For extractTaskId, if this condition is considered a user input or configuration error rather than an internal failure, consider using the explicit user-error macro (e.g., VELOX_USER_FAIL) instead of VELOX_FAIL to avoid misclassifying the error.
  • For the unexpected Block type and unsupported RowExpression type cases, verify whether they should be treated as user errors or unsupported features, and choose between VELOX_USER_FAIL and VELOX_UNSUPPORTED accordingly so they map to the appropriate Presto error codes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The commit message and summary mention replacing `std::invalid_argument` with `VELOX_USER_FAIL`, but the code uses `VELOX_FAIL` and `VELOX_UNSUPPORTED`; consider aligning the implementation and description and ensuring the chosen macros actually route these conditions to the intended user-facing error classification.
- For `extractTaskId`, if this condition is considered a user input or configuration error rather than an internal failure, consider using the explicit user-error macro (e.g., `VELOX_USER_FAIL`) instead of `VELOX_FAIL` to avoid misclassifying the error.
- For the unexpected Block type and unsupported RowExpression type cases, verify whether they should be treated as user errors or unsupported features, and choose between `VELOX_USER_FAIL` and `VELOX_UNSUPPORTED` accordingly so they map to the appropriate Presto error codes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

gggrace14
gggrace14 previously approved these changes Mar 10, 2026
@tanjialiang tanjialiang changed the title Replace throw std::invalid_argument with VELOX_USER_FAIL in presto-native-execution refactor: Replace throw std::invalid_argument with VELOX_USER_FAIL in presto-native-execution Mar 10, 2026
…tive-execution (prestodb#27308)

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

Reviewed By: kewang1024

Differential Revision: D96025465
tanjialiang added a commit to tanjialiang/presto that referenced this pull request Mar 11, 2026
…tive-execution (prestodb#27308)

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

Reviewed By: kewang1024

Differential Revision: D96025465
@gggrace14 gggrace14 self-requested a review March 11, 2026 20:00
@tanjialiang tanjialiang merged commit c27afbb into prestodb:master Mar 11, 2026
81 of 82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants