diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java index 06dccc263e41b..d454786ee9f22 100644 --- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java +++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/groupby/GroupByMemoryMergedResultTest.java @@ -204,7 +204,7 @@ void assertNextForDistinctShorthandResultSetsEmpty() throws SQLException { ShardingSphereTable table = mock(ShardingSphereTable.class); when(schema.getTable("t_order")).thenReturn(table); when(schema.containsTable("t_order")).thenReturn(true); - when(table.getColumnValues()).thenReturn(Collections.emptyList()); + when(table.getAllColumns()).thenReturn(Collections.emptyList()); ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS); when(database.getSchema(DefaultDatabase.LOGIC_NAME)).thenReturn(schema); when(database.getSchemas()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, schema)); diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/insert/keygen/engine/GeneratedKeyContextEngine.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/insert/keygen/engine/GeneratedKeyContextEngine.java index 0bb6f85e5de2f..0e8563b39e628 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/insert/keygen/engine/GeneratedKeyContextEngine.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/context/segment/insert/keygen/engine/GeneratedKeyContextEngine.java @@ -62,7 +62,7 @@ private Optional findGenerateKeyColumn(final String tableName) { if (!schema.containsTable(tableName)) { return Optional.empty(); } - for (ShardingSphereColumn each : schema.getTable(tableName).getColumnValues()) { + for (ShardingSphereColumn each : schema.getTable(tableName).getAllColumns()) { if (each.isGenerated()) { return Optional.of(each.getName()); } @@ -111,7 +111,6 @@ private GeneratedKeyContext findGeneratedKey(final Map insertCo private int findGenerateKeyIndex(final Map insertColumnNamesAndIndexes, final String generateKeyColumnName) { String tableName = insertStatement.getTable().map(optional -> optional.getTableName().getIdentifier().getValue()).orElse(""); - return insertColumnNamesAndIndexes.isEmpty() ? schema.getVisibleColumnNamesAndIndexes(tableName).get(generateKeyColumnName) - : insertColumnNamesAndIndexes.get(generateKeyColumnName); + return insertColumnNamesAndIndexes.isEmpty() ? schema.getVisibleColumnAndIndexMap(tableName).get(generateKeyColumnName) : insertColumnNamesAndIndexes.get(generateKeyColumnName); } } diff --git a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java index 11efe5897433d..8c74c0dd5b49c 100644 --- a/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java +++ b/infra/binder/src/main/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinder.java @@ -146,7 +146,7 @@ private static SimpleTableSegmentBinderContext createSimpleTableSegmentBinderCon final SQLStatementBinderContext binderContext, final IdentifierValue tableName) { Collection projectionSegments = new LinkedList<>(); QuoteCharacter quoteCharacter = new DatabaseTypeRegistry(binderContext.getDatabaseType()).getDialectDatabaseMetaData().getQuoteCharacter(); - for (ShardingSphereColumn each : schema.getTable(tableName.getValue()).getColumnValues()) { + for (ShardingSphereColumn each : schema.getTable(tableName.getValue()).getAllColumns()) { ColumnProjectionSegment columnProjectionSegment = new ColumnProjectionSegment(createColumnSegment(segment, databaseName, schemaName, each, quoteCharacter, tableName)); columnProjectionSegment.setVisible(each.isVisible()); projectionSegments.add(columnProjectionSegment); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/SubquerySegmentBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/SubquerySegmentBinderTest.java index 1dd245111b0ee..7418e027d75bd 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/SubquerySegmentBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/expression/type/SubquerySegmentBinderTest.java @@ -104,7 +104,7 @@ void assertBind() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/JoinTableSegmentBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/JoinTableSegmentBinderTest.java index b8fbed79a2def..bea6206b01a02 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/JoinTableSegmentBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/JoinTableSegmentBinderTest.java @@ -225,11 +225,11 @@ private JoinTableSegment mockLeftJoinSegment() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); - when(schema.getTable("t_order_item").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order_item").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("item_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("order_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinderTest.java index 84c7b7fd20b47..737db24714555 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SimpleTableSegmentBinderTest.java @@ -58,11 +58,11 @@ void assertBindTableNotExists() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); - when(schema.getTable("pg_database").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("pg_database").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("datname", Types.VARCHAR, false, false, false, true, false, false), new ShardingSphereColumn("datdba", Types.VARCHAR, false, false, false, true, false, false))); ShardingSphereMetaData result = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SubqueryTableSegmentBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SubqueryTableSegmentBinderTest.java index d09954cc63ea6..ab9c5c9818f9f 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SubqueryTableSegmentBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/segment/from/type/SubqueryTableSegmentBinderTest.java @@ -139,7 +139,7 @@ void assertBindWithoutSubqueryTableAlias() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java index b61e882ca4aa0..b0f0d9a50fe1c 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/DeleteStatementBinderTest.java @@ -70,7 +70,7 @@ void assertBind() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java index 80d23167e50cf..73369254b2ce8 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/InsertStatementBinderTest.java @@ -167,7 +167,7 @@ private static void assertInsertSelect(final InsertStatement actual) { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java index 7fa395f698eb4..f3c684d3c03b8 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/SelectStatementBinderTest.java @@ -106,7 +106,7 @@ private static WhereSegment mockWhereSegment() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java index c22d17d592700..0507f621dcee0 100644 --- a/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java +++ b/infra/binder/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dml/UpdateStatementBinderTest.java @@ -70,7 +70,7 @@ void assertBind() { private ShardingSphereMetaData createMetaData() { ShardingSphereSchema schema = mock(ShardingSphereSchema.class, RETURNS_DEEP_STUBS); - when(schema.getTable("t_order").getColumnValues()).thenReturn(Arrays.asList( + when(schema.getTable("t_order").getAllColumns()).thenReturn(Arrays.asList( new ShardingSphereColumn("order_id", Types.INTEGER, true, false, false, true, false, false), new ShardingSphereColumn("user_id", Types.INTEGER, false, false, false, true, false, false), new ShardingSphereColumn("status", Types.INTEGER, false, false, false, true, false, false))); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java index 247aa8c5371ab..5fcf2008660ef 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java @@ -203,13 +203,13 @@ public List getVisibleColumnNames(final String tableName) { } /** - * Get visible column names and indexes via table. + * Get visible column name and indexe map. * * @param tableName table name - * @return visible column names and indexes + * @return visible column name and index map */ - public Map getVisibleColumnNamesAndIndexes(final String tableName) { - return containsTable(tableName) ? getTable(tableName).getVisibleColumnsAndIndexMap() : Collections.emptyMap(); + public Map getVisibleColumnAndIndexMap(final String tableName) { + return containsTable(tableName) ? getTable(tableName).getVisibleColumnAndIndexMap() : Collections.emptyMap(); } /** diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java index 31d6a3a6f76ba..b1816709f15a3 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java @@ -44,17 +44,17 @@ public final class ShardingSphereTable { @Getter(AccessLevel.NONE) private final Map columns; - private final Map indexes; - - private final Map constraints; - private final List columnNames = new ArrayList<>(); + private final List primaryKeyColumns = new ArrayList<>(); + private final List visibleColumns = new ArrayList<>(); - private final Map visibleColumnsAndIndexMap = new CaseInsensitiveMap<>(); + private final Map visibleColumnAndIndexMap = new CaseInsensitiveMap<>(); - private final List primaryKeyColumns = new ArrayList<>(); + private final Map indexes; + + private final Map constraints; private final TableType type; @@ -87,7 +87,7 @@ private Map createColumn } if (each.isVisible()) { visibleColumns.add(each.getName()); - visibleColumnsAndIndexMap.put(each.getName(), index++); + visibleColumnAndIndexMap.put(each.getName(), index++); } } return result; @@ -110,21 +110,21 @@ private Map createConstraints(final Collection } /** - * Get column meta data via column name. + * Get column. * * @param columnName column name - * @return column meta data + * @return column */ public ShardingSphereColumn getColumn(final String columnName) { return columns.get(new ShardingSphereMetaDataIdentifier(columnName)); } /** - * Get column meta data list. + * Get all columns. * - * @return column meta data list + * @return columns */ - public Collection getColumnValues() { + public Collection getAllColumns() { return columns.values(); } @@ -139,16 +139,16 @@ public boolean containsColumn(final String columnName) { } /** - * Put index meta data. + * Put index. * - * @param index index meta data + * @param index index */ public void putIndex(final ShardingSphereIndex index) { indexes.put(index.getName(), index); } /** - * Remove index meta data via index name. + * Remove index. * * @param indexName index name */ @@ -157,38 +157,38 @@ public void removeIndex(final String indexName) { } /** - * Get index meta data via index name. + * Get index. * * @param indexName index name - * @return index meta data + * @return index */ public ShardingSphereIndex getIndex(final String indexName) { return indexes.get(indexName); } /** - * Get index meta data collection. + * Get indexes. * - * @return index meta data collection + * @return indexes */ public Collection getIndexValues() { return indexes.values(); } /** - * Judge whether contains index or not. + * Judge whether contains index. * * @param indexName index name - * @return whether contains index or not + * @return contains index or not */ public boolean containsIndex(final String indexName) { return null != indexName && indexes.containsKey(indexName); } /** - * Get constraint meta data collection. + * Get constraint. * - * @return constraint meta data collection + * @return constraint */ public Collection getConstraintValues() { return constraints.values(); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereTableDataCollectorUtils.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereTableDataCollectorUtils.java index 25033b786acab..3fda8561dd443 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereTableDataCollectorUtils.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/statistics/collector/ShardingSphereTableDataCollectorUtils.java @@ -42,7 +42,7 @@ public final class ShardingSphereTableDataCollectorUtils { */ public static List createRowValue(final Map columnValues, final ShardingSphereTable table) { List result = new LinkedList<>(); - for (ShardingSphereColumn each : table.getColumnValues()) { + for (ShardingSphereColumn each : table.getAllColumns()) { result.add(columnValues.getOrDefault(each.getName(), mockValue(each.getDataType()))); } return result; diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapper.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapper.java index d35726d4fcfc9..c8f00fb4e2fb0 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapper.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapper.java @@ -48,7 +48,7 @@ public final class YamlTableSwapper implements YamlConfigurationSwapper createSchemaMetaDataMap(final Collection actual) { assertThat(actual.size(), is(2)); - assertTrue(actual.get("data_node_routed_table1").getColumnValues().isEmpty()); - assertTrue(actual.get("data_node_routed_table2").getColumnValues().isEmpty()); + assertTrue(actual.get("data_node_routed_table1").getAllColumns().isEmpty()); + assertTrue(actual.get("data_node_routed_table2").getAllColumns().isEmpty()); } } diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java index 7b70b3f61132b..d6a50d339c5d7 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTableTest.java @@ -43,12 +43,12 @@ void assertGetColumn() { } @Test - void assertGetColumnValues() { + void assertGetAllColumns() { ShardingSphereColumn column1 = new ShardingSphereColumn("foo_col_1", Types.INTEGER, true, true, false, true, false, false); ShardingSphereColumn column2 = new ShardingSphereColumn("foo_col_2", Types.INTEGER, false, true, false, true, false, false); ShardingSphereTable shardingSphereTable = new ShardingSphereTable("foo_tbl", Arrays.asList(column1, column2), Collections.emptyList(), Collections.emptyList()); - assertThat(shardingSphereTable.getColumnValues(), hasItems(column1, column2)); - assertThat(shardingSphereTable.getColumnValues(), hasSize(2)); + assertThat(shardingSphereTable.getAllColumns(), hasItems(column1, column2)); + assertThat(shardingSphereTable.getAllColumns(), hasSize(2)); } @Test diff --git a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistService.java b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistService.java index c8a09ba052f5c..a09d909e55302 100644 --- a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistService.java +++ b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistService.java @@ -104,7 +104,7 @@ private void persistSchema(final String databaseName, final String schemaName) { private void persistTableData(final ShardingSphereDatabase database, final String schemaName, final ShardingSphereSchemaData schemaData) { schemaData.getTableData().values().forEach(each -> { YamlShardingSphereRowDataSwapper swapper = - new YamlShardingSphereRowDataSwapper(new ArrayList<>(database.getSchema(schemaName).getTable(each.getName()).getColumnValues())); + new YamlShardingSphereRowDataSwapper(new ArrayList<>(database.getSchema(schemaName).getTable(each.getName()).getAllColumns())); persistTableData(database.getName(), schemaName, each.getName(), each.getRows().stream().map(swapper::swapToYamlConfiguration).collect(Collectors.toList())); }); } diff --git a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/metadata/table/TableRowDataPersistService.java b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/metadata/table/TableRowDataPersistService.java index e7a56ffd478e2..71380e1d7d594 100644 --- a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/metadata/table/TableRowDataPersistService.java +++ b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/metadata/table/TableRowDataPersistService.java @@ -77,7 +77,7 @@ public void delete(final String databaseName, final String schemaName, final Str */ public ShardingSphereTableData load(final String databaseName, final String schemaName, final String tableName, final ShardingSphereTable table) { ShardingSphereTableData result = new ShardingSphereTableData(tableName); - YamlShardingSphereRowDataSwapper swapper = new YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getColumnValues())); + YamlShardingSphereRowDataSwapper swapper = new YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getAllColumns())); for (String each : repository.getChildrenKeys(ShardingSphereDataNode.getTablePath(databaseName, schemaName, tableName))) { String yamlRow = repository.query(ShardingSphereDataNode.getTableRowPath(databaseName, schemaName, tableName, each)); if (!Strings.isNullOrEmpty(yamlRow)) { diff --git a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistServiceTest.java b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistServiceTest.java index 83ae6736c6402..76c513ed2d93c 100644 --- a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistServiceTest.java +++ b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/data/ShardingSphereDataPersistServiceTest.java @@ -78,7 +78,7 @@ private ShardingSphereMetaData mockMetaData() { when(result.containsDatabase("foo_db")).thenReturn(true); when(result.getDatabase("foo_db").containsSchema("foo_schema")).thenReturn(true); when(result.getDatabase("foo_db").getSchema("foo_schema").containsTable("foo_tbl")).thenReturn(true); - when(result.getDatabase("foo_db").getSchema("foo_schema").getTable("foo_tbl").getColumnValues()).thenReturn(Collections.emptyList()); + when(result.getDatabase("foo_db").getSchema("foo_schema").getTable("foo_tbl").getAllColumns()).thenReturn(Collections.emptyList()); when(result.containsDatabase("bar_db")).thenReturn(true); when(result.getDatabase("bar_db")).thenReturn(mock(ShardingSphereDatabase.class)); return result; @@ -101,7 +101,7 @@ void assertPersist() { when(schemaData.getTableData().values()).thenReturn(Collections.singleton(tableData)); ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS); when(database.getName()).thenReturn("foo_db"); - when(database.getSchema("foo_schema").getTable("foo_tbl").getColumnValues()).thenReturn(Collections.singleton(mock(ShardingSphereColumn.class))); + when(database.getSchema("foo_schema").getTable("foo_tbl").getAllColumns()).thenReturn(Collections.singleton(mock(ShardingSphereColumn.class))); persistService.persist(database, "foo_schema", schemaData); verify(tableRowDataPersistService).persist("foo_db", "foo_schema", "foo_tbl", Collections.emptyList()); } diff --git a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java index bac006825289c..2a365874dcb0e 100644 --- a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java +++ b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java @@ -168,7 +168,7 @@ private Enumerable createMemoryEnumerator(final ShardingSphereTableData @Override public Enumerator enumerator() { - return new MemoryRowEnumerator(tableData.getRows(), table.getColumnValues(), databaseType); + return new MemoryRowEnumerator(tableData.getRows(), table.getAllColumns(), databaseType); } }; } diff --git a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutorTest.java b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutorTest.java index 4843954603f1b..47c57ef397f0b 100644 --- a/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutorTest.java +++ b/kernel/sql-federation/executor/src/test/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutorTest.java @@ -63,7 +63,7 @@ void assertExecuteWithStatistics() { when(schemaData.getTable("test")).thenReturn(tableData); ShardingSphereTable table = mock(ShardingSphereTable.class, RETURNS_DEEP_STUBS); when(table.getName()).thenReturn("test"); - when(table.getColumnValues()).thenReturn(Collections.singleton(new ShardingSphereColumn("id", Types.INTEGER, true, false, false, false, true, false))); + when(table.getAllColumns()).thenReturn(Collections.singleton(new ShardingSphereColumn("id", Types.INTEGER, true, false, false, false, true, false))); Enumerable enumerable = new EnumerableScanExecutor(null, null, null, optimizerContext, executorContext, null, null, statistics) .execute(table, mock(ScanExecutorContext.class)); try (Enumerator actual = enumerable.enumerator()) { diff --git a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/util/SQLFederationDataTypeUtils.java b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/util/SQLFederationDataTypeUtils.java index 3d47a15c51760..cbf200d12c23a 100644 --- a/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/util/SQLFederationDataTypeUtils.java +++ b/kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/metadata/util/SQLFederationDataTypeUtils.java @@ -50,7 +50,7 @@ public final class SQLFederationDataTypeUtils { */ public static RelDataType createRelDataType(final ShardingSphereTable table, final DatabaseType protocolType, final RelDataTypeFactory typeFactory) { Builder fieldInfoBuilder = typeFactory.builder(); - for (ShardingSphereColumn each : table.getColumnValues()) { + for (ShardingSphereColumn each : table.getAllColumns()) { fieldInfoBuilder.add(each.getName(), getRelDataType(protocolType, each, typeFactory)); } return fieldInfoBuilder.build(); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ShardingSphereDatabaseDataManager.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ShardingSphereDatabaseDataManager.java index d779b57e396b5..773e72b0593f8 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ShardingSphereDatabaseDataManager.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/manager/ShardingSphereDatabaseDataManager.java @@ -138,7 +138,7 @@ public synchronized void alterShardingSphereRowData(final String databaseName, f return; } ShardingSphereTableData tableData = metaDataContexts.get().getStatistics().getDatabase(databaseName).getSchema(schemaName).getTable(tableName); - List columns = new ArrayList<>(metaDataContexts.get().getMetaData().getDatabase(databaseName).getSchema(schemaName).getTable(tableName).getColumnValues()); + List columns = new ArrayList<>(metaDataContexts.get().getMetaData().getDatabase(databaseName).getSchema(schemaName).getTable(tableName).getAllColumns()); tableData.getRows().add(new YamlShardingSphereRowDataSwapper(columns).swapToObject(yamlRowData)); } diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java index faf62f67ff6f8..5805810115000 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngine.java @@ -182,7 +182,7 @@ private AlteredShardingSphereDatabaseData createAlteredShardingSphereDatabaseDat AlteredShardingSphereDatabaseData result = new AlteredShardingSphereDatabaseData(databaseName, schemaName, tableData.getName()); Map tableDataMap = tableData.getRows().stream().collect(Collectors.toMap(ShardingSphereRowData::getUniqueKey, Function.identity())); Map changedTableDataMap = changedTableData.getRows().stream().collect(Collectors.toMap(ShardingSphereRowData::getUniqueKey, Function.identity())); - YamlShardingSphereRowDataSwapper swapper = new YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getColumnValues())); + YamlShardingSphereRowDataSwapper swapper = new YamlShardingSphereRowDataSwapper(new ArrayList<>(table.getAllColumns())); for (Entry entry : changedTableDataMap.entrySet()) { if (!tableDataMap.containsKey(entry.getKey())) { result.getAddedRows().add(swapper.swapToYamlConfiguration(entry.getValue())); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java index 33d891d030198..579b1bdfc9d69 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java @@ -65,7 +65,7 @@ private Optional findLogicTableName(final ShardingSphereSchema schema, f } private ShardingSphereTable newShardingSphereTable(final ShardingSphereTable table) { - ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getColumnValues(), table.getIndexValues(), table.getConstraintValues(), table.getType()); + ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getAllColumns(), table.getIndexValues(), table.getConstraintValues(), table.getType()); result.getColumnNames().addAll(table.getColumnNames()); result.getVisibleColumns().addAll(table.getVisibleColumns()); result.getPrimaryKeyColumns().addAll(table.getPrimaryKeyColumns()); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java index 7e79573c7dcb3..3b0e7ebb1cb0b 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java @@ -53,7 +53,7 @@ public void refresh(final MetaDataManagerPersistService metaDataManagerPersistSe } private ShardingSphereTable newShardingSphereTable(final ShardingSphereTable table) { - ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getColumnValues(), table.getIndexValues(), table.getConstraintValues(), table.getType()); + ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getAllColumns(), table.getIndexValues(), table.getConstraintValues(), table.getType()); result.getColumnNames().addAll(table.getColumnNames()); result.getVisibleColumns().addAll(table.getVisibleColumns()); result.getPrimaryKeyColumns().addAll(table.getPrimaryKeyColumns()); diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java index 94980f70319ff..b16f83e6fcb1d 100644 --- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java +++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/DropIndexStatementSchemaRefresher.java @@ -66,7 +66,7 @@ private Optional findLogicTableName(final ShardingSphereDatabase databas } private ShardingSphereTable newShardingSphereTable(final ShardingSphereTable table) { - ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getColumnValues(), table.getIndexValues(), table.getConstraintValues(), table.getType()); + ShardingSphereTable result = new ShardingSphereTable(table.getName(), table.getAllColumns(), table.getIndexValues(), table.getConstraintValues(), table.getType()); result.getColumnNames().addAll(table.getColumnNames()); result.getVisibleColumns().addAll(table.getVisibleColumns()); result.getPrimaryKeyColumns().addAll(table.getPrimaryKeyColumns()); diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/SchemaMetaDataManagerTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/SchemaMetaDataManagerTest.java index cd3eb5c1e7686..11a304d6974c5 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/SchemaMetaDataManagerTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/manager/SchemaMetaDataManagerTest.java @@ -159,7 +159,7 @@ void assertAlterSchemaForTableAltered() { ShardingSphereTable toBeChangedTable = new ShardingSphereTable("foo_tbl", Collections.singleton(toBeChangedColumn), Collections.emptyList(), Collections.emptyList()); schemaMetaDataManager.alterSchema("foo_db", "foo_schema", toBeChangedTable, null); ShardingSphereTable table = metaDataContexts.getMetaData().getDatabase("foo_db").getSchema("foo_schema").getTables().get("foo_tbl"); - assertThat(table.getColumnValues().size(), is(1)); + assertThat(table.getAllColumns().size(), is(1)); assertTrue(table.containsColumn("foo_col")); } diff --git a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngineTest.java b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngineTest.java index a4e194bd7b270..b6512f67dffed 100644 --- a/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngineTest.java +++ b/mode/core/src/test/java/org/apache/shardingsphere/mode/metadata/refresher/ShardingSphereStatisticsRefreshEngineTest.java @@ -96,7 +96,7 @@ private ShardingSphereMetaData mockMetaData() { Collection columns = new LinkedList<>(); columns.add(new ShardingSphereColumn("column1", Types.INTEGER, false, false, false, true, false, false)); columns.add(new ShardingSphereColumn("column2", Types.INTEGER, false, false, false, true, false, false)); - when(table.getColumnValues()).thenReturn(columns); + when(table.getAllColumns()).thenReturn(columns); return result; } } diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java index fcf55c1a054a4..fda5bd7fefc5e 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowTableMetaDataExecutor.java @@ -59,7 +59,7 @@ public Collection getRows(final ShowTableMetaDataStatem private Collection buildTableRows(final String databaseName, final ShardingSphereSchema schema, final String tableName) { Collection result = new LinkedList<>(); ShardingSphereTable table = schema.getTable(tableName); - result.addAll(table.getColumnValues().stream().map(each -> buildColumnRow(databaseName, tableName, each)).collect(Collectors.toList())); + result.addAll(table.getAllColumns().stream().map(each -> buildColumnRow(databaseName, tableName, each)).collect(Collectors.toList())); result.addAll(table.getIndexValues().stream().map(each -> buildIndexRow(databaseName, tableName, each)).collect(Collectors.toList())); return result; } diff --git a/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java b/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java index cf82c72eaef15..9fb696ed64725 100644 --- a/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java +++ b/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java @@ -157,7 +157,7 @@ private ShardingSphereDatabase mockDatabase() { when(result.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.emptyList())); when(result.containsSchema("public")).thenReturn(true); when(result.getSchema("public").containsTable("bmsql")).thenReturn(true); - when(result.getSchema("public").getTable("bmsql").getColumnValues()).thenReturn(Collections.singleton(new ShardingSphereColumn("id", Types.VARCHAR, false, false, false, true, false, false))); + when(result.getSchema("public").getTable("bmsql").getAllColumns()).thenReturn(Collections.singleton(new ShardingSphereColumn("id", Types.VARCHAR, false, false, false, true, false, false))); return result; } } diff --git a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java index 9e1eb1d2f71a1..7d9d64607cb5d 100644 --- a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java +++ b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java @@ -180,7 +180,7 @@ private PostgreSQLRowDescriptionPacket describeReturning(final ReturningSegment Collection result = new LinkedList<>(); for (ProjectionSegment each : returningSegment.getProjections().getProjections()) { if (each instanceof ShorthandProjectionSegment) { - table.getColumnValues().stream().map(column -> new PostgreSQLColumnDescription(column.getName(), 0, column.getDataType(), estimateColumnLength(column.getDataType()), "")) + table.getAllColumns().stream().map(column -> new PostgreSQLColumnDescription(column.getName(), 0, column.getDataType(), estimateColumnLength(column.getDataType()), "")) .forEach(result::add); } if (each instanceof ColumnProjectionSegment) { diff --git a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java index beb9728bff25c..2bc45f283654f 100644 --- a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java +++ b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java @@ -168,7 +168,7 @@ private ContextManager mockContextManager() { when(database.getSchema("public").containsTable("t_order")).thenReturn(true); when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database); when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true); - when(database.getSchema("public").getTable("t_order").getColumnValues()) + when(database.getSchema("public").getTable("t_order").getAllColumns()) .thenReturn(Collections.singleton(new ShardingSphereColumn("id", Types.VARCHAR, false, false, false, true, false, false))); return result; } diff --git a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java index cfdcb4dd5f657..41c0b317820d7 100644 --- a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java +++ b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java @@ -141,7 +141,7 @@ private ContextManager mockContextManager() { when(database.getRuleMetaData()).thenReturn(new RuleMetaData(Collections.emptyList())); when(database.containsSchema("public")).thenReturn(true); when(database.getSchema("public").containsTable("t")).thenReturn(true); - when(database.getSchema("public").getTable("t").getColumnValues()).thenReturn(Arrays.asList(new ShardingSphereColumn("id", Types.VARCHAR, false, false, false, true, false, false), + when(database.getSchema("public").getTable("t").getAllColumns()).thenReturn(Arrays.asList(new ShardingSphereColumn("id", Types.VARCHAR, false, false, false, true, false, false), new ShardingSphereColumn("col", Types.VARCHAR, false, false, false, true, false, false))); when(result.getMetaDataContexts().getMetaData().containsDatabase("db")).thenReturn(true); when(result.getMetaDataContexts().getMetaData().getDatabase("db")).thenReturn(database);