public static SortOrder buildSortOrder(Table table) {
    return buildSortOrder(table.schema(), table.spec(), table.sortOrder());
  }
@Test
  public void testSortOrderClusteringSatisfiedPartitionLast() {
    PartitionSpec spec = PartitionSpec.builderFor(SCHEMA).identity("category").day("ts").build();
    SortOrder order =
        SortOrder.builderFor(SCHEMA)
            .withOrderId(1)
            .asc("category")
            .asc("ts") // satisfies the ordering of days(ts)
            .desc("id")
            .build();

    SortOrder expected =
        SortOrder.builderFor(SCHEMA).withOrderId(1).asc("category").asc("ts").desc("id").build();

    assertThat(SortOrderUtil.buildSortOrder(SCHEMA, spec, order))
        .as("Should add spec fields as prefix")
        .isEqualTo(expected);
  }