Paul Rogers created IMPALA-7899:
-----------------------------------

             Summary: RuntimeFilterGenerator uses Preconditions for normal 
conditions
                 Key: IMPALA-7899
                 URL: https://issues.apache.org/jira/browse/IMPALA-7899
             Project: IMPALA
          Issue Type: Bug
          Components: Frontend
    Affects Versions: Impala 3.0
            Reporter: Paul Rogers
            Assignee: Paul Rogers


The {{RuntimeFilterGenerator.computeTargetExpr()}} checks if a value can be 
cast to a given type. It does so by calling {{Expr.castTo()}}, which uses the 
following technique to report that the cast is not valid:
{code:java}
      Preconditions.checkArgument(targetType.equals(type),
          "targetType=" + targetType + " type=" + type);
{code}
This condition occurs in {{PlannerTest}}. So, if I have a breakpoint set to 
catch {{Preconditions}} failures, that breakpoint is hit on every run. I have 
to remember, "oh, yeah, it is OK that we are violating this invariant."

In general, it is bad practice to use things like {{assert}}, {{Preconditions}} 
or unchecked exceptions to report "expected" conditions: it muddies the water 
about what is an invariant or is not.

Instead, use a checked, purpose-built exception, such as {{SqlCastException}}, 
to report such errors, and include comments that the exception will be thrown 
for expected illegal casts.

Or, better, restructure the method so that there is one version that is 
expected to succeed (the current one), and another that returns null if the 
cast is not legal. Have the enforcing version call the returning-null version.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to