Search in sources :

Example 36 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForArrayDatatype.

@Test
public void testFromWrapperToExternalColumnSchemaForArrayDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.ARRAY, "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.createDefaultArrayType();
        }

        @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);
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) Test(org.junit.Test)

Example 37 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromWrapperToExternalColumnSchemaForBooleanDataType.

@Test
public void testFromWrapperToExternalColumnSchemaForBooleanDataType() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.BOOLEAN, "columnName", "1", true, encoders, true);
    thriftColumnSchema.setSchemaOrdinal(1);
    thriftColumnSchema.setAggregate_function("");
    ColumnSchema wrapperColumnSchema = new ColumnSchema();
    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";
        }

        @Mock
        public String getAggFunction() {
            return "";
        }
    };
    org.apache.carbondata.format.ColumnSchema actualResult = thriftWrapperSchemaConverter.fromWrapperToExternalColumnSchema(wrapperColumnSchema);
    assertEquals(thriftColumnSchema, actualResult);
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) MockUp(mockit.MockUp) Encoding(org.apache.carbondata.core.metadata.encoder.Encoding) Test(org.junit.Test)

Example 38 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperSchemaEvolutionEntry.

@Test
public void testFromExternalToWrapperSchemaEvolutionEntry() {
    long time = 1112745600000L;
    ColumnSchema wrapperColumnSchema = new ColumnSchema();
    wrapperColumnSchema.setColumnUniqueId("1");
    wrapperColumnSchema.setColumnName("columnName");
    wrapperColumnSchema.setColumnar(true);
    wrapperColumnSchema.setDataType(DataTypes.STRING);
    wrapperColumnSchema.setDimensionColumn(true);
    wrapperColumnSchema.setEncodingList(encodings);
    wrapperColumnSchema.setNumberOfChild(1);
    wrapperColumnSchema.setColumnGroup(1);
    wrapperColumnSchema.setDefaultValue(new byte[] { 1, 2 });
    wrapperColumnSchema.setColumnProperties(columnPropertyMap);
    wrapperColumnSchema.setInvisible(true);
    wrapperColumnSchema.setColumnReferenceId("1");
    List<ColumnSchema> wrapperAddedColumns = new ArrayList<ColumnSchema>();
    wrapperAddedColumns.add(wrapperColumnSchema);
    SchemaEvolutionEntry wrapperSchemaEvolutionEntry = new SchemaEvolutionEntry();
    List<ColumnSchema> wrapperRemovedColumns = new ArrayList<ColumnSchema>();
    wrapperRemovedColumns.add(wrapperColumnSchema);
    wrapperSchemaEvolutionEntry.setTimeStamp(time);
    wrapperSchemaEvolutionEntry.setAdded(wrapperAddedColumns);
    wrapperSchemaEvolutionEntry.setRemoved(wrapperRemovedColumns);
    SchemaEvolutionEntry actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperSchemaEvolutionEntry(schemaEvolEntry);
    assertEquals(wrapperSchemaEvolutionEntry.getAdded().get(0), actualResult.getAdded().get(0));
}
Also used : SchemaEvolutionEntry(org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry) ArrayList(java.util.ArrayList) ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 39 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForDoubleDatatype.

@Test
public void testFromExternalToWrapperColumnSchemaForDoubleDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.DOUBLE, "columnName", "1", true, encoders, true);
    ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
    Boolean expectedResult = true;
    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Example 40 with ColumnSchema

use of org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema in project carbondata by apache.

the class ThriftWrapperSchemaConverterImplTest method testFromExternalToWrapperColumnSchemaForTimestampDatatype.

@Test
public void testFromExternalToWrapperColumnSchemaForTimestampDatatype() {
    org.apache.carbondata.format.ColumnSchema thriftColumnSchema = new org.apache.carbondata.format.ColumnSchema(org.apache.carbondata.format.DataType.TIMESTAMP, "columnName", "1", true, encoders, true);
    ColumnSchema actualResult = thriftWrapperSchemaConverter.fromExternalToWrapperColumnSchema(thriftColumnSchema);
    Boolean expectedResult = true;
    assertEquals(expectedResult, actualResult.hasEncoding(encodings.get(0)));
}
Also used : ColumnSchema(org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema) Test(org.junit.Test)

Aggregations

ColumnSchema (org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema)164 ArrayList (java.util.ArrayList)80 Test (org.junit.Test)63 Encoding (org.apache.carbondata.core.metadata.encoder.Encoding)61 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)33 MockUp (mockit.MockUp)29 TableSchema (org.apache.carbondata.core.metadata.schema.table.TableSchema)14 DataFileFooter (org.apache.carbondata.core.metadata.blocklet.DataFileFooter)13 HashMap (java.util.HashMap)12 SchemaEvolutionEntry (org.apache.carbondata.core.metadata.schema.SchemaEvolutionEntry)11 TableInfo (org.apache.carbondata.core.metadata.schema.table.TableInfo)10 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)10 SchemaEvolution (org.apache.carbondata.core.metadata.schema.SchemaEvolution)9 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)8 CarbonTable (org.apache.carbondata.core.metadata.schema.table.CarbonTable)8 Map (java.util.Map)7 SegmentInfo (org.apache.carbondata.core.metadata.blocklet.SegmentInfo)7 BlockletInfo (org.apache.carbondata.core.metadata.blocklet.BlockletInfo)6 BlockletIndex (org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex)6 ThriftWrapperSchemaConverterImpl (org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl)6