CSPACE-5943: Incorporate the latest candidate SQL query from CSPACE-5945.