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

Mihai Budiu commented on CALCITE-7742:
--------------------------------------

According to one of these clever agents, the bug is in the fact that all type 
factories share a single cache for interning types: DATATYPE_CACHE. Type 
equality is decided according to digests, but different factories may generate 
the same digest for different types. Consider these two types:

 
||createSqlType, precision||Type system||Stored 
precision||{{getPrecision()}}||Digest||Unparses to||
|{{{}CHAR{}}}, unspecified|DEFAULT|-1|1|{{CHAR}}|{{CHAR(1)}}|
|{{{}CHAR{}}}, unspecified|MySQL|-1|-1|{{CHAR}}|{{CHAR}}|

The type stores the type system inside, and that's why getPrecision() returns 
different results for the two.

When you call unparse, whether you get CHAR or CHAR(1)  depends on which test 
managed to install first its type in the cache – the cache considers them 
equal, since they have the same digest.

The clever agent produced a fix for this bug, but I am not sure it's a 
principled one. What is a principled fix?

> Test framework has non-determinstic tests
> -----------------------------------------
>
>                 Key: CALCITE-7742
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7742
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.42.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> Some tests intermittently fail in CI, here's an example output:
> {code:java}
> FAILURE   0.1sec, 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterRoundTripTest > 
> testCastToChar()
>     java.lang.AssertionError:
>     Expected: is "SELECT CAST(`product_id` AS CHAR)\nFROM 
> `foodmart`.`product`"
>          but: was "SELECT CAST(`product_id` AS CHAR(1))\nFROM 
> `foodmart`.`product`" {code}
> Seemingly this is because there is some shared state between concurrent 
> tests, e.g., perhaps a custom type system installed?



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

Reply via email to