You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "2010YOUY01 (via GitHub)" <gi...@apache.org> on 2025/03/30 03:56:02 UTC

[I] Support macro `ensore_or_internal_err` to clean up repeated sanity checks [datafusion]

2010YOUY01 opened a new issue, #15492:
URL: https://github.com/apache/datafusion/issues/15492

   ### Is your feature request related to a problem or challenge?
   
   When implementing complex logic, it's common to include assertions as sanity checks to catch potential errors.
   The Rust `assert!(...)` macro will panic if the condition is false, but in most cases, we want to avoid panicking (which would crash the application). Instead, we prefer to return an internal error to indicate a potential bug. For example:
   https://github.com/apache/datafusion/blob/e2b7919e28c56e618231c4b4489d452ee1ef5a8c/datafusion/physical-plan/src/joins/hash_join.rs#L786-L792
   
   ### Describe the solution you'd like
   
   Implement a macro to throw an internal error when assertion failed
   ```rust
   ensure_or_internal_err!(
       !(self.mode == PartitionMode::Partitioned && left_partitions != right_partitions),
       "Invalid HashJoinExec, partition count mismatch {left_partitions}!={right_partitions},\ 
                     consider using RepartitionExec"
   );
   ```
   Perhaps we can create another `forbid_or_internal_err` for false assertions to make it more clear 🤔 
   
   I think this approach only cleaned things up a little, but this check-and-internal-err pattern is very common (used hundreds of times inside the current datafusion source), so I think this chore task is worth the effort.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] Support macro `ensure_or_internal_err` to clean up repeated sanity checks [datafusion]

Posted by "alan910127 (via GitHub)" <gi...@apache.org>.
alan910127 commented on issue #15492:
URL: https://github.com/apache/datafusion/issues/15492#issuecomment-2764511135

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] Support macro `ensure_or_internal_err` to clean up repeated sanity checks [datafusion]

Posted by "2010YOUY01 (via GitHub)" <gi...@apache.org>.
2010YOUY01 closed issue #15492: Support macro `ensure_or_internal_err` to clean up repeated sanity checks
URL: https://github.com/apache/datafusion/issues/15492


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org