Skip to content
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

Merged
merged 8 commits into from
Dec 29, 2021

Conversation

tjiuming
Copy link
Contributor

@tjiuming tjiuming commented Dec 14, 2021

fix: #3554

Motivation

  1. Support protobuf native timestamp for pulsar-sql, so that presto could display formatted timestamp.
  2. Del conflict method testMergeDifferentCleanupSubscription in SinkConfigUtilTest, to make sure build project successfully.

Modifications

  1. add protobuf/timestamp support in PulsarProtobufNativeRowDecoderFactory
  2. return the seconds field of protobuf/timestamp in PulsarProtobufNativeColumnDecoder

Verifying this change

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (don't know)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (don't know)

Documentation

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

remove conflict method in SinkConfigUtilsTest.java
@tjiuming
Copy link
Contributor Author

TBR

@tjiuming
Copy link
Contributor Author

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.

@github-actions
Copy link

@tjiuming:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@tjiuming
Copy link
Contributor Author

@tjiuming:Thanks for your contribution. For this PR, do we need to update docs? (The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

I‘m not sure, it is a small feature, just display formatted timestamp, maybe not.

@codelipenghui codelipenghui added doc-not-needed Your PR changes do not impact docs type/bug The PR fixed a bug or issue reported a bug area/sql Pulsar SQL related features and removed doc-label-missing labels Dec 15, 2021
@codelipenghui codelipenghui added this to the 2.10.0 milestone Dec 15, 2021
Copy link
Contributor

@codelipenghui codelipenghui left a 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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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.*;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got it

Comment on lines 197 to 200
//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"));
Copy link
Contributor

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();
            }

Copy link
Contributor Author

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

Copy link
Member

@RobertIndie RobertIndie Dec 24, 2021

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?

ariestp316@gmail.com added 2 commits December 15, 2021 17:28
@tjiuming
Copy link
Contributor Author

@codelipenghui TBR

merge master into presto-timestamp
Copy link
Member

@RobertIndie RobertIndie left a 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?

Comment on lines 197 to 200
//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"));
Copy link
Member

@RobertIndie RobertIndie Dec 24, 2021

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())
Copy link
Member

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.

ariestp316@gmail.com added 2 commits December 24, 2021 18:03
merge master into presto-timestamp
@codelipenghui codelipenghui merged commit 1ea4ad8 into apache:master Dec 29, 2021
@codelipenghui codelipenghui changed the title support protobuf/timestamp for pulsar-sql [Pulsar SQL] support protobuf/timestamp Dec 29, 2021
codelipenghui pushed a commit that referenced this pull request Dec 30, 2021
(cherry picked from commit 1ea4ad8)
(cherry picked from commit bdf5802477a8df39a5826548d4b80ad6b3ddbab7)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Dec 30, 2021
codelipenghui pushed a commit that referenced this pull request Dec 30, 2021
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Dec 30, 2021
wuzhanpeng pushed a commit to wuzhanpeng/pulsar that referenced this pull request Jan 5, 2022
@tjiuming tjiuming deleted the presto-timestamp branch May 10, 2022 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql Pulsar SQL related features cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.3 release/2.9.2 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pulsar SQL support for Protobuf
3 participants