This is an automated email from the ASF dual-hosted git repository.

siddteotia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 312808c651 Change comment to be more precise (#11735)
312808c651 is described below

commit 312808c651862af6ced30950868147b72fcc6f35
Author: Gonzalo Ortiz Jaureguizar <gor...@users.noreply.github.com>
AuthorDate: Wed Oct 4 17:56:10 2023 +0200

    Change comment to be more precise (#11735)
---
 .../plugin/inputformat/protobuf/ProtoBufRecordExtractor.java   | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git 
a/pinot-plugins/pinot-input-format/pinot-protobuf/src/main/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractor.java
 
b/pinot-plugins/pinot-input-format/pinot-protobuf/src/main/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractor.java
index 83c6c7fc5a..aa1976f504 100644
--- 
a/pinot-plugins/pinot-input-format/pinot-protobuf/src/main/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractor.java
+++ 
b/pinot-plugins/pinot-input-format/pinot-protobuf/src/main/java/org/apache/pinot/plugin/inputformat/protobuf/ProtoBufRecordExtractor.java
@@ -55,14 +55,12 @@ public class ProtoBufRecordExtractor extends 
BaseRecordExtractor<Message> {
 
   /**
    * For fields that are not set, we want to populate a null, instead of proto 
default.
-   * @param fieldDescriptor
-   * @param message
    */
   private Object getFieldValue(Descriptors.FieldDescriptor fieldDescriptor, 
Message message) {
-    // Note w.r.t proto3 - If a field is not declared with optional keyword, 
there's no way to distinguish
-    // if its explicitly set to a proto default or not been set at all i.e 
hasField() returns false
-    // and we would use null.
-    if (fieldDescriptor.isRepeated() || !fieldDescriptor.hasPresence() || 
message.hasField(fieldDescriptor)) {
+    // In order to support null, the field needs to support _field presence_
+    // See 
https://github.com/protocolbuffers/protobuf/blob/main/docs/field_presence.md
+    // or FieldDescriptor#hasPresence()
+    if (!fieldDescriptor.hasPresence() || message.hasField(fieldDescriptor)) {
       return message.getField(fieldDescriptor);
     } else {
       return null;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to