[INLONG-10129][SDK] Transform SQL support +-*/ operations #10133
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.
Fixes #10129
Motivation
Transform SQL support +-*/ operations
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.msgs(1).msgTime-$root.msgs(0).msgTime)/$root.packageID field2,
$root.packageID*($root.msgs(0).msgTime*$root.packageID+$root.msgs(1).msgTime/$root.packageID)*$root.packageID field3,
$root.msgs(0).msg field4 from source
where $root.packageID<($root.msgs(0).msgTime+$root.msgs(1).msgTime+$root.msgs(0).msgTime+$root.msgs(1).msgTime)
The final data is the following string
sid|2|3426487836002|msgValue4
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