public static TableInfo convertGsonToTableInfo(Map<String, String> properties) { String partsNo = properties.get("carbonSchemaPartsNo"); if (partsNo == null) { return null; } int no = Integer.parseInt(partsNo); StringBuilder builder = new StringBuilder(); for (int i = 0; i < no; i++) { String part = properties.get("carbonSchema" + i); if (part == null) { throw new RuntimeException("Some thing wrong in getting schema from hive metastore"); } builder.append(part); } // Datatype GSON adapter is added to support backward compatibility for tableInfo // deserialization GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(DataType.class, new DataTypeAdapter()); Gson gson = gsonBuilder.create(); TableInfo tableInfo = gson.fromJson(builder.toString(), TableInfo.class); // The tableInfo is deserialized from GSON string, need to update the scale and // precision if there are any decimal field, because DecimalType is added in Carbon 1.3, // If it is not updated, read compactibility will be break for table generated before Carbon 1.3 updateDecimalType(tableInfo); return tableInfo; }