-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32356][SQL] Forbid create view with null type #29152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d5a5575
init
ulysses-you 95dd3d2
update error msg
ulysses-you 3780ccd
add temp view test
ulysses-you 2e8d9f3
add dataset ut
ulysses-you 9d77cb5
move to SQLViewSuite
ulysses-you e1d92ae
update ut
ulysses-you 32ec11a
add view command check
ulysses-you 94fb546
mv to SQLViewSuite
ulysses-you 4d8d088
fix ut name
ulysses-you 3cb224f
remove null
ulysses-you d02986c
remove null
ulysses-you File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2314,6 +2314,7 @@ class HiveDDLSuite | |
| } | ||
|
|
||
| test("SPARK-20680: do not support for null column datatype") { | ||
| val errMsg = s"Cannot create tables/views with ${NullType.simpleString} type." | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed old error msg |
||
| withTable("t") { | ||
| withView("tabNullType") { | ||
| hiveClient.runSqlHive("CREATE TABLE t (t1 int)") | ||
|
|
@@ -2331,17 +2332,17 @@ class HiveDDLSuite | |
| val e1 = intercept[AnalysisException] { | ||
| spark.sql("CREATE TABLE t1 USING PARQUET AS SELECT null as null_col") | ||
| }.getMessage | ||
| assert(e1.contains("Cannot create tables with null type")) | ||
| assert(e1.contains(errMsg)) | ||
|
|
||
| val e2 = intercept[AnalysisException] { | ||
| spark.sql("CREATE TABLE t2 AS SELECT null as null_col") | ||
| }.getMessage | ||
| assert(e2.contains("Cannot create tables with null type")) | ||
| assert(e2.contains(errMsg)) | ||
|
|
||
| val e3 = intercept[AnalysisException] { | ||
| spark.sql("CREATE TABLE t3 STORED AS PARQUET AS SELECT null as null_col") | ||
| }.getMessage | ||
| assert(e3.contains("Cannot create tables with null type")) | ||
| assert(e3.contains(errMsg)) | ||
| } | ||
|
|
||
| // Forbid Replace table AS SELECT with null type | ||
|
|
@@ -2350,27 +2351,27 @@ class HiveDDLSuite | |
| val e = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE OR REPLACE TABLE t USING $v2Source AS SELECT null as null_col") | ||
| }.getMessage | ||
| assert(e.contains("Cannot create tables with null type")) | ||
| assert(e.contains(errMsg)) | ||
| } | ||
|
|
||
| // Forbid creating table with VOID type in Spark | ||
| withTable("t1", "t2", "t3", "t4") { | ||
| val e1 = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE TABLE t1 (v VOID) USING PARQUET") | ||
| }.getMessage | ||
| assert(e1.contains("Cannot create tables with null type")) | ||
| assert(e1.contains(errMsg)) | ||
| val e2 = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE TABLE t2 (v VOID) USING hive") | ||
| }.getMessage | ||
| assert(e2.contains("Cannot create tables with null type")) | ||
| assert(e2.contains(errMsg)) | ||
| val e3 = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE TABLE t3 (v VOID)") | ||
| }.getMessage | ||
| assert(e3.contains("Cannot create tables with null type")) | ||
| assert(e3.contains(errMsg)) | ||
| val e4 = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE TABLE t4 (v VOID) STORED AS PARQUET") | ||
| }.getMessage | ||
| assert(e4.contains("Cannot create tables with null type")) | ||
| assert(e4.contains(errMsg)) | ||
| } | ||
|
|
||
| // Forbid Replace table with VOID type | ||
|
|
@@ -2379,7 +2380,7 @@ class HiveDDLSuite | |
| val e = intercept[AnalysisException] { | ||
| spark.sql(s"CREATE OR REPLACE TABLE t (v VOID) USING $v2Source") | ||
| }.getMessage | ||
| assert(e.contains("Cannot create tables with null type")) | ||
| assert(e.contains(errMsg)) | ||
| } | ||
|
|
||
| // Make sure spark.catalog.createTable with null type will fail | ||
|
|
@@ -2416,7 +2417,7 @@ class HiveDDLSuite | |
| schema = schema, | ||
| options = Map("fileFormat" -> "parquet")) | ||
| }.getMessage | ||
| assert(e.contains("Cannot create tables with null type")) | ||
| assert(e.contains(s"Cannot create tables/views with ${NullType.simpleString} type.")) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2429,7 +2430,7 @@ class HiveDDLSuite | |
| schema = schema, | ||
| options = Map.empty[String, String]) | ||
| }.getMessage | ||
| assert(e.contains("Cannot create tables with null type")) | ||
| assert(e.contains(s"Cannot create tables/views with ${NullType.simpleString} type.")) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is for
df.createTempView. Note that, we supportselect null as cbut fail in create view with null type plan.