[SPARK-46629] Fix for STRUCT type DDL not picking up nullability and comment#44644
Closed
vitaliili-db wants to merge 11 commits intoapache:masterfrom
Closed
[SPARK-46629] Fix for STRUCT type DDL not picking up nullability and comment#44644vitaliili-db wants to merge 11 commits intoapache:masterfrom
vitaliili-db wants to merge 11 commits intoapache:masterfrom
Conversation
Member
|
cc @MaxGekk |
MaxGekk
reviewed
Jan 11, 2024
Comment on lines
+158
to
+164
| case s: StructType => | ||
| val fieldsDDL = s.fields.map { f => | ||
| val nullString = if (f.nullable) "" else " NOT NULL" | ||
| s"${QuotingUtils.quoteIfNeeded(f.name)}: " + | ||
| s"${getDataTypeDDL(f.dataType)}$nullString${f.getDDLComment}" | ||
| } | ||
| s"STRUCT<${fieldsDDL.mkString(", ")}>" |
Member
There was a problem hiding this comment.
Can't we incapsulate the logic inside of the method StructType.sql()?
Contributor
Author
There was a problem hiding this comment.
great idea, done!
MaxGekk
reviewed
Jan 13, 2024
Member
There was a problem hiding this comment.
@vitaliili-db BTW, is the output of toDDL() with NOT NULL parseable back by fromDDL()? Could you add such test to StructTypeSuite.
| "protobufType" -> "FieldMissingInProto", | ||
| "toType" -> toSQLType(CATALYST_STRUCT))) | ||
|
|
||
| assertFailedConversionMessage(protoFile, |
Contributor
Author
There was a problem hiding this comment.
Reverted and fixed.
Member
|
BTW, here is a similar PR #41016 |
Member
|
@vitaliili-db Could you change PR's title, it is too much specific. |
Contributor
Author
MaxGekk
approved these changes
Jan 18, 2024
Member
|
+1, LGTM. Merging to master. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
This change adds logic to generate correct DDL for nested fields in STRUCT. In particular instead of generating list of fields with data type names it will add
NOT NULLqualifier when necessary and field comment when present.For a table:
Before:
After
Closes #41016
Why are the changes needed?
Generate correct DDL.
Does this PR introduce any user-facing change?
No, we do not document behavior of this command for struct case.
How was this patch tested?
New unit test.
Was this patch authored or co-authored using generative AI tooling?
No