You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2023/01/07 05:37:14 UTC

[GitHub] [flink] laughingman7743 opened a new pull request, #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

laughingman7743 opened a new pull request, #21613:
URL: https://github.com/apache/flink/pull/21613

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   The current implementation does not take into consideration the case where another package is imported and used for a message, so it seems that the way getOuterProtoPrefix is determined needs to be improved.
   This improvement allows the google.protobuf.Timestamp type to be handled.
   
   ## Brief change log
   
   * Fixed getOuterProtoPrefix method
   * Changed signature of getFullJavaName method
   * Added test case for google.protobuf.Timestamp type (with multiple_files and outer_classname options)
   * Fixed proto file format according to [style guide](https://developers.google.com/protocol-buffers/docs/style)
   
   ## Verifying this change
   
   The added test case of type google.protobuf.Timestamp should succeed.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable)
   


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118738


##########
flink-formats/flink-protobuf/src/test/proto/test_simple_noouter_nomulti.proto:
##########
@@ -21,18 +21,17 @@ package org.apache.flink.formats.protobuf.proto;
 option java_package = "org.apache.flink.formats.protobuf.testproto";
 
 message SimpleTestNoouterNomulti {

Review Comment:
   Changed proto file and test case names and specified multiple_files options explicitly.
   https://github.com/apache/flink/pull/21613/commits/a13c4a0ccbfc624fdbb2a63ba07263ddfc9bc563



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] libenchao commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
libenchao commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1396915307

   @laughingman7743 Thanks for your contribution and @maosuhan thanks for your review. The PR looks good, I'm merging.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1063957334


##########
flink-formats/flink-protobuf/src/test/proto/test_map.proto:
##########
@@ -22,16 +22,14 @@ option java_package = "org.apache.flink.formats.protobuf.testproto";
 option java_multiple_files = true;
 
 message MapTest {
-    optional int32 a = 1;
-    map<string, string> map1 = 2;
-    map<string, InnerMessageTest> map2 = 3;
-    map<string, bytes> map3 = 4;
+  optional int32 a = 1;

Review Comment:
   Reformat to follow the style guide: https://developers.google.com/protocol-buffers/docs/style



##########
flink-formats/flink-protobuf/pom.xml:
##########
@@ -109,6 +109,7 @@ under the License.
 						</goals>
 						<configuration>
 							<protocArtifact>com.google.protobuf:protoc:${protoc.version}</protocArtifact>
+							<includeMavenTypes>direct</includeMavenTypes>

Review Comment:
   This option is required to use google.protobuf.Timestamp.



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] maosuhan commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
maosuhan commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1063983345


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -72,14 +71,33 @@ public static String getStrongCamelCaseJsonName(String name) {
         return ProtobufInternalUtils.underScoreToCamelCase(name, true);
     }
 
