You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "rangadi (via GitHub)" <gi...@apache.org> on 2023/02/19 05:18:53 UTC

[GitHub] [spark] rangadi commented on a diff in pull request #40080: [SPARK-42406] Fix check for missing required fields.

rangadi commented on code in PR #40080:
URL: https://github.com/apache/spark/pull/40080#discussion_r1111162264


##########
connector/protobuf/src/test/resources/protobuf/serde_suite.proto:
##########
@@ -59,17 +59,6 @@ message TypeMiss {
   int64 bar = 1;
 }
 
-/* Field boo missing from SQL root, but available in Protobuf root*/

Review Comment:
   These two are moved to `proto2_messages.proto` (and renamed)



##########
connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/utils/ProtobufUtils.scala:
##########
@@ -283,9 +283,4 @@ private[sql] object ProtobufUtils extends Logging {
     case Seq() => "top-level record"
     case n => s"field '${n.mkString(".")}'"
   }
-
-  /** Return true if `fieldDescriptor` is optional. */
-  private[protobuf] def isNullable(fieldDescriptor: FieldDescriptor): Boolean =
-    !fieldDescriptor.isOptional

Review Comment:
   This is the bug. extra `!` returns false for `optional` field. But optional fields are nullable. This is fixed at line #103 above.



##########
connector/protobuf/src/test/resources/protobuf/proto2_messages.proto:
##########
@@ -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";

Review Comment:
   Protobuf v2 file is added to test required fields.



##########
connector/protobuf/src/test/resources/protobuf/proto2_messages.desc:
##########
@@ -0,0 +1,8 @@
+

Review Comment:
   This a descriptor file for `proto2_messages.proto` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org