Skip to content
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-43361][PROTOBUF] update documentation for errors related to enum serialization #41188

Conversation

justaparth
Copy link
Contributor

@justaparth justaparth commented May 16, 2023

What changes were proposed in this pull request?

Follows-up on the comment here: #41075 (comment)

Namely:

  • updates error-classes.json and sql-error-conditions.md to have the updated error name.
  • adds an additional test to assert that enum serialization with invalid enum values throws the correct exception.

Why are the changes needed?

Improve documentation

Does this PR introduce any user-facing change?

Yes, documentation.

How was this patch tested?

Existing unit tests

@justaparth justaparth changed the title Parth/update documentation enum error message [SPARK-43361][PROTOBUF] update documentation and error message for enum serialization May 16, 2023
@justaparth justaparth changed the title [SPARK-43361][PROTOBUF] update documentation and error message for enum serialization [SPARK-43361][PROTOBUF] update documentation for errors related to enum serialization May 16, 2023
@justaparth justaparth force-pushed the parth/update-documentation-enum-error-message branch from 36bf491 to 8a30c34 Compare May 16, 2023 15:26
Copy link
Contributor

@rangadi rangadi left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. LGTM.
Suggested a few changes to consider.

@@ -120,7 +120,7 @@ private[sql] class ProtobufSerializer(
catalystPath,
toFieldStr(protoPath),
data.toString,
enumValues.mkString("", ",", ""))
enumValues.mkString("", ", ", ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be replaced with enumValues.mkString(", ")

"sqlColumn" -> "`basic_enum`",
"protobufColumn" -> "field 'basic_enum'",
"data" -> "9999",
"enumString" -> "0, 1, 2"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I see, we print the integer values if the the column is int?

"message" : [
"Cannot convert SQL <sqlColumn> to Protobuf <protobufColumn> because schema is incompatible (protobufType = <protobufType>, sqlType = <sqlType>)."
"Cannot convert SQL <sqlColumn> to Protobuf <protobufColumn> because <data> is not defined in ENUM <enumString>."
Copy link
Contributor

@rangadi rangadi May 16, 2023

Choose a reason for hiding this comment

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

<enumString>

Should this be something like allowed values (<enumString>)?

@rangadi
Copy link
Contributor

rangadi commented May 18, 2023

@justaparth could you take a look at the comments? Would like to merge asap.

@justaparth justaparth force-pushed the parth/update-documentation-enum-error-message branch from 8a30c34 to a4e032b Compare May 18, 2023 22:45
@justaparth
Copy link
Contributor Author

@rangadi just updated to respond to your comments!

@rangadi
Copy link
Contributor

rangadi commented May 19, 2023

Thank you!

@justaparth
Copy link
Contributor Author

cc @HyukjinKwon would you mind taking a look and merging this one? thanks 🙏

@zhengruifeng
Copy link
Contributor

merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants