Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20680][SQL] Adding HiveVoidType in Spark to be compatible with Hive - #28935
[SPARK-20680][SQL] Adding HiveVoidType in Spark to be compatible with Hive#28935LantaoJin wants to merge 7 commits into
Conversation
HyukjinKwon
left a comment
There was a problem hiding this comment.
We should also fix
spark/python/pyspark/sql/tests/test_types.py
Line 486 in 68d7edf
null type at spark/python/pyspark/sql/types.py
Line 752 in d21aab4
I am okay if you're not used to Python side - I can do it in a followup.
LantaoJin
commented
Jun 28, 2020
Thanks @HyukjinKwon, if this could be merged, can you help on python side? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| * and should NOT be used anywhere else. Any instance of these data types should be | ||
| * replaced by a [[NullType]] before analysis. | ||
| */ | ||
| class HiveNullType private() extends DataType { |
There was a problem hiding this comment.
I know the context, but can we name this HiveVoidType literally?
There was a problem hiding this comment.
Currently, the description is interpreted like "hive null type should be replaced by a NullType before analysis".
There was a problem hiding this comment.
null is a value and Hive exposes void as a type.
There was a problem hiding this comment.
nullis avalueand Hive exposesvoidas a type.
You are right.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
dongjoon-hyun
commented
Jun 28, 2020
Thank you for working on this, @LantaoJin ! |
SparkQA
commented
Jun 28, 2020
Test build #124583 has finished for PR 28935 at commit
|
SparkQA
commented
Jun 28, 2020
Test build #124584 has finished for PR 28935 at commit
|
SparkQA
commented
Jun 28, 2020
Test build #124590 has finished for PR 28935 at commit
|
LantaoJin
commented
Jun 28, 2020
retest this please |
SparkQA
commented
Jun 28, 2020
Test build #124597 has finished for PR 28935 at commit
|
dongjoon-hyun
commented
Jun 28, 2020
Thank you for updating, @LantaoJin . |
dongjoon-hyun
commented
Jun 28, 2020
@LantaoJin . Is there a reason why you use
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
LantaoJin
commented
Jun 29, 2020
No, just typo. Fixed. |
Uh oh!
There was an error while loading. Please reload this page.
| case ("decimal" | "dec" | "numeric", precision :: scale :: Nil) => | ||
| DecimalType(precision.getText.toInt, scale.getText.toInt) | ||
| case ("interval", Nil) => CalendarIntervalType | ||
| case ("void", Nil) => HiveVoidType |
There was a problem hiding this comment.
We can just reuse NullType. We should forbid creating table with null type completely, including spark.catalog.createTable.
SparkQA
commented
Jun 29, 2020
Test build #124614 has finished for PR 28935 at commit
|
SparkQA
commented
Jun 29, 2020
Test build #124639 has started for PR 28935 at commit |
cloud-fan
commented
Jun 29, 2020
I think we need two changes:
These two changes can be done with 2 PRs. |
LantaoJin
commented
Jun 29, 2020
Yes. This PR is for the second change. |
cloud-fan
commented
Jun 29, 2020
we need to do 1 first, otherwise it makes users be able to create tables with void type via CREATE TABLE command, while it was not possible before as the parser doesn't support it. |
Ah, now I understood the context. The 5th commit should be reverted in this PR, otherwise the UT will fail. And we need to do 1 first. I will work on that tomorrow. My laptop is out of power now. |
LantaoJin
commented
Jun 30, 2020
@cloud-fan I refactor some codes, now I think this PR could be no dependency. |
| } | ||
| // Add Hive type string to metadata. | ||
| val cleanedDataType = HiveStringType.replaceCharType(dataType) | ||
| // Add Hive type 'string' and 'void' to metadata. |
There was a problem hiding this comment.
we can be more aggressive here: forbid void type in all cases, including hive tables.
| */ | ||
| private def visitSparkDataType(ctx: DataTypeContext): DataType = { | ||
| HiveStringType.replaceCharType(typedVisit(ctx)) | ||
| HiveVoidType.replaceVoidType(HiveStringType.replaceCharType(typedVisit(ctx))) |
There was a problem hiding this comment.
I don't get it why we need HiveVoidType. What happens if we just parse void to NullType?
There was a problem hiding this comment.
Because that could indicate VOID is a Hive type, the handle processing is more unified. Or, we can just use the PR #28833
There was a problem hiding this comment.
For example, below function will point the failure is due to the legacy hive void type. If we mix VOID and NULL, I am not sure it would be better than separation.
deffailVoidType(dt: DataType):Unit= {
if (HiveVoidType.containsVoidType(dt)) {
thrownewAnalysisException(
"Cannot create tables with Hive VOID type.")
}
}There was a problem hiding this comment.
VOID and NULL are indeed the same type. We can just check null type and fail with error message: Cannot create tables with VOID type
There was a problem hiding this comment.
The point is consistency: The VOID type in SQL statement should be the same as NullType specified by Scala API in spark.catalog.createTable.
There was a problem hiding this comment.
@cloud-fan , ok. I will follow your suggestion to fix it in #28833 , since this PR is a refator with new type HiveVoidType. Now we don't need it.
SparkQA
commented
Jun 30, 2020
Test build #124657 has finished for PR 28935 at commit
|
LantaoJin
commented
Jul 8, 2020
Close this since #28833 merged. Thank you! |
What changes were proposed in this pull request?
This is to address the close one #17953, as a refactor for #28833
Adding
HiveVoidType, likeHiveStringType, to prevent from exception when describe tables/views which the schema contain Hive VOID/NULL type.Why are the changes needed?
Spark is incompatible with hive void type. When Hive table schema contains void type, DESC table will throw an exception in Spark.
In Spark2.0.x, the behaviour to read this view is normal:
But in lastest Spark version, it failed with SparkException: Cannot recognize hive type string: void
Does this PR introduce any user-facing change?
No
How was this patch tested?
Add unit tests
Also can manual tests