Search in sources :

Example 1 with DataMapSchema

use of org.apache.carbondata.format.DataMapSchema 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 DataTypes.STRING;
        }

        @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";
        }

        @Mock
        public String getAggFunction() {
            return "";
        }
    };
    new MockUp<TableInfo>() {

        @Mock
        public TableSchema getFactTable() {
            return wrapperTableSchema;
        }
    };
    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);
    org.apache.carbondata.format.TableInfo actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalTableInfo(wrapperTableInfo, dbName, tableName);
    org.apache.carbondata.format.TableInfo expectedResult = new org.apache.carbondata.format.TableInfo(thriftFactTable, new ArrayList<org.apache.carbondata.format.TableSchema>());
    expectedResult.setDataMapSchemas(new ArrayList<DataMapSchema>());
    assertEquals(expectedResult, actualResult);
}
Also used : TableSchema(org.apache.carbondata.core.metadata.schema.table.TableSchema) ArrayList(java.util.ArrayList) MockUp(mockit.MockUp) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) SchemaEvolution(org.apache.carbondata.core.metadata.schema.SchemaEvolution) DataMapSchema(org.apache.carbondata.format.DataMapSchema) TableInfo(org.apache.carbondata.core.metadata.schema.table.TableInfo) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MockUp (mockit.MockUp)1 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)1 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)1 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)1 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)1 ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)1 DataMapSchema (org.apache.carbondata.format.DataMapSchema)1 Test (org.junit.Test)1