Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzelin committed Dec 27, 2024
1 parent 64c250e commit b9c72c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/content/concepts/system-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,13 @@ SELECT * FROM T$statistics;
*/
```

### Indexes Table
### Table Indexes Table

You can query the table's index files generated for dynamic bucket table (index_type = HASH) and deletion vectors
(index_type = DELETION_VECTORS) through indexes table.

```sql
SELECT * FROM my_table$indexes;
SELECT * FROM my_table$table_indexes;

/*
+--------------------------------+-------------+--------------------------------+--------------------------------+----------------------+----------------------+--------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
import static org.apache.paimon.table.system.CatalogOptionsTable.CATALOG_OPTIONS;
import static org.apache.paimon.table.system.ConsumersTable.CONSUMERS;
import static org.apache.paimon.table.system.FilesTable.FILES;
import static org.apache.paimon.table.system.IndexesTable.INDEXES;
import static org.apache.paimon.table.system.ManifestsTable.MANIFESTS;
import static org.apache.paimon.table.system.OptionsTable.OPTIONS;
import static org.apache.paimon.table.system.PartitionsTable.PARTITIONS;
import static org.apache.paimon.table.system.ReadOptimizedTable.READ_OPTIMIZED;
import static org.apache.paimon.table.system.SchemasTable.SCHEMAS;
import static org.apache.paimon.table.system.SnapshotsTable.SNAPSHOTS;
import static org.apache.paimon.table.system.StatisticTable.STATISTICS;
import static org.apache.paimon.table.system.TableIndexesTable.TABLE_INDEXES;
import static org.apache.paimon.table.system.TagsTable.TAGS;

/** Loader to load system {@link Table}s. */
Expand All @@ -71,7 +71,7 @@ public class SystemTableLoader {
.put(AGGREGATION_FIELDS, AggregationFieldsTable::new)
.put(STATISTICS, StatisticTable::new)
.put(BINLOG, BinlogTable::new)
.put(INDEXES, IndexesTable::new)
.put(TABLE_INDEXES, TableIndexesTable::new)
.build();

public static final List<String> SYSTEM_TABLES = new ArrayList<>(SYSTEM_TABLE_LOADERS.keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
import static org.apache.paimon.catalog.Catalog.SYSTEM_TABLE_SPLITTER;
import static org.apache.paimon.utils.SerializationUtils.newStringType;

/** A {@link Table} for showing committing snapshots of table. */
public class IndexesTable implements ReadonlyTable {
/** A {@link Table} for showing indexes. */
public class TableIndexesTable implements ReadonlyTable {

private static final Logger LOG = LoggerFactory.getLogger(IndexesTable.class);
private static final Logger LOG = LoggerFactory.getLogger(TableIndexesTable.class);

public static final String INDEXES = "indexes";
public static final String TABLE_INDEXES = "table_indexes";

public static final RowType TABLE_TYPE =
new RowType(
Expand All @@ -87,7 +87,7 @@ public class IndexesTable implements ReadonlyTable {

private final FileStoreTable dataTable;

public IndexesTable(FileStoreTable dataTable) {
public TableIndexesTable(FileStoreTable dataTable) {
this.dataTable = dataTable;
}

Expand All @@ -103,7 +103,7 @@ public InnerTableRead newRead() {

@Override
public String name() {
return dataTable.name() + SYSTEM_TABLE_SPLITTER + INDEXES;
return dataTable.name() + SYSTEM_TABLE_SPLITTER + TABLE_INDEXES;
}

@Override
Expand All @@ -118,7 +118,7 @@ public List<String> primaryKeys() {

@Override
public Table copy(Map<String, String> dynamicOptions) {
return new IndexesTable(dataTable.copy(dynamicOptions));
return new TableIndexesTable(dataTable.copy(dynamicOptions));
}

private static class IndexesScan extends ReadOnceTableScan {
Expand Down Expand Up @@ -194,7 +194,7 @@ public RecordReader<InternalRow> createReader(Split split) {
Iterators.transform(
rows,
row ->
ProjectedRow.from(readType, IndexesTable.TABLE_TYPE)
ProjectedRow.from(readType, TableIndexesTable.TABLE_TYPE)
.replaceRow(row));
}
return new IteratorRecordReader<>(rows);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void testIndexesTable() {
"INSERT INTO T VALUES ('2024-10-01', 1, 'aaaaaaaaaaaaaaaaaaa'), ('2024-10-01', 2, 'b'), ('2024-10-01', 3, 'c')");
sql("INSERT INTO T VALUES ('2024-10-01', 1, 'a_new1'), ('2024-10-01', 3, 'c_new1')");

List<Row> rows = sql("SELECT * FROM `T$indexes` WHERE index_type = 'HASH'");
List<Row> rows = sql("SELECT * FROM `T$table_indexes` WHERE index_type = 'HASH'");
assertThat(rows.size()).isEqualTo(1);
Row row = rows.get(0);
assertThat(row.getField(0)).isEqualTo("[2024-10-01]");
Expand All @@ -84,7 +84,7 @@ public void testIndexesTable() {
assertThat(row.getField(5)).isEqualTo(3L);
assertThat(row.getField(6)).isNull();

rows = sql("SELECT * FROM `T$indexes` WHERE index_type = 'DELETION_VECTORS'");
rows = sql("SELECT * FROM `T$table_indexes` WHERE index_type = 'DELETION_VECTORS'");
assertThat(rows.size()).isEqualTo(1);
row = rows.get(0);
assertThat(row.getField(0)).isEqualTo("[2024-10-01]");
Expand Down

0 comments on commit b9c72c2

Please sign in to comment.