Skip to content

Conversation

shangm2
Copy link

@shangm2 shangm2 commented May 3, 2025

  1. Allow adding custom thrift type when using generator
  2. This pr is based on [Drift] Add support for Java optional to IDL generator #111 and therefore also include changes from it. Once that one gets merged, this pr will not reflect changes from it.

@shangm2 shangm2 requested a review from a team as a code owner May 3, 2025 05:17
@shangm2 shangm2 requested a review from jaystarshot May 3, 2025 05:17
@shangm2 shangm2 force-pushed the customeThriftType branch 4 times, most recently from b3a1423 to 0c13a86 Compare May 3, 2025 14:56
@shangm2 shangm2 changed the title Allow adding custom thrift type when using generator [Drift] Allow adding custom thrift type when using generator May 4, 2025
@shangm2 shangm2 force-pushed the customeThriftType branch from 0c13a86 to bb38dcc Compare May 5, 2025 16:41
@shangm2 shangm2 force-pushed the customeThriftType branch 2 times, most recently from 9b2a65c to 06ea0c1 Compare May 5, 2025 18:40
Copy link
Member

@arhimondr arhimondr left a comment

Choose a reason for hiding this comment

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

LGTM % questions

<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredNonTestScopedDependencies>
<dependency>com.facebook.airlift:units</dependency>
Copy link
Member

Choose a reason for hiding this comment

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

Why does it need to be ignored?

Choose a reason for hiding this comment

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


public void addKnowTypes(ThriftType type)
{
BUILT_IN_TYPES.add(type);
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to update BUILT_IN_TYPES?

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I see.

Modifying the static map of built in types may result in unexpected side effects. Consider an application using the ThriftIdlGenerator class to generate multiple unrelated IDLs.

Maybe keep the static BUILT_IN_TYPES map immutable and add one more, non static, customTypes map and then initialize the knownTypes map using both, the static BUILT_IN_TYPES and the customTypes map.

You may want to rename the addKnownType method addCustomType

Copy link
Author

@shangm2 shangm2 May 6, 2025

Choose a reason for hiding this comment

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

Good point. Thanks for the suggestion! Code updated.

this.recursive = config.isRecursive();
}

public void addKnowTypes(ThriftType type)
Copy link
Member

Choose a reason for hiding this comment

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

nit: addKnownType

Copy link
Author

Choose a reason for hiding this comment

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

Updated

@shangm2 shangm2 force-pushed the customeThriftType branch from 06ea0c1 to 6738595 Compare May 6, 2025 17:12

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>

Choose a reason for hiding this comment

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

looks like this is used only for Tests ? if so can we make the scope as test ?

Copy link
Author

Choose a reason for hiding this comment

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

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>test</scope>
Copy link
Author

Choose a reason for hiding this comment

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

.

@NikhilCollooru NikhilCollooru merged commit 2eca1f9 into prestodb:master May 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants