Konstantin Orlov created IGNITE-24699:
-----------------------------------------

             Summary: Sql. Query with ORDER BY returns unsorted result
                 Key: IGNITE-24699
                 URL: https://issues.apache.org/jira/browse/IGNITE-24699
             Project: Ignite
          Issue Type: Bug
          Components: sql
            Reporter: Konstantin Orlov


Run this test:
{code:java}
// org.apache.ignite.internal.sql.engine.ItSecondaryIndexTest
@Test
void ensurePartitionStreamsAreMergedCorrectlyWithRegardToProjection() {
    assertQuery("SELECT /*+ FORCE_INDEX(" + NAME_CITY_IDX + ") */ name FROM 
Developer WHERE id % 2 = 0 ORDER BY name DESC")
            .matches(containsIndexScan("PUBLIC", "DEVELOPER", NAME_CITY_IDX))
            .matches(not(containsSubPlan("Sort")))
            .returns("Zimmer")
            .returns("Stravinsky")
            .returns("Strauss")
            .returns("Shubert")
            .returns("Rihter")
            .returns("Prokofiev")
            .returns("O'Halloran")
            .returns("Einaudi")
            .returns("Chaikovsky")
            .returns("Beethoven")
            .returns("Arnalds")
            .ordered()
            .check();
} {code}
It fails with
{code}
org.opentest4j.AssertionFailedError: Collections are not equal (position 0):
Expected: Stravinsky <class java.lang.String>
Actual:   Rihter <class java.lang.String>
{code}

The reason is that comparator created to join streams of partition is created 
based on collation returned by relation node, which in turn may be adjusted 
with regard to projection merged into the real, but merge of partition is 
happening before the projection, therefore must account only for 
{{requiredColumns}} bitset.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to