Github user kumarvishal09 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2261#discussion_r186041329
  
    --- Diff: 
store/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonWriterBuilder.java 
---
    @@ -416,16 +411,58 @@ private CarbonTable buildCarbonTable() {
         }
         TableSchema schema = tableSchemaBuilder.build();
         schema.setTableName(tableName);
    -    CarbonTable table = CarbonTable.builder()
    -        .tableName(schema.getTableName())
    -        .databaseName(dbName)
    -        .tablePath(path)
    -        .tableSchema(schema)
    -        .isTransactionalTable(isTransactionalTable)
    -        .build();
    +    CarbonTable table =
    +        
CarbonTable.builder().tableName(schema.getTableName()).databaseName(dbName).tablePath(path)
    +            
.tableSchema(schema).isTransactionalTable(isTransactionalTable).build();
         return table;
       }
     
    +  private void buildTableSchema(Field[] fields, TableSchemaBuilder 
tableSchemaBuilder,
    +      List<String> sortColumnsList, ColumnSchema[] sortColumnsSchemaList) {
    +    for (Field field : fields) {
    +      if (null != field) {
    +        int isSortColumn = sortColumnsList.indexOf(field.getFieldName());
    +        if (isSortColumn > -1) {
    +          // unsupported types for ("array", "struct", "double", "float", 
"decimal")
    +          if (field.getDataType() == DataTypes.DOUBLE || 
field.getDataType() == DataTypes.FLOAT
    +              || DataTypes.isDecimal(field.getDataType()) || DataTypes
    +              .isArrayType(field.getDataType()) || 
DataTypes.isStructType(field.getDataType())) {
    +            throw new RuntimeException(
    +                " sort columns not supported for " + "array, struct, 
double, float, decimal ");
    +          }
    +        }
    +
    +        if (field.getChildren() != null && field.getChildren().size() > 0) 
{
    +          if (field.getDataType().getName().equalsIgnoreCase("ARRAY")) {
    +            // Loop through the inner columns and for a StructData
    +            DataType complexType =
    +                
DataTypes.createArrayType(field.getChildren().get(0).getDataType());
    +            tableSchemaBuilder.addColumn(new 
StructField(field.getFieldName(), complexType), false);
    +          } else if 
(field.getDataType().getName().equalsIgnoreCase("STRUCT")) {
    +            // Loop through the inner columns and for a StructData
    +            List<StructField> structFieldsArray =
    +                new ArrayList<StructField>(field.getChildren().size());
    +            for (StructField childFld : field.getChildren()) {
    +              structFieldsArray
    +                  .add(new StructField(childFld.getFieldName(), 
childFld.getDataType()));
    +            }
    +            DataType complexType = 
DataTypes.createStructType(structFieldsArray);
    +            tableSchemaBuilder.addColumn(new 
StructField(field.getFieldName(), complexType), false);
    +          }
    +        } else {
    +
    --- End diff --
    
    remove empty lines


---

Reply via email to