public Object getFieldValue(_Fields field) { switch (field) { case FACT_TABLE: return getFact_table(); case AGGREGATE_TABLE_LIST: return getAggregate_table_list(); case DATA_MAP_SCHEMAS: return getDataMapSchemas(); } throw new IllegalStateException(); }
@Override public TableInfo fromExternalToWrapperTableInfo( org.apache.carbondata.format.TableInfo externalTableInfo, String dbName, String tableName, String tablePath) { TableInfo wrapperTableInfo = new TableInfo(); List<org.apache.carbondata.format.SchemaEvolutionEntry> schemaEvolutionList = externalTableInfo.getFact_table().getSchema_evolution().getSchema_evolution_history(); wrapperTableInfo.setLastUpdatedTime( schemaEvolutionList.get(schemaEvolutionList.size() - 1).getTime_stamp()); wrapperTableInfo.setDatabaseName(dbName); wrapperTableInfo.setTableUniqueName(CarbonTable.buildUniqueName(dbName, tableName)); wrapperTableInfo.setFactTable( fromExternalToWrapperTableSchema(externalTableInfo.getFact_table(), tableName)); if (null != externalTableInfo.getDataMapSchemas()) { wrapperTableInfo.setDataMapSchemaList( fromExternalToWrapperChildSchemaList(externalTableInfo.getDataMapSchemas())); } wrapperTableInfo.setTablePath(tablePath); return wrapperTableInfo; }
public static CarbonTable buildTable( String tablePath, String tableName, Configuration configuration) throws IOException { TableInfo tableInfoInfer = CarbonUtil.buildDummyTableInfo(tablePath, "null", "null"); CarbonFile carbonFile = getFirstIndexFile(FileFactory.getCarbonFile(tablePath, configuration)); if (carbonFile == null) { throw new RuntimeException("Carbon index file not exists."); } org.apache.carbondata.format.TableInfo tableInfo = CarbonUtil .inferSchemaFromIndexFile(carbonFile.getPath(), tableName); List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>(); for (org.apache.carbondata.format.ColumnSchema thriftColumnSchema : tableInfo .getFact_table().getTable_columns()) { ColumnSchema columnSchema = thriftColumnSchemaToWrapperColumnSchema(thriftColumnSchema); if (columnSchema.getColumnReferenceId() == null) { columnSchema.setColumnReferenceId(columnSchema.getColumnUniqueId()); } columnSchemaList.add(columnSchema); } tableInfoInfer.getFactTable().setListOfColumns(columnSchemaList); return CarbonTable.buildFromTableInfo(tableInfoInfer); }
org.apache.carbondata.format.SchemaEvolutionEntry schemaEvolutionEntry = new org.apache.carbondata.format.SchemaEvolutionEntry(tableInfo.getLastUpdatedTime()); thriftTableInfo.getFact_table().getSchema_evolution().getSchema_evolution_history() .add(schemaEvolutionEntry);