-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Pulsar SQL] support protobuf/timestamp #13287
Conversation
remove conflict method in SinkConfigUtilsTest.java
TBR |
there is a question, protobuf/timestamp contains nanos, but presto/timestamp not. so that nanos will be missed in pulsar-sql when display formatted timestamp. |
@tjiuming:Thanks for your contribution. For this PR, do we need to update docs? |
I‘m not sure, it is a small feature, just display formatted timestamp, maybe not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test to cover the new fix? So that we can avoid the issue will not happening in the future.
@@ -390,22 +390,6 @@ public void testMergeRuntimeFlags() { | |||
); | |||
} | |||
|
|||
@Test | |||
public void testMergeDifferentCleanupSubscription() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please rebase the master branch? I think the test has already been removed on the master branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the method still exists yesterday, but I checkout just now, it removed.
import io.prestosql.spi.type.TypeSignature; | ||
import io.prestosql.spi.type.TypeSignatureParameter; | ||
import io.prestosql.spi.type.VarbinaryType; | ||
import io.prestosql.spi.type.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid use star import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, got it
//return seconds field of protobuf/timestamp | ||
if (columnType instanceof TimestampType && value instanceof DynamicMessage) { | ||
DynamicMessage message = (DynamicMessage) value; | ||
return (long) message.getField(message.getDescriptorForType().findFieldByName("seconds")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between the following pattern:
if (columnType instanceof TimestampType && value instanceof Timestamp) {
return ((Timestamp) value).getSeconds();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll check it, but I confirmed value instanceof DynamicMessage
is true, and protobuf/timestamp not extends DynamicMessage, if I use value instanceof Timestamp
, it seems not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return time in the unit of milliseconds here. It seems that we need to convert it here. And do we also need to handle Timestamp.nanos
here?
remove star imports
@codelipenghui TBR |
merge master into presto-timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested it in C# client -> pulsar SQL case. But the time shown in pulsar SQL is wrong, see lastlogintimestamp
:
presto> select * from pulsar."public/default".test;
name | age | lastlogintimestamp | __partition__ | __event_time__ | __publish_time__ | __message_id__ | __sequence_id__ | __producer_name__ | __key__ | __properties__
------+-----+-------------------------+---------------+-------------------------+-------------------------+----------------+-----------------+-------------------+---------+----------------
abc | 18 | 1970-01-20 07:39:05.115 | -1 | 1970-01-01 08:00:00.000 | 2021-12-24 11:25:15.093 | (76,0,0) | 0 | NULL | NULL | {}
The correct time is 2021-12-24 ... ...
.
I have left some comments below. Could we also add some tests to cover the above case?
//return seconds field of protobuf/timestamp | ||
if (columnType instanceof TimestampType && value instanceof DynamicMessage) { | ||
DynamicMessage message = (DynamicMessage) value; | ||
return (long) message.getField(message.getDescriptorForType().findFieldByName("seconds")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return time in the unit of milliseconds here. It seems that we need to convert it here. And do we also need to handle Timestamp.nanos
here?
@@ -83,6 +85,7 @@ public void testPrimitiveType() { | |||
.setBoolField(true) | |||
.setBytesField(ByteString.copyFrom("abc".getBytes())) | |||
.setTestEnum(TestMsg.TestEnum.FAILOVER) | |||
.setTimestampField(Timestamp.newBuilder().setSeconds(System.currentTimeMillis()).build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use the time in seconds here.
merge master into presto-timestamp
(cherry picked from commit 1ea4ad8) (cherry picked from commit bdf5802477a8df39a5826548d4b80ad6b3ddbab7)
(cherry picked from commit 1ea4ad8)
fix: #3554
Motivation
testMergeDifferentCleanupSubscription
inSinkConfigUtilTest
, to make sure build project successfully.Modifications
PulsarProtobufNativeRowDecoderFactory
seconds
field of protobuf/timestamp inPulsarProtobufNativeColumnDecoder
Verifying this change
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
no-need-doc
a small feature, seems no need