[FLINK-30093] [formats] Protobuf Timestamp Compile Error#21436
[FLINK-30093] [formats] Protobuf Timestamp Compile Error#21436hdulay wants to merge 1 commit intoapache:masterfrom
Conversation
|
Hi @maosuhan . Since you were the originator of this code, I was hoping you could check this enhancement to the protobuf work. Thanks |
|
@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 |
|
Thx for the PR. Can you also update the commit message, for example to the PR title? |
|
The CI failure seems to be caused by a known instability: https://issues.apache.org/jira/browse/FLINK-30257 |
|
Updated commit message. Tnx |
|
@hdulay Thanks for raising this issue and your fix PR. I will help to review this PR. cc @MartijnVisser |
| String parentJavaFullName = | ||
| getFullJavaName(descriptor.getContainingType(), outerProtoName); | ||
| return parentJavaFullName + "." + descriptor.getName(); | ||
| } else if (descriptor.getFullName().contains("google")) { |
There was a problem hiding this 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?
| assertEquals(1, rowData.getInt(0)); | ||
| assertEquals(2L, rowData.getLong(1)); | ||
|
|
||
| assertEquals(ts.getNanos(), row.getTimestamp(11, 3).getNanoOfMillisecond()); |
There was a problem hiding this 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?
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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
There was a problem hiding this 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?
There was a problem hiding this 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
There was a problem hiding this 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.
There was a problem hiding this comment.
Thanks. Let me know if it's appropriate to convert this PR to a draft. Thanks for all the guidance.
| bytes i = 9; | ||
| map<string, string> map1 = 10; | ||
| map<string, InnerMessageTest> map2 = 11; | ||
| google.protobuf.Timestamp ts = 12; |
There was a problem hiding this comment.
Also test in ProtobufSQLITCaseTest for end to end correctness.
FLINK-30093
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
<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)Verifying this change
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (yno)Documentation