Skip to content

Commit

Permalink
[core][bug]Fix partition table get index RowType error
Browse files Browse the repository at this point in the history
  • Loading branch information
hawk9821 committed Aug 5, 2024
1 parent a838be6 commit d0e0c76
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@

package org.apache.paimon.flink;

import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.catalog.CatalogContext;
import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
import org.apache.paimon.crosspartition.IndexBootstrap;
import org.apache.paimon.fs.Path;
import org.apache.paimon.table.FileStoreTable;

import org.apache.flink.types.Row;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

import static org.apache.paimon.crosspartition.IndexBootstrap.BUCKET_FIELD;
import static org.assertj.core.api.Assertions.assertThat;

/** ITCase for batch file store. */
Expand Down Expand Up @@ -161,4 +170,27 @@ public void testLargeRecords() {
sql("insert into large_t select * from src");
assertThat(sql("select k, count(*) from large_t group by k having count(*) > 1")).isEmpty();
}

@Test
public void testBootstrapType() throws Exception {
Catalog catalog = CatalogFactory.createCatalog(CatalogContext.create(new Path(path)));
FileStoreTable T = (FileStoreTable) catalog.getTable(Identifier.create("default", "T"));
FileStoreTable partial_update_t =
(FileStoreTable) catalog.getTable(Identifier.create("default", "partial_update_t"));
FileStoreTable first_row_t =
(FileStoreTable) catalog.getTable(Identifier.create("default", "first_row_t"));
assertThat(IndexBootstrap.bootstrapType(T.schema()).getFieldNames()).contains(BUCKET_FIELD);
assertThat(IndexBootstrap.bootstrapType(partial_update_t.schema()).getFieldNames())
.contains(BUCKET_FIELD);
assertThat(IndexBootstrap.bootstrapType(first_row_t.schema()).getFieldNames())
.contains(BUCKET_FIELD);
assertThat(IndexBootstrap.bootstrapType(T.schema()).getFieldIndex(BUCKET_FIELD))
.isEqualTo(2);
assertThat(
IndexBootstrap.bootstrapType(partial_update_t.schema())
.getFieldIndex(BUCKET_FIELD))
.isEqualTo(2);
assertThat(IndexBootstrap.bootstrapType(first_row_t.schema()).getFieldIndex(BUCKET_FIELD))
.isEqualTo(2);
}
}

0 comments on commit d0e0c76

Please sign in to comment.