-    public static String getOuterProtoPrefix(String name) {
-        name = name.replace('$', '.');
-        int index = name.lastIndexOf('.');
-        if (index != -1) {
-            // include dot
-            return name.substring(0, index + 1);
+    public static String getOuterProtoPrefix(Descriptors.Descriptor descriptor) {
+        String javaPackageName = descriptor.getFile().getOptions().getJavaPackage();
+        if (javaPackageName.isEmpty()) {

Review Comment:
   what about use descriptor.getFile().getOptions().hasJavaPackage() to check existence of java package option?



##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -28,26 +28,25 @@
 
 /** Protobuf function util. */
 public class PbFormatUtils {
-    public static String getFullJavaName(Descriptors.Descriptor descriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.Descriptor descriptor) {
         if (null != descriptor.getContainingType()) {
             // nested type
-            String parentJavaFullName =
-                    getFullJavaName(descriptor.getContainingType(), outerProtoName);
+            String parentJavaFullName = getFullJavaName(descriptor.getContainingType());
             return parentJavaFullName + "." + descriptor.getName();
         } else {
             // top level message
+            String outerProtoName = getOuterProtoPrefix(descriptor);
             return outerProtoName + descriptor.getName();
         }
     }
 
-    public static String getFullJavaName(
-            Descriptors.EnumDescriptor enumDescriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.EnumDescriptor enumDescriptor) {
         if (null != enumDescriptor.getContainingType()) {
-            return getFullJavaName(enumDescriptor.getContainingType(), outerProtoName)
+            return getFullJavaName(enumDescriptor.getContainingType())
                     + "."
                     + enumDescriptor.getName();
         } else {
-            return outerProtoName + enumDescriptor.getName();
+            return enumDescriptor.getFullName();

Review Comment:
   fullName of enumDescriptor is determine by package option. If user specify different java_package and the enum is at the top level, the result is not correct.



##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/deserialize/ProtoToRowConverter.java:
##########
@@ -58,16 +58,15 @@ public class ProtoToRowConverter {
     public ProtoToRowConverter(RowType rowType, PbFormatConfig formatConfig)
             throws PbCodegenException {
         try {
-            String outerPrefix =
-                    PbFormatUtils.getOuterProtoPrefix(formatConfig.getMessageClassName());
             Descriptors.Descriptor descriptor =
                     PbFormatUtils.getDescriptor(formatConfig.getMessageClassName());
+            String outerPrefix = PbFormatUtils.getOuterProtoPrefix(descriptor);

Review Comment:
   It seems  PbFormatContext.oterPrefix is actually not used in the code logic. Is it possible to remove outerPrefix in PbFormatContext?



##########
flink-formats/flink-protobuf/src/test/proto/test_simple_noouter_nomulti.proto:
##########
@@ -21,18 +21,17 @@ package org.apache.flink.formats.protobuf.proto;
 option java_package = "org.apache.flink.formats.protobuf.testproto";
 
 message SimpleTestNoouterNomulti {

Review Comment:
   What about rename this file to test_simple_nomulti.proto as you do?



##########
flink-formats/flink-protobuf/src/test/proto/test_timestamp.proto:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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 = "proto3";
+package org.apache.flink.formats.protobuf.proto;
+import "google/protobuf/timestamp.proto";
+option java_package = "org.apache.flink.formats.protobuf.testproto";
+option java_multiple_files = false;
+
+message TimestampTest {

Review Comment:
   change this file name to test_timestamp_nomulti.proto



##########
flink-formats/flink-protobuf/src/test/proto/test_simple_noouter_nomulti.proto:
##########
@@ -21,18 +21,17 @@ package org.apache.flink.formats.protobuf.proto;
 option java_package = "org.apache.flink.formats.protobuf.testproto";
 
 message SimpleTestNoouterNomulti {

Review Comment:
   Also set multiple_files=false explicitly ?



##########
flink-formats/flink-protobuf/src/test/proto/test_simple_outer_nomulti.proto:
##########
@@ -22,18 +22,17 @@ option java_package = "org.apache.flink.formats.protobuf.testproto";
 option java_outer_classname = "SimpleTestOuterNomultiProto";

Review Comment:
   set java_multiple_files=false explicitly as test_timestamp_outer_nomulti.proto do?



##########
flink-formats/flink-protobuf/src/test/proto/test_simple.proto:
##########
@@ -22,28 +22,25 @@ option java_package = "org.apache.flink.formats.protobuf.testproto";
 option java_multiple_files = true;

Review Comment:
   what about rename this file to test_simple_multi.proto so that the name convention is the same as timestamp?



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374800739

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1063962702


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/TimestampToRowTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.formats.protobuf;
+
+import org.apache.flink.formats.protobuf.testproto.TestTimestamp.TimestampTest;
+import org.apache.flink.table.data.RowData;
+
+import com.google.protobuf.Timestamp;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** Test conversion of proto timestamp data to flink internal data. */
+public class TimestampToRowTest {

Review Comment:
   All of the following test cases may be consolidated into this test case and handled by methods such as testSimpleMulti, testSimpleOuterMulti and testSimpleOuterNomulti.
   - TimestampMultiToRowTest
   - TimestampOuterMultiToRowTest
   - TimestampOuterNomultiToRowTest
   



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374386063

   Related: https://github.com/apache/flink/pull/21436


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1376760012

   Currently all tests pass. (Maybe there is a flaky test in the e2e test).
   https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=44585&view=results


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118738


##########
flink-formats/flink-protobuf/src/test/proto/test_simple_noouter_nomulti.proto:
##########
@@ -21,18 +21,17 @@ package org.apache.flink.formats.protobuf.proto;
 option java_package = "org.apache.flink.formats.protobuf.testproto";
 
 message SimpleTestNoouterNomulti {

Review Comment:
   https://github.com/apache/flink/pull/21613/commits/5fb41bb51d838e61dcb323822aca45c880b09d27
   Changed proto file and test case names and specified multiple_files options explicitly.



##########
flink-formats/flink-protobuf/src/test/proto/test_simple.proto:
##########
@@ -22,28 +22,25 @@ option java_package = "org.apache.flink.formats.protobuf.testproto";
 option java_multiple_files = true;

Review Comment:
   https://github.com/apache/flink/pull/21613#discussion_r1064118738



##########
flink-formats/flink-protobuf/src/test/proto/test_simple_outer_nomulti.proto:
##########
@@ -22,18 +22,17 @@ option java_package = "org.apache.flink.formats.protobuf.testproto";
 option java_outer_classname = "SimpleTestOuterNomultiProto";

Review Comment:
   https://github.com/apache/flink/pull/21613#discussion_r1064118738



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118335


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -72,14 +71,33 @@ public static String getStrongCamelCaseJsonName(String name) {
         return ProtobufInternalUtils.underScoreToCamelCase(name, true);
     }
 
-    public static String getOuterProtoPrefix(String name) {
-        name = name.replace('$', '.');
-        int index = name.lastIndexOf('.');
-        if (index != -1) {
-            // include dot
-            return name.substring(0, index + 1);
+    public static String getOuterProtoPrefix(Descriptors.Descriptor descriptor) {
+        String javaPackageName = descriptor.getFile().getOptions().getJavaPackage();
+        if (javaPackageName.isEmpty()) {

Review Comment:
   Fixed: https://github.com/apache/flink/pull/21613/commits/690f209ed4708c88d713015f4c7af5e5d95b5a88



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064120073


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -28,26 +28,25 @@
 
 /** Protobuf function util. */
 public class PbFormatUtils {
-    public static String getFullJavaName(Descriptors.Descriptor descriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.Descriptor descriptor) {
         if (null != descriptor.getContainingType()) {
             // nested type
-            String parentJavaFullName =
-                    getFullJavaName(descriptor.getContainingType(), outerProtoName);
+            String parentJavaFullName = getFullJavaName(descriptor.getContainingType());
             return parentJavaFullName + "." + descriptor.getName();
         } else {
             // top level message
+            String outerProtoName = getOuterProtoPrefix(descriptor);
             return outerProtoName + descriptor.getName();
         }
     }
 
-    public static String getFullJavaName(
-            Descriptors.EnumDescriptor enumDescriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.EnumDescriptor enumDescriptor) {
         if (null != enumDescriptor.getContainingType()) {
-            return getFullJavaName(enumDescriptor.getContainingType(), outerProtoName)
+            return getFullJavaName(enumDescriptor.getContainingType())
                     + "."
                     + enumDescriptor.getName();
         } else {
-            return outerProtoName + enumDescriptor.getName();
+            return enumDescriptor.getFullName();

Review Comment:
   Changed the method of generating OuterProtoPrefix for enum to be the same as for message. The method of determining when an OuterClass is automatically added has also been changed, and a test case for enum has been added.
   https://github.com/apache/flink/pull/21613/commits/76f1923c5d19a56039699f47742d3b7d93168151



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374858341

   @maosuhan I have added a test cases to convert from flink internal primitive data to proto timestamp data. I will add any other test cases that are needed.
   https://github.com/apache/flink/pull/21613/commits/6d28b339e8c8507e2e668765f0bae56bb0587541


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] maosuhan commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
maosuhan commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1376836273

   @laughingman7743 It looks all right now. @libenchao Do you have time to take another look at this?
   


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] flinkbot commented on pull request #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374385481

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "f06c17ee50dcb39403f14a8f47109e5b09b2b66b",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "f06c17ee50dcb39403f14a8f47109e5b09b2b66b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * f06c17ee50dcb39403f14a8f47109e5b09b2b66b UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118261


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/deserialize/ProtoToRowConverter.java:
##########
@@ -58,16 +58,15 @@ public class ProtoToRowConverter {
     public ProtoToRowConverter(RowType rowType, PbFormatConfig formatConfig)
             throws PbCodegenException {
         try {
-            String outerPrefix =
-                    PbFormatUtils.getOuterProtoPrefix(formatConfig.getMessageClassName());
             Descriptors.Descriptor descriptor =
                     PbFormatUtils.getDescriptor(formatConfig.getMessageClassName());
+            String outerPrefix = PbFormatUtils.getOuterProtoPrefix(descriptor);

Review Comment:
   Removed: https://github.com/apache/flink/pull/21613/commits/c3bde63a92941e1d8c6b170fb6f690f4eefa6815



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118762


##########
flink-formats/flink-protobuf/src/test/proto/test_timestamp.proto:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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 = "proto3";
+package org.apache.flink.formats.protobuf.proto;
+import "google/protobuf/timestamp.proto";
+option java_package = "org.apache.flink.formats.protobuf.testproto";
+option java_multiple_files = false;
+
+message TimestampTest {

Review Comment:
   https://github.com/apache/flink/pull/21613#discussion_r1064118738



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] maosuhan commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
maosuhan commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374837459

   @laughingman7743 Thanks for your quick quick fix. We are almost there. Would you add another unit test like TimestampMultiRowToProto.java to make sure flink row can be correctly converted to protobuf object?


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118335


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -72,14 +71,33 @@ public static String getStrongCamelCaseJsonName(String name) {
         return ProtobufInternalUtils.underScoreToCamelCase(name, true);
     }
 
-    public static String getOuterProtoPrefix(String name) {
-        name = name.replace('$', '.');
-        int index = name.lastIndexOf('.');
-        if (index != -1) {
-            // include dot
-            return name.substring(0, index + 1);
+    public static String getOuterProtoPrefix(Descriptors.Descriptor descriptor) {
+        String javaPackageName = descriptor.getFile().getOptions().getJavaPackage();
+        if (javaPackageName.isEmpty()) {

Review Comment:
   Fixed: https://github.com/apache/flink/pull/21613/commits/84b4c309ec84671c9c67c37654b071d7cc65aec6



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064118261


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/deserialize/ProtoToRowConverter.java:
##########
@@ -58,16 +58,15 @@ public class ProtoToRowConverter {
     public ProtoToRowConverter(RowType rowType, PbFormatConfig formatConfig)
             throws PbCodegenException {
         try {
-            String outerPrefix =
-                    PbFormatUtils.getOuterProtoPrefix(formatConfig.getMessageClassName());
             Descriptors.Descriptor descriptor =
                     PbFormatUtils.getDescriptor(formatConfig.getMessageClassName());
+            String outerPrefix = PbFormatUtils.getOuterProtoPrefix(descriptor);

Review Comment:
   Removed: https://github.com/apache/flink/pull/21613/commits/07cf5324602502436a5be51c5919f3eb355c3cc5



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1375132192

   @maosuhan I have added a description of data mapping of type google.protobuf.Timestamp to the documentation.
   https://github.com/apache/flink/pull/21613/commits/23b5fb0b35abb5e888ad7b50fcc22c837f860977
   
   https://dev.azure.com/apache-flink/apache-flink/_build/results?buildId=44568&view=logs&j=af184cdd-c6d8-5084-0b69-7e9c67b35f7a&t=160c9ae5-96fd-516e-1c91-deb81f59292a
   The e2e test seems to be failing, but I can't find the cause. Could the changes made in this pull request be affecting it? Please let me know if I am missing something.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] libenchao closed pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
libenchao closed pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type
URL: https://github.com/apache/flink/pull/21613


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] maosuhan commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
maosuhan commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1375027529

   @laughingman7743 The code LGTM. Would you also add documentation in protobuf page describing how to use timestamp type or other internal provided type? Some users may not know the corresponding flink type of Timestamp is a row structure.


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064120073


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -28,26 +28,25 @@
 
 /** Protobuf function util. */
 public class PbFormatUtils {
-    public static String getFullJavaName(Descriptors.Descriptor descriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.Descriptor descriptor) {
         if (null != descriptor.getContainingType()) {
             // nested type
-            String parentJavaFullName =
-                    getFullJavaName(descriptor.getContainingType(), outerProtoName);
+            String parentJavaFullName = getFullJavaName(descriptor.getContainingType());
             return parentJavaFullName + "." + descriptor.getName();
         } else {
             // top level message
+            String outerProtoName = getOuterProtoPrefix(descriptor);
             return outerProtoName + descriptor.getName();
         }
     }
 
-    public static String getFullJavaName(
-            Descriptors.EnumDescriptor enumDescriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.EnumDescriptor enumDescriptor) {
         if (null != enumDescriptor.getContainingType()) {
-            return getFullJavaName(enumDescriptor.getContainingType(), outerProtoName)
+            return getFullJavaName(enumDescriptor.getContainingType())
                     + "."
                     + enumDescriptor.getName();
         } else {
-            return outerProtoName + enumDescriptor.getName();
+            return enumDescriptor.getFullName();

Review Comment:
   Changed the method of generating OuterProtoPrefix for enum to be the same as for message. The method of determining when an OuterClass is automatically added has also been changed, and a test case for enum has been added.
   https://github.com/apache/flink/pull/21613/commits/32f59798e3ef08d8b0579bda8e7d7157ef188b41



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1374797735

   @maosuhan I have addressed the comments, PTAL when you have time 🙏 


-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1064120073


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -28,26 +28,25 @@
 
 /** Protobuf function util. */
 public class PbFormatUtils {
-    public static String getFullJavaName(Descriptors.Descriptor descriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.Descriptor descriptor) {
         if (null != descriptor.getContainingType()) {
             // nested type
-            String parentJavaFullName =
-                    getFullJavaName(descriptor.getContainingType(), outerProtoName);
+            String parentJavaFullName = getFullJavaName(descriptor.getContainingType());
             return parentJavaFullName + "." + descriptor.getName();
         } else {
             // top level message
+            String outerProtoName = getOuterProtoPrefix(descriptor);
             return outerProtoName + descriptor.getName();
         }
     }
 
-    public static String getFullJavaName(
-            Descriptors.EnumDescriptor enumDescriptor, String outerProtoName) {
+    public static String getFullJavaName(Descriptors.EnumDescriptor enumDescriptor) {
         if (null != enumDescriptor.getContainingType()) {
-            return getFullJavaName(enumDescriptor.getContainingType(), outerProtoName)
+            return getFullJavaName(enumDescriptor.getContainingType())
                     + "."
                     + enumDescriptor.getName();
         } else {
-            return outerProtoName + enumDescriptor.getName();
+            return enumDescriptor.getFullName();

Review Comment:
   Changed the method of generating OuterProtoPrefix for enum to be the same as for message. The method of determining when an OuterClass is automatically added has also been changed, and a test case for enum has been added.
   https://github.com/apache/flink/pull/21613/commits/b40e9f20c6685b594203c0ebdda08d61e6aef6c8



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] laughingman7743 commented on a diff in pull request #21613: [FLINK-30093][Formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
laughingman7743 commented on code in PR #21613:
URL: https://github.com/apache/flink/pull/21613#discussion_r1063962702


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/TimestampToRowTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.formats.protobuf;
+
+import org.apache.flink.formats.protobuf.testproto.TestTimestamp.TimestampTest;
+import org.apache.flink.table.data.RowData;
+
+import com.google.protobuf.Timestamp;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** Test conversion of proto timestamp data to flink internal data. */
+public class TimestampToRowTest {

Review Comment:
   All of the following test cases may be aggregated into this test case and handled by methods such as testSimpleMulti, testSimpleOuterMulti and testSimpleOuterNomulti.
   - TimestampMultiToRowTest
   - TimestampOuterMultiToRowTest
   - TimestampOuterNomultiToRowTest
   



-- 
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: issues-unsubscribe@flink.apache.org

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


[GitHub] [flink] libenchao commented on pull request #21613: [FLINK-30093][formats] Fix compile errors for google.protobuf.Timestamp type

Posted by GitBox <gi...@apache.org>.
libenchao commented on PR #21613:
URL: https://github.com/apache/flink/pull/21613#issuecomment-1378176914

   @maosuhan I will, but I've been a little busy lately. To manage your expectation, it won't be quick.


-- 
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: issues-unsubscribe@flink.apache.org

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