Hello,

 

What happens when you concatenate a CHAR(N) and a VARCHAR value?

Calcite seems to insert no casts before concatenation, so the trailing
spaces for the CHAR(N) value are preserved.

However, Postgres has the following test:

 

https://github.com/postgres/postgres/blob/5bcc7e6dc8cb6fb6ab16c118a1e710fc85
096f76/src/test/regress/expected/strings.out#L1802C1-L1805C21

 

SELECT char(20) 'characters' || ' and text' AS "Concat char to unknown
type";

Concat char to unknown type 

-----------------------------

characters and text

 

The same test (adapted for the Babel syntax) evaluates statically in Calcite
to:

 

"characters           and text"

 

It looks like Postgres implicitly casts the CHAR(20) value to TEXT before
concatenation.

I have stared at tables with type conversions in various databases for a
long time, but I could not figure out what the result is supposed to be. 

 

Thank you,

Mihai

Reply via email to