Hi Milhai, you can obtain this behavior by overriding shouldConvertRaggedUnionTypesToVarying to true in RelDataTypeSystem.
https://calcite.apache.org/javadocAggregate/org/apache/calcite/rel/type/RelDataTypeSystem.html#shouldConvertRaggedUnionTypesToVarying() https://github.com/apache/calcite/blob/3ab8003106507b1664ad2c42860789776a816cd3/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java#L347-L355 you can also change the SqlConformance: https://github.com/apache/calcite/blob/3ab8003106507b1664ad2c42860789776a816cd3/core/src/main/java/org/apache/calcite/sql/validate/SqlConformanceEnum.java#L348-L362 On Tue, Jul 18, 2023 at 7:04 PM <[email protected]> wrote: > Hello, > > > > I have a question about the type inference for case expressions. Consider > this query from the Postgres tests: > > > https://github.com/postgres/postgres/blob/137b131d6fbd29b4acf740aba3f74220fa > ef2678/src/test/regress/expected/case.out#L136 > <https://github.com/postgres/postgres/blob/137b131d6fbd29b4acf740aba3f74220faef2678/src/test/regress/expected/case.out#L136> > > > > SELECT i AS "Value", > > CASE WHEN (i < 0) THEN 'small' > > WHEN (i = 0) THEN 'zero' > > WHEN (i = 1) THEN 'one' > > WHEN (i = 2) THEN 'two' > > ELSE 'big' > > END AS "Category" > > FROM CASE_TBL; > > > > Calcite infers a type of CHAR(5) for the "Category" column, but Postgres > infers a type of VARCHAR. > > As a result, using Calcite the output is padded with spaces. > > > > Is this the expected result, or is this a bug? > > > > Thank you, > > Mihai > >
