-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Cast pushdown test case refactoring #23737
Cast pushdown test case refactoring #23737
Conversation
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcCastPushdownTest.java
Outdated
Show resolved
Hide resolved
b6ba45f
to
9dd5bf5
Compare
Addressed comments |
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcCastPushdownTest.java
Outdated
Show resolved
Hide resolved
|
||
public CastTestCase | ||
public record FailCastTestCase(String sourceColumn, String castType, String errorMessage, Optional<String> pushdownErrorMessage) |
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.
Why not to use different factory methods for CastTestCase ?
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.
I think its better to have two separate records for success and failed cases. As targetColumn
is not necessary in failed case and errorMessage
, pushdownErrorMessage
is not required for success case.
Introducing factory method
public record CastTestCase(String sourceColumn, String castType, Optional<String> targetColumn, Optional<String> errorMessage, Optional<String> pushdownErrorMessage)
{
public CastTestCase
{
requireNonNull(sourceColumn, "sourceColumn is null");
requireNonNull(castType, "castType is null");
requireNonNull(targetColumn, "targetColumn is null");
requireNonNull(targetColumn, "errorMessage is null");
requireNonNull(targetColumn, "pushdownErrorMessage is null");
}
public CastTestCase castTestCase(String sourceColumn, String castType, String targetColumn)
{
return new CastTestCase(sourceColumn, castType, Optional.of(targetColumn), Optional.empty(), Optional.empty());
}
public CastTestCase failingCastTestCase(String sourceColumn, String castType)
{
return new CastTestCase(sourceColumn, castType, Optional.empty(), Optional.of("(.*)Cannot cast (.*) to (.*)"), Optional.empty());
}
public CastTestCase failingCastTestCase(String sourceColumn, String castType, String errorMessage)
{
return new CastTestCase(sourceColumn, castType, Optional.empty(), Optional.of(errorMessage), Optional.empty());
}
public CastTestCase failingCastTestCase(String sourceColumn, String castType, String errorMessage, String pushdownErrorMessage)
{
return new CastTestCase(sourceColumn, castType, Optional.empty(), Optional.of(errorMessage), Optional.of(pushdownErrorMessage));
}
}
By having 2 separate records.
public record CastTestCase(String sourceColumn, String castType, String targetColumn)
{
public CastTestCase
{
requireNonNull(sourceColumn, "sourceColumn is null");
requireNonNull(castType, "castType is null");
requireNonNull(targetColumn, "targetColumn is null");
}
}
public record FailCastTestCase(String sourceColumn, String castType, String errorMessage, Optional<String> pushdownErrorMessage)
{
public FailCastTestCase(String sourceColumn, String castType)
{
this(sourceColumn, castType, "(.*)Cannot cast (.*) to (.*)");
}
public FailCastTestCase(String sourceColumn, String castType, String errorMessage)
{
this(sourceColumn, castType, errorMessage, Optional.empty());
}
public FailCastTestCase
{
requireNonNull(sourceColumn, "sourceColumn is null");
requireNonNull(castType, "castType is null");
requireNonNull(errorMessage, "errorMessage is null");
requireNonNull(pushdownErrorMessage, "pushdownErrorMessage is null");
}
}
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcCastPushdownTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcCastPushdownTest.java
Outdated
Show resolved
Hide resolved
9dd5bf5
to
d81aea7
Compare
Thanks @SemionPar @ssheikin @Praveen2112 for the review. Addressed comments. |
d81aea7
to
40a2d89
Compare
(Ready for review) |
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. % change
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/BaseJdbcCastPushdownTest.java
Outdated
Show resolved
Hide resolved
40a2d89
to
762da87
Compare
762da87
to
61c371f
Compare
61c371f
to
346a6cc
Compare
(rebased with master) |
Description
Follow up of #22728 (comment) and #22951 (comment)
Release notes
(X) This is not user-visible or is docs only, and no release notes are required.