-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-42406][SQL] Fix check for missing required fields of to_protobuf #40080
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This a descriptor file for |
||
| � | ||
| proto2_messages.proto$org.apache.spark.sql.protobuf.protos"@ | ||
| FoobarWithRequiredFieldBar | ||
| foo ( Rfoo | ||
| bar (Rbar"� | ||
| NestedFoobarWithRequiredFieldBare | ||
| nested_foobar (2@.org.apache.spark.sql.protobuf.protos.FoobarWithRequiredFieldBarRnestedFoobarBBProto2Messages | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| syntax = "proto2"; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Protobuf v2 file is added to test required fields. |
||
|
|
||
| package org.apache.spark.sql.protobuf.protos; | ||
| option java_outer_classname = "Proto2Messages"; | ||
|
|
||
|
|
||
| // Used to test missing required field bar in top level schema. | ||
| message FoobarWithRequiredFieldBar { | ||
| optional string foo = 1; | ||
| required int32 bar = 2; | ||
| } | ||
|
|
||
| // Used to test missing required field bar in nested struct. | ||
| message NestedFoobarWithRequiredFieldBar { | ||
| optional FoobarWithRequiredFieldBar nested_foobar = 1; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,17 +59,6 @@ message TypeMiss { | |
| int64 bar = 1; | ||
| } | ||
|
|
||
| /* Field boo missing from SQL root, but available in Protobuf root*/ | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two are moved to |
||
| message FieldMissingInSQLRoot { | ||
| Foo foo = 1; | ||
| int32 boo = 2; | ||
| } | ||
|
|
||
| /* Field baz missing from SQL nested and available in Protobuf nested*/ | ||
| message FieldMissingInSQLNested { | ||
| Baz foo = 1; | ||
| } | ||
|
|
||
| message Baz { | ||
| int32 bar = 1; | ||
| int32 baz = 2; | ||
|
|
||
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.
This is the bug. extra
!returns false foroptionalfield. But optional fields are nullable. This is fixed at line #103 above.