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 2022/11/30 16:47:52 UTC

[GitHub] [flink] hdulay opened a new pull request, #21436: FLINK-30093 Formats Protobuf Timestamp

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

   [FLINK-30093](https://github.com/hdulay/flink/tree/FLINK-30093)
   
   <!--
   *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
   
   This PR enables support for Google Protobuf Timestamp datatypes and possibly other Google Protobuf datatypes.
   
   ## Brief change log
   
   - Adding `<includeMavenTypes>direct</includeMavenTypes>` Specifies whether to extract .proto files from Maven dependencies and add them to the protoc import path. Options: "none" (do not extract any proto files), "**direct" (extract only from direct dependencies)**, "transitive" (extract from direct and transitive dependencies)
   - Ensuring the generated code provides the correct package name for all google proto types.
   
   
   ## Verifying this change
   
   - Added Google Protobuf Timestamp to existing Proto tests.
   
   
   ## 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)`: (yno)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (don't know)
     - 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] hdulay commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   @MartijnVisser Hi. I'm suggesting to add support for 3rd party protobuf datatype. Which needs a mapping to either a RowType or a SimpleType in the protobuf codegen components. I'm assuming this is the correct approach. Thanks



-- 
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] MartijnVisser commented on pull request #21436: FLINK-30093 Formats Protobuf Timestamp

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

   @hdulay Thanks for opening your first PR. Please check out the code style & quality guide for naming conventions on commits https://flink.apache.org/contributing/code-style-and-quality-preamble.html


-- 
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 #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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

   @hdulay Thanks for raising this issue and your fix PR. I will help to review this PR. cc @MartijnVisser 


-- 
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] rmetzger commented on pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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

   Thx for the PR. Can you also update the commit message, for example to the PR title?


-- 
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] hdulay commented on pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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

   Updated commit message. Tnx


-- 
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 #21436: FLINK-30093 Formats Protobuf Timestamp

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

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "869e061fb91ffff20c4346f1cf978e38f6ad863a",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "869e061fb91ffff20c4346f1cf978e38f6ad863a",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 869e061fb91ffff20c4346f1cf978e38f6ad863a 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] hdulay commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -34,6 +35,15 @@ public static String getFullJavaName(Descriptors.Descriptor descriptor, String o
             String parentJavaFullName =
                     getFullJavaName(descriptor.getContainingType(), outerProtoName);
             return parentJavaFullName + "." + descriptor.getName();
+        } else if (descriptor.getFullName().contains("google")) {

Review Comment:
   Yes



-- 
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] hdulay commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   The org.apache.flink.table.data.binary.BinaryRowData.getTimestamp() method from the flink-table module does the translation to org.apache.flink.table.data.TimestampData.



-- 
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 #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   I'm curious how does Timestamp work because I did not define Timestamp type for flink. I guess Timestamp is a message type in protobuf, how come it will convert to flink Timestamp automatically?



##########
flink-formats/flink-protobuf/src/main/java/org/apache/flink/formats/protobuf/util/PbFormatUtils.java:
##########
@@ -34,6 +35,15 @@ public static String getFullJavaName(Descriptors.Descriptor descriptor, String o
             String parentJavaFullName =
                     getFullJavaName(descriptor.getContainingType(), outerProtoName);
             return parentJavaFullName + "." + descriptor.getName();
+        } else if (descriptor.getFullName().contains("google")) {

Review Comment:
   @hdulay The compilation error is caused by a third-party import, right? Could you make it more general to adapt to all the import cases?



##########
flink-formats/flink-protobuf/src/test/proto/test_pb3.proto:
##########
@@ -33,6 +34,7 @@ message Pb3Test {
     bytes i = 9;
     map<string, string> map1 = 10;
     map<string, InnerMessageTest> map2 = 11;
+    google.protobuf.Timestamp ts = 12;

Review Comment:
   Also test in ProtobufSQLITCaseTest for end to end correctness.



-- 
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] hdulay commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   @maosuhan Yes as I stepped through the ProtobufSQLITCaseTest to add a timestamp field, I realized this issue goes beyond just source generation and compilation errors. Is there an example of how to add new data type?  I'm assuming I'll need to somehow map it to the TimestampType logical type. Thanks



-- 
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 #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   @hdulay I think there is still gap between protobuf and flink internal memory layout. I tried to build a concrete Timestamp like `Timestamp ts =Timestamp.newBuilder().setSeconds(xxx).setNanos(yyy).build()` in unit test. And you can easily find the difference.



-- 
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] hdulay commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   Thanks. Let me know if it's appropriate to convert this PR to a draft. Thanks for all the guidance. 



-- 
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] hdulay commented on pull request #21436: FLINK-30093 Formats Protobuf Timestamp

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

   Hi @maosuhan .  Since you were the originator of this code, I was hoping you could check this enhancement to the protobuf work. Thanks


-- 
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] rmetzger commented on pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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

   The CI failure seems to be caused by a known instability: https://issues.apache.org/jira/browse/FLINK-30257


-- 
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 #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   @hdulay Yes, I agree with your idea. RowType must be doable to reflect a Timestamp pb type. If you want to make it more easy to use, you can treat `google.protobuf.Timestamp` a special type and manually convert Timestamp to TimestampData in code. 



-- 
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] MartijnVisser commented on a diff in pull request #21436: [FLINK-30093] [formats] Protobuf Timestamp Compile Error

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


##########
flink-formats/flink-protobuf/src/test/java/org/apache/flink/formats/protobuf/Pb3ToRowTest.java:
##########
@@ -85,6 +88,8 @@ public void testDeserialization() throws Exception {
 
         assertEquals(1, rowData.getInt(0));
         assertEquals(2L, rowData.getLong(1));
+
+        assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond());

Review Comment:
   Just to step in: adding a new datatype requires a FLIP and a discussion. Why can't any of the existing datatypes be reused?



-- 
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