public static Optional<TableMetaData> load(final DataSource dataSource, final String tableNamePattern, final DatabaseType databaseType) throws SQLException {
        DialectDatabaseMetaData dialectDatabaseMetaData = new DatabaseTypeRegistry(databaseType).getDialectDatabaseMetaData();
        try (MetaDataLoaderConnection connection = new MetaDataLoaderConnection(databaseType, dataSource.getConnection())) {
            String formattedTableNamePattern = dialectDatabaseMetaData.formatTableNamePattern(tableNamePattern);
            return isTableExist(connection, formattedTableNamePattern)
                    ? Optional.of(new TableMetaData(tableNamePattern, ColumnMetaDataLoader.load(
                            connection, formattedTableNamePattern, databaseType), IndexMetaDataLoader.load(connection, formattedTableNamePattern), Collections.emptyList()))
                    : Optional.empty();
        }
    }
@Test
    void assertLoadWithExistedTable() throws SQLException {
        Map<String, SchemaMetaData> actual = MetaDataLoader.load(Collections.singleton(new MetaDataLoaderMaterial(Collections.singleton(TEST_TABLE), dataSource, databaseType, "sharding_db")));
        TableMetaData tableMetaData = actual.get("sharding_db").getTables().iterator().next();
        Collection<ColumnMetaData> columns = tableMetaData.getColumns();
        assertThat(columns.size(), is(2));
        Iterator<ColumnMetaData> columnsIterator = columns.iterator();
        assertColumnMetaData(columnsIterator.next(), "pk_col", Types.INTEGER, true, true);
        assertColumnMetaData(columnsIterator.next(), "col", Types.VARCHAR, false, false);
        Collection<IndexMetaData> indexes = tableMetaData.getIndexes();
        assertThat(indexes.size(), is(1));
        Iterator<IndexMetaData> indexesIterator = indexes.iterator();
        assertThat(indexesIterator.next().getName(), is("my_index"));
    }