-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Generate ProtocolToThrift files through make and commit #25162
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
base: master
Are you sure you want to change the base?
Conversation
@vhsu14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
d505a2f
to
dd4a16c
Compare
If we're using Thrift, why can't we just use either the Drift IDL generator, or have both Java and C++ auto-generate the Thrift structures from a checked in IDL? |
We are using Drift to annotate classes in Java and generate an IDL for C++ to auto-gen the Thrift structures. Using a checked-in IDL has some cons in Java:
Thanks for the comment. Let me know if you have further questions. |
Can we discuss the approach for code generation and overall timeline in this RFC? The protocol infrastructure has its own overhead and technical debt, and it's not really clear to me how this is going to work. For example, some questions I have:
We use RFCs to get alignment on design and also to document decisions made. These are all important decisions that needs to be memorialized into the above RFC. |
Hey @tdcmeehan . Let me know if the following answers your questions. And yes, we will incorporate these questions and answers into the RFC as well.
|
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
StructMap: |
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.
StructMap maps fields that have different names for protocol and thrift classes
fields: | ||
infoUnion: { field_name: info } | ||
|
||
SkipStruct: |
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 don't generate toThrift/fromThrift classes for the following structs because they are related to OperatorInfo, which is an empty struct in C++
StageExecutionId: | ||
StageId: | ||
|
||
WrapperStruct: |
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.
These are single field structs in IDL that are directly declared in C++. For example,
In IDL:
struct ConnectorId {
1: string catalogName;
}
In C++:
using ConnectorId = std::string;
RuntimeStats: | ||
SqlFunctionId: | ||
|
||
Special: |
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.
These are structs that require custom conversions, which are defined under the /special folder
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
all: ProtocolToThrift.h ProtocolToThrift.cpp |
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.
This Makefile defines the flow for generating ProtocolToThrift files as defined in README.md. For now, it depends on presto_thrift.thrift, which is a copy of Drift generated IDL. @shangm2 is working on having it auto-generated as part of presto-thrift-spec and we will reference to the generated IDL once that is done.
2a99cd0
to
7ec0dac
Compare
7ec0dac
to
fd74671
Compare
@vhsu14 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
LGTM
|
||
|
||
def main(): | ||
preprocess(sys.argv[1], "temp_presto_thrift.thrift") |
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.
This is to remove the "drift.recursive_reference=true" annotation from the original thrift file. This annotation is needed/generated by drift codec and we prefer not to write hacky code in drift repo in order to remove it. @vhsu14 maybe we can add some comment to emphasize this for future reference.
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.
This seems little hacky.. can we add a comment here explaining it.
./presto_protocol-to-thrift-json.py presto_thrift.json ../../presto_protocol/core/presto_protocol_core.json | jq . > presto_protocol-to-thrift-json.json | ||
|
||
presto_thrift.json: presto_thrift.thrift ./thrift2json.py | ||
./thrift2json.py presto_thrift.thrift | jq . > presto_thrift.json |
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 .thrift file is at presto-thrift-spec/target/thrift/presto-thrift-protocol.thrift
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
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.
add new line at end of file.
Description
In #25079, ProtocolToThrift files were manually written. This PR generates these files using pythons scripts and chevron templates.
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use: