Skip to content

summarize() multiple columns return columns in random order #1246

@cashlo

Description

@cashlo

I don't really know how is the columns ordered after a summarize() my expectation is in the order of:

  1. In the order of passed columnNames
  2. In the order of the original table
  3. In alphabetical order

But it seems to be in random order, and the column name seems to be a factor?

Here's a short example:

public Table createMockTable(String metricName1, String metricName2) {
    Table mockTable = Table.create()
            .addColumns(
                      StringColumn.create("id"), 
                      LongColumn.create(metricName1), 
                      LongColumn.create(metricName2)
);

    Row row1 = mockTable.appendRow();
    row1.setString("id", "123");
    row1.setLong(metricName1, 123);
    row1.setLong(metricName2, 234);

    return mockTable
            .summarize(List.of(metricName1, metricName2), AggregateFunctions.sum)
            .by("id");
}

@Test
void wat() {
    Table mockTable1 = createMockTable("metric1", "metric2");
    Table mockTable2 = createMockTable("metricf1", "metricf2");

    System.out.println(mockTable1.print());
    System.out.println(mockTable2.print());
}

And the result is:

               null summary                
 id   |  Sum [metric1]  |  Sum [metric2]  |
-------------------------------------------
 123  |            123  |            234  |
                null summary                 
 id   |  Sum [metricf2]  |  Sum [metricf1]  |
---------------------------------------------
 123  |             234  |             123  |

I don't know if this is expected, if it is I can't seems to find this on the docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions