duckdb-web icon indicating copy to clipboard operation
duckdb-web copied to clipboard

Inconsistency in the Casting Operation Matrix?

Open vlulla opened this issue 1 year ago • 1 comments

How should I read the table/figure listed at https://duckdb.org/docs/sql/data_types/typecasting#casting-operations-matrix? It appears that reading the cell at R1C1 the rows ought to be read as from type and the columns ought to be read as to type. But that does not make sense, at least to me. For instance, typing select '10' > 9 in duckdb will print true indicating that the left operand has been implicitly typecast from varchar to int. So, shouldn't the varchar column be transposed? I.e., all values from varchar can be implicitly converted to other types! By the way, this implicit conversion of string literal to any other type is mentioned explicitly at https://duckdb.org/docs/sql/data_types/literal_types#string-literals. I find this figure a little confusing and am wondering if it cannot be fixed up to be more precise. Regardless, thanks for all the good work on duckdb documentation!

vlulla avatar Apr 28 '24 21:04 vlulla

There is a difference between columns of type VARCHAR and string literals. See the page https://duckdb.org/docs/sql/data_types/literal_types which is linked to from the site you cited.

That being said, it would probably be useful to add "LITERALSTRING" and "LITERALINTEGER" etc. to the matrix.

soerenwolfers avatar May 02 '24 11:05 soerenwolfers