DRILL-1835: Fix sort and join when results include complex types