Skip to content

[SPARK-36012][SQL] Add null flag in SHOW CREATE TABLE#33219

Closed
Peng-Lei wants to merge 2 commits intoapache:masterfrom
Peng-Lei:SPARK-36012
Closed

[SPARK-36012][SQL] Add null flag in SHOW CREATE TABLE#33219
Peng-Lei wants to merge 2 commits intoapache:masterfrom
Peng-Lei:SPARK-36012

Conversation

@Peng-Lei
Copy link
Contributor

@Peng-Lei Peng-Lei commented Jul 5, 2021

What changes were proposed in this pull request?

When exec the command SHOW CREATE TABLE, we should not lost the info null flag if the table column that
is specified NOT NULL

Why are the changes needed?

SPARK-36012

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add UT test for V1 and existed UT for V2

@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Jul 6, 2021

@cloud-fan Could you take a look?

@Peng-Lei Peng-Lei force-pushed the SPARK-36012 branch 2 times, most recently from da9c28e to 3ee8ffc Compare July 6, 2021 08:52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are touching the code here, can we change it to compare the StructType instance instead of the DDL string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: classOf[SimpleInsertSource].getName

Copy link
Contributor

@cloud-fan cloud-fan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for some minor comments

@cloud-fan cloud-fan changed the title [SPARK-36012][SQL] Add null flag when SHOW CREATE TABLE in v2 [SPARK-36012][SQL] Add null flag in SHOW CREATE TABLE Jul 6, 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit and you don't have to change: I think you can modify getShowDDL a bit and reuse it, and make this code structure the same as test("SPARK-24911: keep quotes for nested fields")

Copy link
Contributor Author

@Peng-Lei Peng-Lei Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huaxingao Thank you for your code review. done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this function getShowDDL. It just returns part of the DDL data instead of the complete DDL data. But it is named getShowDDL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we always call .mkString(" ") here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Peng-Lei doesn't want to include the USING text TBLPROPERTIES ( 'transient_lastDdlTime... in the test in HiveShowCreateTableSuite. I guess maybe always call .mkString(" ") here and trim off the USING text ... using something like shownDDL.substring(0, shownDDL.indexOf(" USING") in the Hive test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. In HiveShowCreateTableSuite it compare the Array(0) + Array(1). I do not want to include the USING text TBLPROPERTIES, because the test fail. I just think getShowDDL return Array[String] is flexible, because if we want to use Array to assert, it just ok. If we want to use String to assert, just mkString(). @cloud-fan @huaxingao

@huaxingao
Copy link
Contributor

ok to test

@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45322/

@cloud-fan
Copy link
Contributor

thanks, merging to master/3.2 (since v2 SHOW CREATE TABLE is new in 3.2)

@cloud-fan cloud-fan closed this in e071721 Jul 8, 2021
cloud-fan pushed a commit that referenced this pull request Jul 8, 2021
### What changes were proposed in this pull request?
When exec the command `SHOW CREATE TABLE`, we should not lost the info null flag if the table column that
is specified `NOT NULL`

### Why are the changes needed?
[SPARK-36012](https://issues.apache.org/jira/browse/SPARK-36012)

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Add UT test for V1 and existed UT for V2

Closes #33219 from Peng-Lei/SPARK-36012.

Authored-by: PengLei <peng.8lei@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit e071721)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/45322/

@SparkQA
Copy link

SparkQA commented Jul 8, 2021

Test build #140811 has finished for PR 33219 at commit 3b57144.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants