-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[SPARK-5196][SQL] Support comment
in Create Table Field DDL
#3999
Conversation
This is the better way to implement the |
Can one of the admins verify this patch? |
Jenkins, test this please |
ping. |
ok to test |
Test build #25421 has started for PR 3999 at commit
|
ident ~ dataType ~ (COMMENT ~> stringLit).? ^^ { case columnName ~ typ ~ cm => | ||
val metadata = new MetadataBuilder() | ||
.putString(COMMENT.str.toLowerCase(), cm.getOrElse("")).build() | ||
StructField(columnName, typ, true, metadata) |
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.
How about we do not define the metadata if a comment is not provided? I feel we are losing information if we use an empty string when a comment is not provided.
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.
I think the test failure will be resolved once we do not create a metadata
if there is no comment.
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.
that's fine.
Test build #25421 has finished for PR 3999 at commit
|
Test FAILed. |
test this please |
Test build #25424 has started for PR 3999 at commit
|
Test build #25424 has finished for PR 3999 at commit
|
Test PASSed. |
Test build #25445 has started for PR 3999 at commit
|
Test build #25445 has finished for PR 3999 at commit
|
Test FAILed. |
Test build #25449 has started for PR 3999 at commit
|
Test build #25449 has finished for PR 3999 at commit
|
Test FAILed. |
Test build #25450 has started for PR 3999 at commit
|
Test build #25450 has finished for PR 3999 at commit
|
Test PASSed. |
ping |
Test build #25538 has started for PR 3999 at commit
|
Test build #25538 has finished for PR 3999 at commit
|
""".stripMargin) | ||
|
||
val comments = sql("SELECT * FROM student").queryExecution.sparkPlan. | ||
schema.fields.map { field => |
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.
I think it is better to use queryExecution.executedPlan
since it is the final physical. Also, this line is kind of long. How about we break it as follows.
val planned = sql("SELECT * FROM student").queryExecution.executedPlan
val comments = planned.schema.fields.map { ...
Just one minor comment. Other than that, LGTM. |
Test build #25876 has started for PR 3999 at commit
|
Test build #25876 has finished for PR 3999 at commit
|
Test PASSed. |
LGTM |
Test build #25949 has started for PR 3999 at commit
|
1c71505
to
d1cfb0f
Compare
Test build #25950 has started for PR 3999 at commit
|
Test build #25949 has finished for PR 3999 at commit
|
Test PASSed. |
Test build #25950 has finished for PR 3999 at commit
|
Test PASSed. |
else "NO_COMMENT" | ||
}.mkString(",") | ||
|
||
assert(comments == "SN,SA,NO_COMMENT") |
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.
Plain asserts should be avoided in tests as they give very little information when there is a failure. Instead use ===
or add a custom string that describes what went wrong as the second argument.
Test build #26369 has started for PR 3999 at commit
|
77bf089
to
39150d4
Compare
Test build #26371 has started for PR 3999 at commit
|
Test build #26369 has finished for PR 3999 at commit
|
Test PASSed. |
Test build #26371 has finished for PR 3999 at commit
|
Test PASSed. |
else "NO_COMMENT" | ||
}.mkString(",") | ||
|
||
assert(comments === "SN,SA,NO_COMMENT", "assert equals, display all comments of fields") |
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.
I will fix this up while merging, but I don't think it is useful to both use ===
and give a comment that doesn't include the actual answer. Ideally, when the test fails you want to see the answer that does not match the expected answer so you can figure out what went wrong without having to go and add println
manually.
Support
comment
in create a table field.CREATE TEMPORARY TABLE people(name string
comment
"the name of a person")