Github user ajithme commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2589#discussion_r207721977 --- Diff: store/core/src/main/java/org/apache/carbondata/store/impl/MetaOperation.java --- @@ -145,26 +152,61 @@ private void createTable(TableInfo tableInfo, boolean ifNotExists) throws IOExce } } - public void dropTable(TableIdentifier table) throws IOException { - String tablePath = store.getTablePath(table.getTableName(), table.getDatabaseName()); + public void dropTable(TableIdentifier table) throws CarbonException { + String tablePath = getTablePath(table.getTableName(), table.getDatabaseName()); cache.remove(tablePath); - FileFactory.deleteFile(tablePath); + try { + FileFactory.deleteFile(tablePath); + } catch (IOException e) { + throw new CarbonException(e); + } + } + + public TableInfo getTable(TableIdentifier table) throws CarbonException { + return getTable(table, storeConf); } - public CarbonTable getTable(TableIdentifier table) throws IOException { - String tablePath = store.getTablePath(table.getTableName(), table.getDatabaseName()); + public static TableInfo getTable(TableIdentifier table, StoreConf storeConf) + throws CarbonException { + String tablePath = getTablePath(table.getTableName(), table.getDatabaseName(), storeConf); if (cache.containsKey(tablePath)) { return cache.get(tablePath); } else { - org.apache.carbondata.format.TableInfo formatTableInfo = - CarbonUtil.readSchemaFile(CarbonTablePath.getSchemaFilePath(tablePath)); + org.apache.carbondata.format.TableInfo formatTableInfo = null; + try { + formatTableInfo = CarbonUtil.readSchemaFile(CarbonTablePath.getSchemaFilePath(tablePath)); + } catch (IOException e) { + throw new CarbonException(e); + } SchemaConverter schemaConverter = new ThriftWrapperSchemaConverterImpl(); TableInfo tableInfo = schemaConverter.fromExternalToWrapperTableInfo( formatTableInfo, table.getDatabaseName(), table.getTableName(), tablePath); tableInfo.setTablePath(tablePath); - CarbonTable carbonTable = CarbonTable.buildFromTableInfo(tableInfo); - cache.put(tablePath, carbonTable); - return carbonTable; + cache.put(tablePath, tableInfo); + return tableInfo; } } -} \ No newline at end of file + + public List<TableDescriptor> listTable() throws CarbonException { + throw new UnsupportedOperationException(); + } + + public TableDescriptor getDescriptor(TableIdentifier table) throws CarbonException { + throw new UnsupportedOperationException(); + } + + public void alterTable(TableIdentifier table, TableDescriptor newTable) throws CarbonException { + throw new UnsupportedOperationException(); + } + + public String getTablePath(String tableName, String databaseName) { + Objects.requireNonNull(tableName); + Objects.requireNonNull(databaseName); + return String.format("%s/%s", storeConf.storeLocation(), tableName); + } + public static String getTablePath(String tableName, String databaseName, StoreConf storeConf) { + Objects.requireNonNull(tableName); + Objects.requireNonNull(databaseName); + return String.format("%s/%s", storeConf.storeLocation(), tableName); --- End diff -- must consider database name in path
---