Legacy search location gateway is not correctly quoting depth column, which led to an error stating that "depth" column is ambiguous when I was trying to create custom SortClauseHandler, in which I was joining external table which also contained depth column.
In my controller, I create a LocationQuery with some basic criterions:
I also create sort clause, in which I use custom sort clause handler:
In the custom sort clause handler, I have something like this inside applyJoin method:
where "my_external_table" is the table which also contains "depth" column.