You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2023/02/03 07:37:01 UTC

[spark] branch master updated: [MINOR][SQL] Enhance data type check error message

This is an automated email from the ASF dual-hosted git repository.

maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new a3c6b6b0232 [MINOR][SQL] Enhance data type check error message
a3c6b6b0232 is described below

commit a3c6b6b0232ddd3f09a2ed4b5e6a2f6e538c6733
Author: Yuming Wang <yu...@ebay.com>
AuthorDate: Fri Feb 3 10:36:44 2023 +0300

    [MINOR][SQL] Enhance data type check error message
    
    ### What changes were proposed in this pull request?
    
    This PR adds the expression to data type check error message.
    
    Before This PR:
    ```
    requirement failed: All input types must be the same except nullable, containsNull, valueContainsNull flags. The input types found are
            DecimalType(30,2)
            DecimalType(35,2).
    ```
    
    After this PR:
    ```
    requirement failed: All input types must be the same except nullable, containsNull, valueContainsNull flags. The expression is: CASE WHEN upper(TAX_STATE#472) IN (UK,EU) THEN bround((((QTY#507 * ITEM_PRICE#506) + coalesce(ITEM_SALES_TAX_AMT#510, 0.00)) / QTY#507), 2) ELSE cast(ITEM_PRICE#506 as decimal(35,2)) END. The input types found are
            DecimalType(30,2)
            DecimalType(35,2).
    ```
    ### Why are the changes needed?
    
    It is difficult to find out which expression has this issue when there are lots of expressions.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Manual testing.
    
    Closes #39851 from wangyum/Expression.
    
    Authored-by: Yuming Wang <yu...@ebay.com>
    Signed-off-by: Max Gekk <ma...@gmail.com>
---
 .../scala/org/apache/spark/sql/catalyst/expressions/Expression.scala | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
index de0e90285f5..7d5169ca8ef 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
@@ -1298,8 +1298,9 @@ trait ComplexTypeMergingExpression extends Expression {
       "The collection of input data types must not be empty.")
     require(
       TypeCoercion.haveSameType(inputTypesForMerging),
-      "All input types must be the same except nullable, containsNull, valueContainsNull flags." +
-        s" The input types found are\n\t${inputTypesForMerging.mkString("\n\t")}")
+      "All input types must be the same except nullable, containsNull, valueContainsNull flags. " +
+        s"The expression is: $this. " +
+        s"The input types found are\n\t${inputTypesForMerging.mkString("\n\t")}.")
   }
 
   private lazy val internalDataType: DataType = {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org