Skip to content

[CALCITE-5848] Add BIT_GET and GETBIT functions (enabled in Spark library)#3319

Merged
zoudan merged 1 commit intoapache:mainfrom
herunkang2018:CALCITE-5848
Aug 22, 2023
Merged

[CALCITE-5848] Add BIT_GET and GETBIT functions (enabled in Spark library)#3319
zoudan merged 1 commit intoapache:mainfrom
herunkang2018:CALCITE-5848

Conversation

@herunkang2018
Copy link
Contributor

No description provided.

@herunkang2018
Copy link
Contributor Author

@tanclary would you like to help review if you have time? Thanks very much.

f1.checkNull("BIT_LENGTH(cast(null as binary))");
}

@Test void testBitGetFunc() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could reuse the test code for BIT_GET and GETBIT, as the only difference between them is the function name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you mean to reuse the test code by parameterized test?
By the way, currently testGetBitFunc only contains basic test, and testBitGetFunc contains the full test cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, in that way we could test all cases for both of them.

| * | ATANH(numeric) | Returns the inverse hyperbolic tangent of *numeric*
| s | BIT_LENGTH(binary) | Returns the bit length of *binary*
| s | BIT_LENGTH(string) | Returns the bit length of *string*
| s | BIT_GET(value, position) | Returns the bit (0 or 1) value at the specified *position* of *value*. The positions are numbered from right to left, starting at zero. The *position* argument cannot be negative
Copy link
Contributor

Choose a reason for hiding this comment

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

What types are supported for value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The supported type is NUMERIC type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will update the doc to address this.

}

/** SQL BIT_GET(value, position) function. */
public static int bitGet(long value, int position) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we take other number types like Decimal into consideration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Spark's PR to implement BIT_GET function, currently we don't support decimal type. For consistency, I think we should not take other number types like Decimal into consideration.

@zoudan zoudan self-assigned this Aug 9, 2023
@herunkang2018
Copy link
Contributor Author

@zoudan Thanks for the review.
All comments resolved, please help to review if you have time.

@zoudan
Copy link
Contributor

zoudan commented Aug 19, 2023

LGTM, would you mind rebase and squash your commits?

@zoudan zoudan added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Aug 19, 2023
@herunkang2018
Copy link
Contributor Author

@zoudan The commits is squashed. Thanks for the valuable comments in the review.

@zoudan
Copy link
Contributor

zoudan commented Aug 21, 2023

Sorry, one minor comment use functions instead of function in the commit message.

@herunkang2018 herunkang2018 changed the title [CALCITE-5848] Add BIT_GET and GETBIT function (enabled in Spark library) [CALCITE-5848] Add BIT_GET and GETBIT functions (enabled in Spark library) Aug 21, 2023
@herunkang2018
Copy link
Contributor Author

@zoudan Good catch. This is fixed.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell C 6 Code Smells

93.4% 93.4% Coverage
0.0% 0.0% Duplication

@zoudan zoudan merged commit 95a59d6 into apache:main Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LGTM-will-merge-soon Overall PR looks OK. Only minor things left.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants