Skip to content

Change java type of UNKNOWN from void to boolean#11116

Merged
jessesleeping merged 1 commit intoprestodb:masterfrom
jessesleeping:unknown_type
Aug 3, 2018
Merged

Change java type of UNKNOWN from void to boolean#11116
jessesleeping merged 1 commit intoprestodb:masterfrom
jessesleeping:unknown_type

Conversation

@jessesleeping
Copy link
Copy Markdown
Contributor

Using boolean to represent UNKNOWN helps remove all special handling
for void/Void in functions/operators implementations and bytecode
generations.

The changes were done by:

  • Change UnknownType.java and UnknownOperators.java, followed by all fixes to pass all tests under presto-main/src/test/java/com/facebook/presto/type and presto-main/src/test/java/com/facebook/presto/operator
  • Search for void.class and check if it's related to UNKNOWN handling
  • Search for Void.class and check if it's related
  • Search for public static Void.class and check if it's return value of certain SQL functions/operators
  • Search for @SqlType\([^\)]*\) Void and check if it's parameters of certain SQL functions/operators

@jessesleeping
Copy link
Copy Markdown
Contributor Author

The failed test seems unrelated. I passed it locally on my laptop.

@jessesleeping jessesleeping removed their assignment Jul 24, 2018
Copy link
Copy Markdown
Contributor

@haozhun haozhun left a comment

Choose a reason for hiding this comment

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

Some minor inline comments.

In addition, in the commit message, also put in an explanation on why we choose boolean.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

throw new IllegalArgumentException("value of unknown type should always be null")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't need this if any more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

        // Ideally, this function should never be invoked for unknown type.
        // However, some logic rely on having a default value before the null check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add checkState(type instanceof UnknownType)

Copy link
Copy Markdown
Contributor

@haozhun haozhun Jul 25, 2018

Choose a reason for hiding this comment

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

Add comment to explain why the native container type doesn't actually matter. And also explain why we picked boolean among other possible choices.

@jessesleeping jessesleeping force-pushed the unknown_type branch 2 times, most recently from 25f279e to 5c827c5 Compare July 25, 2018 03:00
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about leave this file untouched since it will get a major refactor in #10961 ?

cc @haozhun

Copy link
Copy Markdown
Contributor

@haozhun haozhun Jul 26, 2018

Choose a reason for hiding this comment

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

In my opinion, the conflict will be minor.

What alternative do you propose? I wouldn't want to leave this as is indefinitely.

@facebook-github-bot
Copy link
Copy Markdown
Collaborator

Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired.

Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status.

@facebook-github-bot
Copy link
Copy Markdown
Collaborator

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Using boolean to represent UNKNOWN helps remove all special handling
for void/Void in functions/operators implementations and bytecode
generations. In fact, any native container type can represet UNKNOWN.
We choose boolean becuase it's the smallest primitive type.
@jessesleeping jessesleeping merged commit c49cf2a into prestodb:master Aug 3, 2018
@jessesleeping jessesleeping deleted the unknown_type branch August 3, 2018 21:21
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