[INLONG-10117][SDK] Support to transform from PB protocol to CSV/KV protocol by single SQL#10127
Merged
Merged
Conversation
…rotocol by single SQL
baomingyu
approved these changes
May 6, 2024
vernedeng
approved these changes
May 7, 2024
dockerzhang
approved these changes
May 7, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[SDK] Support to transform from PB protocol to CSV/KV protocol by single SQL
Fixes #10117
Parent issue:
#10022
Motivation
Support to transform from PB protocol to CSV/KV protocol by single SQL
Modifications
Support to parse the following PB protocol
syntax = "proto3";
package test;
message SdkMessage {
bytes msg = 1;
int64 msgTime = 2;
map<string, string> extinfo = 3;
}
message SdkDataRequest {
string sid = 1;
repeated SdkMessage msgs = 2;
uint64 packageID = 3;
}
Support to parse the following PB data
SdkDataRequest.Builder requestBuilder = SdkDataRequest.newBuilder();
requestBuilder.setSid("sid");
requestBuilder.setPackageID(1);
{
SdkMessage.Builder msgBuilder = SdkMessage.newBuilder();
msgBuilder.setMsgTime(1713243918000L);
msgBuilder.setMsg(ByteString.copyFrom("msgValue4".getBytes()));
msgBuilder.putExtinfo("key", "value");
SdkMessage msgObj = msgBuilder.build();
requestBuilder.addMsgs(msgObj);
}
{
SdkMessage.Builder msgBuilder = SdkMessage.newBuilder();
msgBuilder.setMsgTime(1713243918002L);
msgBuilder.setMsg(ByteString.copyFrom("msgValue42".getBytes()));
msgBuilder.putExtinfo("key2", "value2");
SdkMessage msgObj = msgBuilder.build();
requestBuilder.addMsgs(msgObj);
}
SdkDataRequest requestObj = requestBuilder.build();
byte[] srcBytes = requestObj.toByteArray();
Generate the final data by the following SQL
select $root.sid,
$root.packageID,
$child.msgTime,
$child.msg from source
The final data is the following string
sid|1|1713243918000|msgValue4
sid|1|1713243918002|msgValue42
Verifying this change
(Please pick either of the following options)
This change is a trivial rework/code cleanup without any test coverage.
This change is already covered by existing tests, such as:
(please describe tests)
This change added tests and can be verified as follows:
(example:)
Documentation