Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/concepts/system-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ SELECT * FROM my_table$table_indexes;
## Global System Table

Global system tables contain the statistical information of all the tables exists in paimon. For convenient of searching, we create a reference system database called `sys`.
We can display all the global system tables by sql in flink:
We can display all the global system tables by sql in flink or spark:

```sql
USE sys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import java.util.function.Function;

import static org.apache.paimon.table.system.AggregationFieldsTable.AGGREGATION_FIELDS;
import static org.apache.paimon.table.system.AllPartitionsTable.ALL_PARTITIONS;
import static org.apache.paimon.table.system.AllTableOptionsTable.ALL_TABLE_OPTIONS;
import static org.apache.paimon.table.system.AllTablesTable.ALL_TABLES;
import static org.apache.paimon.table.system.AuditLogTable.AUDIT_LOG;
import static org.apache.paimon.table.system.BinlogTable.BINLOG;
import static org.apache.paimon.table.system.BranchesTable.BRANCHES;
Expand Down Expand Up @@ -78,6 +80,9 @@ public class SystemTableLoader {

public static final List<String> SYSTEM_TABLES = new ArrayList<>(SYSTEM_TABLE_LOADERS.keySet());

public static final List<String> GLOBAL_SYSTEM_TABLES =
Arrays.asList(ALL_TABLES, ALL_PARTITIONS, ALL_TABLE_OPTIONS, CATALOG_OPTIONS);

@Nullable
public static Table load(String type, FileStoreTable dataTable) {
return Optional.ofNullable(SYSTEM_TABLE_LOADERS.get(type.toLowerCase()))
Expand All @@ -86,6 +91,6 @@ public static Table load(String type, FileStoreTable dataTable) {
}

public static List<String> loadGlobalTableNames() {
return Arrays.asList(ALL_TABLE_OPTIONS, CATALOG_OPTIONS);
return GLOBAL_SYSTEM_TABLES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.apache.paimon.table.sink.CommitMessage;
import org.apache.paimon.table.source.ReadBuilder;
import org.apache.paimon.table.source.TableScan;
import org.apache.paimon.table.system.AllTableOptionsTable;
import org.apache.paimon.table.system.CatalogOptionsTable;
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.types.RowType;
Expand Down Expand Up @@ -85,6 +83,7 @@
import static org.apache.paimon.catalog.Catalog.SYSTEM_DATABASE_NAME;
import static org.apache.paimon.table.system.AllTableOptionsTable.ALL_TABLE_OPTIONS;
import static org.apache.paimon.table.system.CatalogOptionsTable.CATALOG_OPTIONS;
import static org.apache.paimon.table.system.SystemTableLoader.GLOBAL_SYSTEM_TABLES;
import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
Expand Down Expand Up @@ -1044,10 +1043,7 @@ public void testGetTable() throws Exception {
() -> catalog.getTable(Identifier.create(SYSTEM_DATABASE_NAME, "1111")));

List<String> sysTables = catalog.listTables(SYSTEM_DATABASE_NAME);
assertThat(sysTables)
.containsExactlyInAnyOrder(
AllTableOptionsTable.ALL_TABLE_OPTIONS,
CatalogOptionsTable.CATALOG_OPTIONS);
assertThat(sysTables).containsAll(GLOBAL_SYSTEM_TABLES);

assertThat(catalog.listViews(SYSTEM_DATABASE_NAME)).isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.apache.paimon.flink;

import org.apache.paimon.catalog.Catalog;
import org.apache.paimon.table.system.AllTableOptionsTable;
import org.apache.paimon.table.system.CatalogOptionsTable;
import org.apache.paimon.utils.BlockingIterator;

import org.apache.paimon.shade.org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -53,6 +51,7 @@
import static org.apache.paimon.catalog.Catalog.NUM_FILES_PROP;
import static org.apache.paimon.catalog.Catalog.NUM_ROWS_PROP;
import static org.apache.paimon.catalog.Catalog.TOTAL_SIZE_PROP;
import static org.apache.paimon.table.system.SystemTableLoader.GLOBAL_SYSTEM_TABLES;
import static org.apache.paimon.testutils.assertj.PaimonAssertions.anyCauseMatches;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
Expand Down Expand Up @@ -207,9 +206,8 @@ public void testChangeTableInSystemDatabase() {
public void testSystemDatabase() {
sql("USE " + Catalog.SYSTEM_DATABASE_NAME);
assertThat(sql("SHOW TABLES"))
.containsExactlyInAnyOrder(
Row.of(AllTableOptionsTable.ALL_TABLE_OPTIONS),
Row.of(CatalogOptionsTable.CATALOG_OPTIONS));
.containsAll(
GLOBAL_SYSTEM_TABLES.stream().map(Row::of).collect(Collectors.toList()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.paimon.spark.table

import org.apache.paimon.spark.PaimonSparkTestBase
import org.apache.paimon.table.system.SystemTableLoader

import org.apache.spark.sql.Row

import scala.collection.JavaConverters._

class PaimonSystemTableTest extends PaimonSparkTestBase {

test("system table: show all global system tables") {
checkAnswer(
sql("SHOW TABLES IN sys").select("tableName"),
SystemTableLoader.GLOBAL_SYSTEM_TABLES.asScala.map(Row(_)).toSeq
)
}
}
Loading