I have a column geohash with precision p used as a primary key. I want to leverage the index in queries of type :
SELECT ... WHERE geohash IN geohashesInBox(lon_min, lat_min, lon_max, lat_max, p)
The above query fails with :
Type mismatch in IN or VALUES section. Expected: String. Got: Array.
Becasue geohashesInBox returns Array(String).
The alternatives I tried :
SELECT ... WHERE has(geohashesInBox(lon_min, lat_min, lon_max, lat_max, p), geostr)SELECT ... FROM some_table JOIN (SELECT arrayJoin(geohashesInBox(...)) AS box_geohash) ON geohash = box_geohashThe ideal solution would be to use IN with a tuple returned by geohashesInBox.
Is there a way to convert the returned Array to a Tuple ? Something like the unpacking operator in Python : tuple(*some_array) ?
Try that:
SELECT ... WHERE geohash IN (SELECT arrayJoin(geohashesInBox(...)) AS box_geohash)
Hi @yamrzou !
Well, there was a plan to fix operator IN just for that, but it has low priority due to a workaround @filimonov just posted.
And right now there is no way to convert Array to Tuple. IIRC, there are no plans to do that either.
Hi @Enmk,
For now the workaround proposed by @filimonov works perfectly. Thanks a lot !
@yamrzou, do you have any further questions?
Thanks @blinkov. No, this issue can be closed.
Most helpful comment
Try that:
Related: https://github.com/ClickHouse/ClickHouse/pull/5342