use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class CarbonMetadataTest method getColumnarDimensionColumn.
private static ColumnSchema getColumnarDimensionColumn() {
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(true);
dimColumn.setColumnName("IMEI");
dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
dimColumn.setDataType(DataType.STRING);
dimColumn.setDimensionColumn(true);
List<Encoding> encodeList = new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
encodeList.add(Encoding.DICTIONARY);
dimColumn.setEncodingList(encodeList);
dimColumn.setNumberOfChild(0);
return dimColumn;
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalTableSchema.
@Test
public void testFromWrapperToExternalTableSchema() {
TableSchema wrapperTableSchema = new TableSchema();
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
return encodings;
}
@Mock
public int getSchemaOrdinal() {
return 1;
}
@Mock
public DataType getDataType() {
return DataType.BOOLEAN;
}
@Mock
public String getColumnName() {
return "columnName";
}
@Mock
public String getColumnUniqueId() {
return "1";
}
@Mock
public boolean isColumnar() {
return true;
}
@Mock
public boolean isDimensionColumn() {
return true;
}
@Mock
public int getColumnGroupId() {
return 1;
}
@Mock
public int getScale() {
return 1;
}
@Mock
public int getPrecision() {
return 1;
}
@Mock
public int getNumberOfChild() {
return 1;
}
@Mock
public byte[] getDefaultValue() {
return new byte[] { 1, 2 };
}
@Mock
public Map<String, String> getColumnProperties() {
return columnPropertyMap;
}
@Mock
public boolean isInvisible() {
return true;
}
@Mock
public String getColumnReferenceId() {
return "1";
}
};
new MockUp<SchemaEvolutionEntry>() {
@Mock
public List<ColumnSchema> getAdded() {
return columnSchemas;
}
@Mock
public List<ColumnSchema> getRemoved() {
return columnSchemas;
}
};
final SchemaEvolution schemaEvolution = new SchemaEvolution();
final Map mapTableProperties = new HashMap<String, String>();
new MockUp<TableSchema>() {
@Mock
public List<ColumnSchema> getListOfColumns() {
return columnSchemas;
}
@Mock
public SchemaEvolution getSchemaEvalution() {
return schemaEvolution;
}
@Mock
public String getTableId() {
return "tableId";
}
@Mock
public Map<String, String> getTableProperties() {
return mapTableProperties;
}
};
org.apache.carbondata.format.TableSchema expectedResult = new org.apache.carbondata.format.TableSchema("tableId", thriftColumnSchemas, schemaEvol);
org.apache.carbondata.format.TableSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalTableSchema(wrapperTableSchema);
assertEquals(expectedResult, actualResult);
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class CarbonTableWithComplexTypesTest method getColumnarDimensionColumn.
private List<ColumnSchema> getColumnarDimensionColumn() {
List<ColumnSchema> cols = new ArrayList<ColumnSchema>();
ColumnSchema dimColumn = new ColumnSchema();
dimColumn.setColumnar(true);
dimColumn.setColumnName("IMEI");
dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
dimColumn.setDataType(DataType.STRING);
dimColumn.setDimensionColumn(true);
List<Encoding> encodeList = new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
encodeList.add(Encoding.DICTIONARY);
dimColumn.setEncodingList(encodeList);
dimColumn.setNumberOfChild(0);
cols.add(dimColumn);
ColumnSchema structColumn = new ColumnSchema();
structColumn.setColumnar(true);
structColumn.setColumnName("mobile");
structColumn.setColumnUniqueId(UUID.randomUUID().toString());
structColumn.setDataType(DataType.STRUCT);
structColumn.setDimensionColumn(true);
structColumn.setEncodingList(encodeList);
structColumn.setNumberOfChild(2);
cols.add(structColumn);
ColumnSchema primitiveColumn = new ColumnSchema();
primitiveColumn.setColumnar(true);
primitiveColumn.setColumnName("mobile.stdcode");
primitiveColumn.setColumnUniqueId(UUID.randomUUID().toString());
primitiveColumn.setDataType(DataType.STRING);
primitiveColumn.setDimensionColumn(true);
primitiveColumn.setEncodingList(encodeList);
primitiveColumn.setNumberOfChild(0);
cols.add(primitiveColumn);
ColumnSchema arrayColumn = new ColumnSchema();
arrayColumn.setColumnar(true);
arrayColumn.setColumnName("mobile.val");
arrayColumn.setColumnUniqueId(UUID.randomUUID().toString());
arrayColumn.setDataType(DataType.ARRAY);
arrayColumn.setDimensionColumn(true);
arrayColumn.setEncodingList(encodeList);
arrayColumn.setNumberOfChild(1);
cols.add(arrayColumn);
ColumnSchema primitiveColumn1 = new ColumnSchema();
primitiveColumn1.setColumnar(true);
primitiveColumn1.setColumnName("mobile.val.phoneno");
primitiveColumn1.setColumnUniqueId(UUID.randomUUID().toString());
primitiveColumn1.setDataType(DataType.STRING);
primitiveColumn1.setDimensionColumn(true);
primitiveColumn1.setEncodingList(encodeList);
primitiveColumn1.setNumberOfChild(0);
cols.add(primitiveColumn1);
return cols;
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalTableInfo.
@Test
public void testFromWrapperToExternalTableInfo() {
TableInfo wrapperTableInfo = new TableInfo();
String dbName = "dbName";
String tableName = "TableName";
final TableSchema wrapperTableSchema = new TableSchema();
final List<TableSchema> tableSchemas = new ArrayList<>();
tableSchemas.add(wrapperTableSchema);
new MockUp<SchemaEvolutionEntry>() {
@Mock
public List<ColumnSchema> getAdded() {
return columnSchemas;
}
@Mock
public List<ColumnSchema> getRemoved() {
return columnSchemas;
}
};
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
return encodings;
}
@Mock
public int getSchemaOrdinal() {
return 1;
}
@Mock
public DataType getDataType() {
return DataType.BOOLEAN;
}
@Mock
public String getColumnName() {
return "columnName";
}
@Mock
public String getColumnUniqueId() {
return "1";
}
@Mock
public boolean isColumnar() {
return true;
}
@Mock
public boolean isDimensionColumn() {
return true;
}
@Mock
public int getColumnGroupId() {
return 1;
}
@Mock
public int getScale() {
return 1;
}
@Mock
public int getPrecision() {
return 1;
}
@Mock
public int getNumberOfChild() {
return 1;
}
@Mock
public byte[] getDefaultValue() {
return new byte[] { 1, 2 };
}
@Mock
public Map<String, String> getColumnProperties() {
return columnPropertyMap;
}
@Mock
public boolean isInvisible() {
return true;
}
@Mock
public String getColumnReferenceId() {
return "1";
}
};
new MockUp<TableInfo>() {
@Mock
public TableSchema getFactTable() {
return wrapperTableSchema;
}
@Mock
public List<TableSchema> getAggregateTableList() {
return tableSchemas;
}
};
new MockUp<TableSchema>() {
@Mock
public List<ColumnSchema> getListOfColumns() {
return columnSchemas;
}
final SchemaEvolution schemaEvolution = new SchemaEvolution();
final Map mapTableProperties = new HashMap<String, String>();
@Mock
public SchemaEvolution getSchemaEvalution() {
return schemaEvolution;
}
@Mock
public String getTableId() {
return "tableId";
}
@Mock
public Map<String, String> getTableProperties() {
return mapTableProperties;
}
};
org.apache.carbondata.format.TableSchema thriftFactTable = new org.apache.carbondata.format.TableSchema("tableId", thriftColumnSchemas, schemaEvol);
List<org.apache.carbondata.format.TableSchema> thriftAggTables = new ArrayList<>();
thriftAggTables.add(thriftFactTable);
org.apache.carbondata.format.TableInfo actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalTableInfo(wrapperTableInfo, dbName, tableName);
org.apache.carbondata.format.TableInfo expectedResult = new org.apache.carbondata.format.TableInfo(thriftFactTable, thriftAggTables);
assertEquals(expectedResult, actualResult);
}
use of org.apache.carbondata.core.metadata.encoder.Encoding in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalSchemaEvolution.
@Test
public void testFromWrapperToExternalSchemaEvolution() {
SchemaEvolution schemaEvolution = new SchemaEvolution();
new MockUp<SchemaEvolutionEntry>() {
@Mock
public List<ColumnSchema> getAdded() {
return columnSchemas;
}
@Mock
public List<ColumnSchema> getRemoved() {
return columnSchemas;
}
};
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
return encodings;
}
@Mock
public int getSchemaOrdinal() {
return 1;
}
@Mock
public DataType getDataType() {
return DataType.BOOLEAN;
}
@Mock
public String getColumnName() {
return "columnName";
}
@Mock
public String getColumnUniqueId() {
return "1";
}
@Mock
public boolean isColumnar() {
return true;
}
@Mock
public boolean isDimensionColumn() {
return true;
}
@Mock
public int getColumnGroupId() {
return 1;
}
@Mock
public int getScale() {
return 1;
}
@Mock
public int getPrecision() {
return 1;
}
@Mock
public int getNumberOfChild() {
return 1;
}
@Mock
public byte[] getDefaultValue() {
return new byte[] { 1, 2 };
}
@Mock
public Map<String, String> getColumnProperties() {
return columnPropertyMap;
}
@Mock
public boolean isInvisible() {
return true;
}
@Mock
public String getColumnReferenceId() {
return "1";
}
};
List<org.apache.carbondata.format.SchemaEvolutionEntry> thriftSchemaEvolutionEntries = new ArrayList<>();
thriftSchemaEvolutionEntries.add(schemaEvolEntry);
org.apache.carbondata.format.SchemaEvolution actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalSchemaEvolution(schemaEvolution);
org.apache.carbondata.format.SchemaEvolution expectedResult = new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
assertEquals(expectedResult, actualResult);
}
Aggregations