opteryx
opteryx copied to clipboard
🪲 String Concatination in JOIN
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
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)
Compare to DuckDB to confirm expected behaviour
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;