Skip to content

Conversation

@lowka
Copy link
Contributor

@lowka lowka commented Aug 8, 2023

Adds index usage checks to BaseIndexDataTypeTest. In addition to that fixes the issue with VARBINARY, mentioned in issue's comment.

  • Updates *DataTypeTests to use literals, when type supports literals (UUID tests use CAST('str' AS UUID), VARBINARY tests use HEX literals).
  • Adds additional tests cases for index usage for varbinary type.

https://issues.apache.org/jira/browse/IGNITE-19893


Thank you for submitting the pull request.

To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:

The Review Checklist

  • Formal criteria: TC status, codestyle, mandatory documentation. Also make sure to complete the following:
    - There is a single JIRA ticket related to the pull request.
    - The web-link to the pull request is attached to the JIRA ticket.
    - The JIRA ticket has the Patch Available state.
    - The description of the JIRA ticket explains WHAT was made, WHY and HOW.
    - The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • Design: new code conforms with the design principles of the components it is added to.
  • Patch quality: patch cannot be split into smaller pieces, its size must be reasonable.
  • Code quality: code is clean and readable, necessary developer documentation is added if needed.
  • Tests code quality: test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.

Notes

@lowka lowka marked this pull request as ready for review August 8, 2023 06:56
}

// No need to binary between char and varbinary.
if (SqlTypeUtil.isBinary(toType) && SqlTypeUtil.isBinary(fromType)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this check is not operate with char types at all, why char is mentioned here ? also "No need to binary" is sounds strange, isn`t it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was a typo, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still think that such kind of fix is looks like a stub, varchar(default_precision) and varchar need to be equal types is not it ?

Copy link
Contributor Author

@lowka lowka Aug 14, 2023

Choose a reason for hiding this comment

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

What kind of fix are we talking about - you mean rewriting logic related to creating reldata types with default precision/scale?

@lowka lowka marked this pull request as draft August 9, 2023 11:05
@lowka lowka marked this pull request as ready for review August 10, 2023 06:35
lowka added 3 commits August 10, 2023 09:39
Add comments that clarifies checks for binary/char types.
Add comments that clarifies checks for binary/char types.
@lowka lowka requested a review from zstan August 11, 2023 08:30
@AMashenkov AMashenkov requested a review from korlov42 August 11, 2023 15:27
@lowka
Copy link
Contributor Author

lowka commented Aug 15, 2023

Removed the remaining outdated information from javadocs of BaseDataTypeTest.
Reverted visibility of BaseDataTypeTest::createQueryTemplate back to private.

@lowka lowka requested a review from korlov42 August 15, 2023 13:08
Copy link
Contributor

@zstan zstan left a comment

Choose a reason for hiding this comment

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

overall looks good, instead of still possible cast from char to varbinary (check comments) probably you can fix it ?

* <ul>
* <li>{@code <type>} - an SQL name of a data type.</li>
* <li>{@code $N} - the {@code N-th} value from sample values (0-based), converted to an SQL expression by
* {@link DataTypeTestSpec#toValueExpr(Comparable)} call (0-based)</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

not always converted by DataTypeTestSpec#toValueExpr i suppose ? but after change :

                if (useLiterals) {
                    placeHolderValue = testTypeSpec.toLiteral(value);
                } else {
                    placeHolderValue = testTypeSpec.toValueExpr(value);
                }

toLiteral - is used ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

case LITERAL:
return spec.toLiteral(value);
case CAST: {
String str = spec.toStringValue(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

https://issues.apache.org/jira/browse/IGNITE-20185 will reject casting from char to varbinary i.e. '1'::varbinary would be rejected, also it`s not allowed by standard. But i also understand that this is without the scope of this issue but if you can easily fix it - it would be great.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced string literals with binary literals.

Fix CASTs - use casts from VARBINARY literal instead of CHAR literals.
@lowka lowka requested a review from zstan August 16, 2023 12:04

@BeforeAll
public void createTable() {
runSql("CREATE TABLE varbinary_fixed_length(id INTEGER PRIMARY KEY, test_key VARBINARY(10))");
Copy link
Member

Choose a reason for hiding this comment

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

VARBINARY is variable length BINARY type.
What does varbinary_fixed_length mean?

Copy link
Member

Choose a reason for hiding this comment

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

If you mean we could create columns as

col1 VARBINARY,
col2 VARBINARY(10)

then, actually, col1 will have a max length as well.
We always create VARBINARY/VARCHAR column with specific length, which is 65k by default as I remember.

Copy link
Contributor Author

@lowka lowka Aug 18, 2023

Choose a reason for hiding this comment

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

@AMashenkov

VARBINARY is variable length BINARY type.
What does varbinary_fixed_length mean?

Right now VARBINARY(n) works exactly the same way as does BINARY(n). If this is a bug, I can replace VARBINARY(n) with BINARY(n) here, I could file an issue to fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed varbinary_fixed_length as it duplicates test cases defined in base class.

@lowka
Copy link
Contributor Author

lowka commented Aug 21, 2023

Unmuted ItVarBinaryExpressionTest::testCastToDifferentLengthsWithDynamicParameters

@lowka lowka requested review from AMashenkov and korlov42 August 21, 2023 10:58
@zstan
Copy link
Contributor

zstan commented Aug 21, 2023

@lowka can you merge fresh main plz ?

@lowka
Copy link
Contributor Author

lowka commented Aug 21, 2023

@zstan Merged the latest main into this PR.

private static Stream<Arguments> indexChecks() {
return Stream.of(
Arguments.of(Named.of("VARBINARY_DEFAULT_LENGTH", "T"), ValueMode.LITERAL),
//Arguments.of(Named.of("VARBINARY_DEFAULT_LENGTH", "T"), ValueMode.CAST),
Copy link
Contributor

Choose a reason for hiding this comment

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

plz remove this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@zstan zstan merged commit fefcadb into apache:main Aug 22, 2023
@zstan zstan deleted the IGNITE-19893 branch August 22, 2023 07:32
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