[ 
https://issues.apache.org/jira/browse/CALCITE-5923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17755547#comment-17755547
 ] 

Runkang He commented on CALCITE-5923:
-------------------------------------

After fix this issue, the result check for `CAST` operator is turned on, and 
then, I find a test case `SqlOperatorTest.testCastStringToDateTime` fails due 
to the failed test below with latest calcite-avatica branch:
{code:java}
f.checkScalar("cast('1945-2-2 12:2:5' as TIMESTAMP)",
    "1945-02-02 12:02:05", "TIMESTAMP(0) NOT NULL");
{code}
The stacktrace is:
{code:java}
Caused by: java.lang.IllegalArgumentException: Invalid DATE value, '1945-2-2 
12:2:5'
    at 
org.apache.calcite.avatica.util.DateTimeUtils.invalidType(DateTimeUtils.java:809)
    at 
org.apache.calcite.avatica.util.DateTimeUtils.validateDate(DateTimeUtils.java:752)
    at 
org.apache.calcite.avatica.util.DateTimeUtils.timestampStringToUnixDate0(DateTimeUtils.java:828)
    at 
org.apache.calcite.avatica.util.DateTimeUtils.timestampStringToUnixDate(DateTimeUtils.java:815)
    ... 113 more
{code}
It seems related to the fix in CALCITE-5678 in avatica-1.24, which use ISO8601 
to validate the timestamp string.
I think we can safely modify this test case to use `checkFails` with message 
`Invalid DATE value`.
[~zstan] What do you think? Looking forward to your reply.

> Some test cases in `SqlOperatorTest` violates the test fixture's design 
> principle
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-5923
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5923
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Runkang He
>            Assignee: Runkang He
>            Priority: Minor
>              Labels: pull-request-available
>
> There are some test cases in `SqlOperatorTest` directly use the 
> `SqlOperatorFixtureImpl.DEFAULT` to get the `SqlOperatorFixture`, including 
> `SqlOperatorTest.testCast` and many other test cases related with `CAST` 
> operator. This causes that the result check is missing when execute 
> `CalciteSqlOperatorTest`, which should has result check.
> This violates the design principle introduced by CALCITE-4885, which we 
> should alway use `SqlOperatorTest.fixture()` to get the `SqlOperatorFixture`. 
> This principle allows us to override`fixture()` method in subclasses to run 
> tests in a different environment.
> So I think we should fix these related test cases to keep consistent with the 
> principle.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to