Skip to content

Conversation

@petermaxlee
Copy link
Contributor

What changes were proposed in this pull request?

Greatest/least function does not have the most friendly error message for data types. This patch improves the error message to not show the Seq type, and use more human readable data types.

Before:

org.apache.spark.sql.AnalysisException: cannot resolve 'greatest(CAST(1.0 AS DECIMAL(2,1)), "1.0")' due to data type mismatch: The expressions should all have the same type, got GREATEST (ArrayBuffer(DecimalType(2,1), StringType)).; line 1 pos 7

After:

org.apache.spark.sql.AnalysisException: cannot resolve 'greatest(CAST(1.0 AS DECIMAL(2,1)), "1.0")' due to data type mismatch: The expressions should all have the same type, got GREATEST(decimal(2,1), string).; line 1 pos 7

How was this patch tested?

Manually verified the output and also added unit tests to ConditionalExpressionSuite.

@petermaxlee
Copy link
Contributor Author

@cloud-fan please take a look. A small issue I found when I was working on the other pull request.

@cloud-fan
Copy link
Contributor

LGTM

@cloud-fan
Copy link
Contributor

BTW how about we move Greatest and Least to arithmetic.scala? They are not conditional expressions...

@SparkQA
Copy link

SparkQA commented Aug 2, 2016

Test build #63109 has finished for PR 14453 at commit 1043df4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 2, 2016

Test build #63110 has finished for PR 14453 at commit e701a15.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@asfgit asfgit closed this in a1ff72e Aug 2, 2016
@cloud-fan
Copy link
Contributor

thanks. merging to master!

@rxin
Copy link
Contributor

rxin commented Aug 2, 2016

Yea we should probably move those.

@rxin
Copy link
Contributor

rxin commented Aug 2, 2016

I've also cherry picked this into branch-2.0.

asfgit pushed a commit that referenced this pull request Aug 2, 2016
…east

Greatest/least function does not have the most friendly error message for data types. This patch improves the error message to not show the Seq type, and use more human readable data types.

Before:
```
org.apache.spark.sql.AnalysisException: cannot resolve 'greatest(CAST(1.0 AS DECIMAL(2,1)), "1.0")' due to data type mismatch: The expressions should all have the same type, got GREATEST (ArrayBuffer(DecimalType(2,1), StringType)).; line 1 pos 7
```

After:
```
org.apache.spark.sql.AnalysisException: cannot resolve 'greatest(CAST(1.0 AS DECIMAL(2,1)), "1.0")' due to data type mismatch: The expressions should all have the same type, got GREATEST(decimal(2,1), string).; line 1 pos 7
```

Manually verified the output and also added unit tests to ConditionalExpressionSuite.

Author: petermaxlee <[email protected]>

Closes #14453 from petermaxlee/SPARK-16850.

(cherry picked from commit a1ff72e)
Signed-off-by: Reynold Xin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants