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-42178][UI] Handle remaining null string values in ui protobuf serializer and add tests #39732

Closed
wants to merge 2 commits into from

Conversation

gengliangwang
Copy link
Member

What changes were proposed in this pull request?

Why are the changes needed?

Properly handles null string values in the protobuf serializer.

Does this PR introduce any user-facing change?

No

How was this patch tested?

New UTs

@gengliangwang
Copy link
Member Author

cc @LuciferYang

@@ -31,6 +34,32 @@ import org.apache.spark.ui.scope.{RDDOperationEdge, RDDOperationNode}
class KVStoreProtobufSerializerSuite extends SparkFunSuite {
private val serializer = new KVStoreProtobufSerializer()

test("All the string fields must be optional to avoid NPE") {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test checks the protobuf file to make sure all the string fields are defined as optional string

Copy link
Member Author

Choose a reason for hiding this comment

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

Example failure output:

ArrayBuffer(("  string storage_level = 5;", 267), ("  string name = 1;", 363)) was not empty
All the string fields should be defined as `optional string` for handling null string.
Please update the following fields:
line #267:   string storage_level = 5;
line #363:   string name = 1;

val invalidDefinition = new mutable.ArrayBuffer[(String, Int)]()
var lineNumber = 1
Source.fromFile(protoFile.toFile.getCanonicalPath).getLines().foreach { line =>
if (line.matches(containsStringRegex)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

org.apache.spark.util.Utils.tryWithResource should be used to ensureSource.fromFile(protoFile.toFile.getCanonicalPath) is closed after use

Copy link
Member

Choose a reason for hiding this comment

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

+1 for the above comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, updated

@@ -463,7 +492,7 @@ class KVStoreProtobufSerializerSuite extends SparkFunSuite {
name = null,
numPartitions = 8,
numCachedPartitions = 5,
storageLevel = "IN_MEMORY",
storageLevel = null,
Copy link
Member

Choose a reason for hiding this comment

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

Is this change required in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah we need to test null string input. There is another object with storageLevel as IN_MEMORY already. Let's simply change the third object.

Copy link
Member

Choose a reason for hiding this comment

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

Got it~

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (except two comments; one from @LuciferYang and one question from me).

@LuciferYang
Copy link
Contributor

LuciferYang commented Jan 25, 2023

Another way I can think of is to check each field in StoreTypes.getDescriptor.toProto.getMessageTypeList, but it should not be better than the current one.

Copy link
Contributor

@LuciferYang LuciferYang left a comment

Choose a reason for hiding this comment

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

+1, LGTM

@gengliangwang
Copy link
Member Author

gengliangwang commented Jan 25, 2023

@dongjoon-hyun @LuciferYang Thanks for the review. Merging to master/3.4

gengliangwang added a commit that referenced this pull request Jan 25, 2023
…serializer and add tests

### What changes were proposed in this pull request?

* Similar to #39666, handle remaining null string values in ui protobuf serializer, including `RDDStorageInfo` and `ResourceInformation`
* Add test to make sure all the string fields are defined as `optional string`.

### Why are the changes needed?

Properly handles null string values in the protobuf serializer.

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

No
### How was this patch tested?

New UTs

Closes #39732 from gengliangwang/moreNullString.

Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants