Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20680][SQL] Spark-sql do not support for void column datatype … - #17953
[SPARK-20680][SQL] Spark-sql do not support for void column datatype …#17953LantaoJin wants to merge 2 commits into
Conversation
hvanhovell
commented
May 11, 2017
ok to test |
There was a problem hiding this comment.
This change really resolves your issue?
There was a problem hiding this comment.
Apparently Hive can have null typed columns. So this should be the location where you'd want to change this.
There was a problem hiding this comment.
Hive 2.x disables it. Could you add some test cases by reading and writing the tables with void types? Thanks!
SparkQA
commented
May 12, 2017
Test build #76834 has finished for PR 17953 at commit
|
hvanhovell
commented
May 12, 2017
@LantaoJin Can you add a description and a test case for this? You can take a look at the OrcSourceSuite to get an idea how to work with Hive. |
SparkQA
commented
May 12, 2017
Test build #76866 has finished for PR 17953 at commit
|
gatorsmile
commented
May 14, 2017
Are your test scenario is like? withTable("t", "tabNullType") {
valclient= spark.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client
client.runSqlHive("CREATE TABLE t (t1 int)")
client.runSqlHive("INSERT INTO t VALUES (3)")
client.runSqlHive("CREATE TABLE tabNullType AS SELECT NULL AS col FROM t")
spark.table("tabNullType").show()
spark.table("tabNullType").printSchema()
}Is this what you want? |
LantaoJin
commented
May 15, 2017
@gatorsmile Yes, it's the right test scenario. Which class should I add to? |
There was a problem hiding this comment.
Could you add a comment to explain this specific scenario?
gatorsmile
commented
May 15, 2017
Maybe |
LantaoJin
commented
May 16, 2017
Add a test in HiveDDLSuite. Please review, thanks. |
SparkQA
commented
May 16, 2017
Test build #76968 has finished for PR 17953 at commit
|
gatorsmile
commented
May 16, 2017
After this PR, we can describe it, but the query results are still empty. |
LantaoJin
commented
May 17, 2017
Thanks, I add a row to the table |
SparkQA
commented
May 17, 2017
Test build #77001 has finished for PR 17953 at commit
|
SparkQA
commented
May 17, 2017
Test build #77000 has finished for PR 17953 at commit
|
SparkQA
commented
May 17, 2017
Test build #77002 has finished for PR 17953 at commit
|
There was a problem hiding this comment.
From the Jenkins, I saw below error message:
org.scalatest.exceptions.TestFailedException: StructType(StructField(col,NullType,true)) did not contain StructField(col,NullType,true)
But it can passed from my spark-shell:
scala> val schema = spark.table("tabNullType").schema
schema: org.apache.spark.sql.types.StructType = StructType(StructField(col,NullType,true))
scala> schema.contains(StructField("col", NullType))
res7: Boolean = true
cloud-fan
commented
May 17, 2017
I don't think we should support |
SparkQA
commented
May 20, 2017
Test build #77115 has started for PR 17953 at commit |
LantaoJin
commented
May 20, 2017
Thanks @cloud-fan . Hi @hvanhovell and @gatorsmile , any ideas? |
cloud-fan
commented
May 21, 2017
retest this please |
SparkQA
commented
May 21, 2017
Test build #77150 has finished for PR 17953 at commit
|
There was a problem hiding this comment.
-> checkAnswer(spark.table("tabNullType"), Row(null))?
There was a problem hiding this comment.
In class NullType, we can add the following line:
override def simpleString: String = "void"
There was a problem hiding this comment.
After the above change, you can improve the test to
valdesc= sql("DESC tabNullType").collect().toSeq
assert(desc.contains(Row("col", "void", null)))gatorsmile
commented
May 22, 2017
LGTM except two comments. |
gatorsmile
commented
May 29, 2017
ping @LantaoJin |
LantaoJin
commented
Jun 3, 2017
Thanks @gatorsmile , I took a vacation last week. Will update it ASAP. |
dongjoon-hyun
commented
Jun 3, 2017
Retest this please |
gatorsmile
commented
Jun 4, 2017
retest this please |
gatorsmile
commented
Jun 4, 2017
ok to test |
cloud-fan
commented
Jun 4, 2017
shall we add a test case for |
cloud-fan
commented
Jun 4, 2017
I think a safer fix is to just handle "void" specially in |
cloud-fan
commented
Jun 4, 2017
oh actually users can still create a table with null type column via |
SparkQA
commented
Jun 4, 2017
Test build #77723 has finished for PR 17953 at commit
|
All failed tests due to mis-match of *.sql.out with the new "void" simple string of NullType.
|
LantaoJin
commented
Jun 6, 2017
Ahh, found it. Re-generated the golden files. |
LantaoJin
commented
Jun 6, 2017
@cloud-fan Do you think it should be done in this pull? And where should add the filter, |
SparkQA
commented
Jun 6, 2017
Test build #77766 has finished for PR 17953 at commit
|
| val client = spark.sharedState.externalCatalog.asInstanceOf[HiveExternalCatalog].client | ||
| client.runSqlHive("CREATE TABLE t (t1 int)") | ||
| client.runSqlHive("INSERT INTO t VALUES (3)") | ||
| client.runSqlHive("CREATE TABLE tabNullType AS SELECT NULL AS col FROM t") |
There was a problem hiding this comment.
IIRC, hive 2 does't support this. Let's test with CREATE VIEW AS ... to be safer
HyukjinKwon
commented
Jul 24, 2017
@LantaoJin do you have some time to address the review comment above? |
LantaoJin
commented
Jul 24, 2017
@HyukjinKwon Sure. Thank you for reminding me. I almost forgot it. |
gatorsmile
commented
Oct 27, 2017
@LantaoJin Maybe close it now? You can reopen it when the comment is resolved? |
LantaoJin
commented
Oct 28, 2017
via email
Sure, please close it as you wish. I will reopen it when it is ready for up to date.
Sent from Mail Master
On 10/28/2017 07:39, Xiao Li wrote: @LantaoJin Maybe close it now? You can reopen it when the comment is resolved?
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/apache/spark","title":"apache/spark","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/apache/spark"}},"updates":{"snippets":[{"icon":"PERSON","message":"@gatorsmile in #17953: @LantaoJin Maybe close it now? You can reopen it when the comment is resolved?"}],"action":{"name":"View Pull Request","url":"#17953 (comment)"}}} |
amit-hitachi
commented
Jun 9, 2020
@LantaoJin@gatorsmile |
maropu
commented
Jun 9, 2020
@amit-hitachi I think we don't have any plan for this work. But, you could revive this discussion in the corresponding jira side. |
HyukjinKwon
commented
Jun 15, 2020
Yeah .. I personally support this change FWIW. |
LantaoJin
commented
Jun 15, 2020
Emmm. How to reopen it? |
LantaoJin
commented
Jun 15, 2020
I open a new one #28833 |
…oid column datatype ### What changes were proposed in this pull request? This is the new PR which to address the close one #17953 1. support "void" primitive data type in the `AstBuilder`, point it to `NullType` 2. forbid creating tables with VOID/NULL column type ### Why are the changes needed? 1. Spark is incompatible with hive void type. When Hive table schema contains void type, DESC table will throw an exception in Spark. >hive> create table bad as select 1 x, null z from dual; >hive> describe bad; OK x int z void In Spark2.0.x, the behaviour to read this view is normal: >spark-sql> describe bad; x int NULL z void NULL Time taken: 4.431 seconds, Fetched 2 row(s) But in lastest Spark version, it failed with SparkException: Cannot recognize hive type string: void >spark-sql> describe bad; 17/05/09 03:12:08 ERROR thriftserver.SparkSQLDriver: Failed in [describe bad] org.apache.spark.SparkException: Cannot recognize hive type string: void Caused by: org.apache.spark.sql.catalyst.parser.ParseException: DataType void() is not supported.(line 1, pos 0) == SQL == void ^^^ ... 61 more org.apache.spark.SparkException: Cannot recognize hive type string: void 2. Hive CTAS statements throws error when select clause has NULL/VOID type column since HIVE-11217 In Spark, creating table with a VOID/NULL column should throw readable exception message, include - create data source table (using parquet, json, ...) - create hive table (with or without stored as) - CTAS ### Does this PR introduce any user-facing change? No ### How was this patch tested? Add unit tests Closes#28833 from LantaoJin/SPARK-20680_COPY. Authored-by: LantaoJin <jinlantao@gmail.com> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Closesapache#11494Closesapache#14158Closesapache#16803Closesapache#16864Closesapache#17455Closesapache#17936Closesapache#19377 Added: Closesapache#19380Closesapache#18642Closesapache#18377Closesapache#19632 Added: Closesapache#14471Closesapache#17402Closesapache#17953Closesapache#18607 Also cc srowen vanzin HyukjinKwon gatorsmile cloud-fan to see if you have other PRs to close. Author: Xingbo Jiang <xingbo.jiang@databricks.com> Closesapache#19669 from jiangxb1987/stale-prs.
What changes were proposed in this pull request?
Spark-sql do not support for void column datatype of view
Create a HIVE view:
Because there's no type, Hive gives it the VOID type:
In Spark2.0.x, the behaviour to read this view is normal:
But in Spark2.1.x, it failed with SparkException: Cannot recognize hive type string: void
How was this patch tested?
Add tests
Also can manual tests