use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForDatatypeNullCase.
@Test
public void testFromWrapperToExternalColumnSchemaForDatatypeNullCase() {
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.INT, "columnName", "1", true, encoders, true);
thriftColumnSchema.setSchemaOrdinal(1);
thriftColumnSchema.setAggregate_function("");
new MockUp<ColumnSchema>() {
@Mock
public List<Encoding> getEncodingList() {
return encodings;
}
@Mock
public int getSchemaOrdinal() {
return 1;
}
@Mock
public DataType getDataType() {
return DataTypes.INT;
}
@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";
}
};
ColumnSchema wrapperColumnSchema = new ColumnSchema();
org.apache.carbondata.format.ColumnSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
assertEquals(thriftColumnSchema, actualResult);
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForStructDatatype.
@Test
public void testFromExternalToWrapperColumnSchemaForStructDatatype() {
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRUCT, "columnName", "1", true, encoders, true);
ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
Boolean expectedResult = true;
assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForArrayDatatype.
@Test
public void testFromExternalToWrapperColumnSchemaForArrayDatatype() {
org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.ARRAY, "columnName", "1", true, encoders, true);
ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
Boolean expectedResult = true;
assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema 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 DataTypes.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);
}
use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.
the class ThriftWrapperSchemaConverterImplTest method setUp.
@BeforeClass
public static void setUp() {
thriftWrapperSchemaConverter = new ThriftWrapperSchemaConverterImpl();
schemaEvolEntry = new org.apache.carbondata.format.SchemaEvolutionEntry();
schemaEvolutionEntries = new ArrayList();
schemaEvolutionEntries.add(new SchemaEvolutionEntry());
columnSchemas = new ArrayList();
columnSchemas.add(new ColumnSchema());
encodings = new ArrayList<>();
encodings.add(Encoding.INVERTED_INDEX);
encodings.add(Encoding.DELTA);
encodings.add(Encoding.BIT_PACKED);
encodings.add(Encoding.DICTIONARY);
encodings.add(Encoding.RLE);
encodings.add(Encoding.DIRECT_DICTIONARY);
encoders = new ArrayList<org.apache.carbondata.format.Encoding>();
encoders.add(org.apache.carbondata.format.Encoding.INVERTED_INDEX);
encoders.add(org.apache.carbondata.format.Encoding.DELTA);
encoders.add(org.apache.carbondata.format.Encoding.BIT_PACKED);
encoders.add(org.apache.carbondata.format.Encoding.DICTIONARY);
encoders.add(org.apache.carbondata.format.Encoding.RLE);
encoders.add(org.apache.carbondata.format.Encoding.DIRECT_DICTIONARY);
columnPropertyMap = new HashMap<String, String>();
columnPropertyMap.put("property", "value");
thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.STRING, "columnName", "1", true, encoders, true);
thriftColumnSchema.setSchemaOrdinal(1);
thriftColumnSchema.setAggregate_function("");
thriftColumnSchemas = new ArrayList<org.apache.carbondata.format.ColumnSchema>();
thriftColumnSchemas.add(thriftColumnSchema);
thriftSchemaEvolutionEntries = new ArrayList<>();
thriftSchemaEvolutionEntries.add(schemaEvolEntry);
schemaEvol = new org.apache.carbondata.format.SchemaEvolution(thriftSchemaEvolutionEntries);
new MockUp<SchemaEvolution>() {
@Mock
public List<SchemaEvolutionEntry> getSchemaEvolutionEntryList() {
return schemaEvolutionEntries;
}
};
new MockUp<org.apache.carbondata.format.SchemaEvolutionEntry>() {
@Mock
public org.apache.carbondata.format.SchemaEvolutionEntry setAdded(List<org.apache.carbondata.format.ColumnSchema> added) {
return schemaEvolEntry;
}
@Mock
public org.apache.carbondata.format.SchemaEvolutionEntry setRemoved(List<org.apache.carbondata.format.ColumnSchema> removed) {
return schemaEvolEntry;
}
@Mock
public long getTime_stamp() {
return 1112745600000L;
}
@Mock
public List<org.apache.carbondata.format.ColumnSchema> getAdded() {
return thriftColumnSchemas;
}
@Mock
public List<org.apache.carbondata.format.ColumnSchema> getRemoved() {
return thriftColumnSchemas;
}
};
new MockUp<org.apache.carbondata.format.ColumnSchema>() {
@Mock
public org.apache.carbondata.format.ColumnSchema setColumn_group_id(int column_group_id) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setScale(int scale) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setPrecision(int precision) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setNum_child(int num_child) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setDefault_value(byte[] default_value) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setColumnProperties(Map<String, String> columnProperties) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setInvisible(boolean invisible) {
return thriftColumnSchema;
}
@Mock
public org.apache.carbondata.format.ColumnSchema setColumnReferenceId(String columnReferenceId) {
return thriftColumnSchema;
}
@Mock
public String getColumn_id() {
return "1";
}
@Mock
public String getColumn_name() {
return "columnName";
}
@Mock
public boolean isColumnar() {
return true;
}
@Mock
public boolean isDimension() {
return true;
}
@Mock
public List<org.apache.carbondata.format.Encoding> getEncoders() {
return encoders;
}
@Mock
public int getNum_child() {
return 1;
}
@Mock
public int getPrecision() {
return 1;
}
@Mock
public int getColumn_group_id() {
return 1;
}
@Mock
public int getScale() {
return 1;
}
@Mock
public byte[] getDefault_value() {
return new byte[] { 1, 2 };
}
@Mock
public String getAggregate_function() {
return "";
}
@Mock
public Map<String, String> getColumnProperties() {
return columnPropertyMap;
}
@Mock
public boolean isInvisible() {
return true;
}
@Mock
public String getColumnReferenceId() {
return "1";
}
};
final Map mapTableProperties = new HashMap<String, String>();
tabSchema = new org.apache.carbondata.format.TableSchema();
new MockUp<org.apache.carbondata.format.TableSchema>() {
@Mock
public org.apache.carbondata.format.TableSchema setTableProperties(Map<String, String> tableProperties) {
return tabSchema;
}
@Mock
public String getTable_id() {
return "1";
}
@Mock
public Map<String, String> getTableProperties() {
return mapTableProperties;
}
@Mock
public List<org.apache.carbondata.format.ColumnSchema> getTable_columns() {
return thriftColumnSchemas;
}
@Mock
public org.apache.carbondata.format.SchemaEvolution getSchema_evolution() {
return schemaEvol;
}
};
new MockUp<org.apache.carbondata.format.SchemaEvolution>() {
@Mock
public List<org.apache.carbondata.format.SchemaEvolutionEntry> getSchema_evolution_history() {
return thriftSchemaEvolutionEntries;
}
};
}
Aggregations