opteryx icon indicating copy to clipboard operation
opteryx copied to clipboard

🪲 String Concatination in JOIN

Open joocer opened this issue 2 years ago • 3 comments
trafficstars

Sample Code/Statement If you can, please submit the SQL statement or Python code snippet, or a representative example using the sample datasets.

SELECT * FROM A JOIN B ON 'b' || A.a = B.b

Field 'StringConcat' does not exist

joocer avatar Feb 21 '23 22:02 joocer

SELECT * FROM $planets AS A JOIN $planets AS B ON ('E' || A.name) = B.name

'NoneType' object has no attribute 'upper'

What appears to be happening is that the condition isn't evaluated before the join code is called and the code doesn't check if the node is an identifier before extracting the value. So we get the function name (StringConcat) or the marker for nesting (None)

joocer avatar Feb 23 '23 18:02 joocer

Compare to DuckDB to confirm expected behaviour

joocer avatar Feb 25 '23 23:02 joocer

in DuckDB

SELECT * FROM $planets AS A JOIN $planets AS B ON A.gravity * 1 = B.gravity;

returns the same as

SELECT * FROM $planets AS A JOIN $planets AS B ON A.gravity = B.gravity;

joocer avatar Feb 26 '23 00:02 joocer