tisonkun commented on code in PR #19027:
URL: https://github.com/apache/pulsar/pull/19027#discussion_r1187091852


##########
pulsar-sql/presto-pulsar/src/main/java/org/apache/pulsar/sql/presto/PulsarRecordCursor.java:
##########
@@ -589,42 +588,55 @@ public boolean advanceNextPosition() {
                             .filter(col -> 
PulsarColumnHandle.HandleKeyValueType.NONE
                                     .equals(col.getHandleKeyValueType()))
                             .collect(toImmutableSet()));
+
             Optional<Map<DecoderColumnHandle, FieldValueProvider>> 
decodedValue =
                     messageDecoder.decodeRow(this.currentMessage.getData());
             decodedValue.ifPresent(currentRowValuesMap::putAll);
         }
 
         for (DecoderColumnHandle columnHandle : columnHandles) {
-            if (columnHandle.isInternal()) {
-                if 
(PulsarInternalColumn.PARTITION.getName().equals(columnHandle.getName())) {
+            //String names = 
PulsarInternalColumn.getNameByColumnHandle(columnHandle);
+            switch (columnHandle.getName()) {
+                case "__partition__":
                     currentRowValuesMap.put(columnHandle, 
longValueProvider(this.partition));
-                } else if 
(PulsarInternalColumn.EVENT_TIME.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__event_time__":
                     currentRowValuesMap.put(columnHandle, 
PulsarFieldValueProviders.timeValueProvider(
                             this.currentMessage.getEventTime(), 
this.currentMessage.getEventTime() == 0));
-                } else if 
(PulsarInternalColumn.PUBLISH_TIME.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__publish_time__":
                     currentRowValuesMap.put(columnHandle, 
PulsarFieldValueProviders.timeValueProvider(
                             this.currentMessage.getPublishTime(), 
this.currentMessage.getPublishTime() == 0));
-                } else if 
(PulsarInternalColumn.MESSAGE_ID.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__message_id__":
                     currentRowValuesMap.put(columnHandle, bytesValueProvider(
                             
this.currentMessage.getMessageId().toString().getBytes()));
-                } else if 
(PulsarInternalColumn.SEQUENCE_ID.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__sequence_id__":
                     currentRowValuesMap.put(columnHandle, 
longValueProvider(this.currentMessage.getSequenceId()));
-                } else if 
(PulsarInternalColumn.PRODUCER_NAME.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__producer_name__":
                     currentRowValuesMap.put(columnHandle,
                             
bytesValueProvider(this.currentMessage.getProducerName().getBytes()));
-                } else if 
(PulsarInternalColumn.KEY.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__key__":
                     String key = this.currentMessage.getKey().orElse(null);
                     currentRowValuesMap.put(columnHandle, 
bytesValueProvider(key == null ? null : key.getBytes()));
-                } else if 
(PulsarInternalColumn.PROPERTIES.getName().equals(columnHandle.getName())) {
+                    break;
+                case "__properties__":
                     try {
                         currentRowValuesMap.put(columnHandle, 
bytesValueProvider(
                                 new 
ObjectMapper().writeValueAsBytes(this.currentMessage.getProperties())));
                     } catch (JsonProcessingException e) {
                         throw new RuntimeException(e);
                     }
-                } else {
-                    throw new IllegalArgumentException("unknown internal field 
" + columnHandle.getName());
-                }
+                    break;
+                default:
+                    try {
+                        throw new IllegalArgumentException("unknown internal 
field " + columnHandle.getName());
+                    } finally {
+                        break;
+                    }

Review Comment:
   Thanks for pointing it out. SGTM.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to