xubo245 commented on a change in pull request #3301: [CARBONDATA-3446] Support read schema of complex data type from carbon file folder path
URL:
https://github.com/apache/carbondata/pull/3301#discussion_r403982893
##########
File path: store/sdk/src/test/java/org/apache/carbondata/sdk/file/CSVCarbonWriterTest.java
##########
@@ -580,6 +578,91 @@ public void testWritingAndReadingStructOfFloat() throws IOException {
}
}
+ @Test
+ public void testWritingAndReadingArrayStruct() throws IOException {
+ String path = "./testWriteFilesArrayStruct";
+ FileUtils.deleteDirectory(new File(path));
+
+ Field[] fields = new Field[4];
+ fields[0] = new Field("id", DataTypes.STRING);
+ fields[1] = new Field("source", DataTypes.STRING);
+ fields[2] = new Field("usage", DataTypes.STRING);
+
+ List<StructField> structFieldsList = new ArrayList<>();
+ structFieldsList.add(new StructField("name", DataTypes.STRING));
+ structFieldsList.add(new StructField("type", DataTypes.STRING));
+ structFieldsList.add(new StructField("creation-time", DataTypes.STRING));
+ structFieldsList.add(new StructField("property", DataTypes.STRING));
+
+
+ StructField structTypeByList = new StructField("annotation", DataTypes.createStructType(structFieldsList));
+
+ List<StructField> list = new ArrayList<>();
+ list.add(structTypeByList);
+
+ Field arrayType = new Field("annotations", "array", list);
+ fields[3] = arrayType;
+ try {
+ CarbonWriterBuilder builder = CarbonWriter.builder().taskNo(5).outputPath(path);
+ CarbonWriter writer = builder.withCsvInput(new Schema(fields)).writtenBy("CSVCarbonWriterTest").build();
+ for (int i = 0; i < 15; i++) {
+ String[] row = new String[]{
+ "robot" + (i % 10),
+ String.valueOf(i),
+ String.valueOf(i + "." + i),
+ "sunflowers" + (i % 10) + "\002" + "modelarts/image_classification" + "\002" + "2019-03-30 17:22:31" + "\002" + "{\"@modelarts:start_index\":0,\"@modelarts:end_index\":5}"
+ + "\001" +
+ "roses" + (i % 10) + "\002" + "modelarts/image_classification" + "\002" + "2019-03-30 17:22:32" + "\002" + "{\"@modelarts:start_index\":0,\"@modelarts:end_index\":5}"};
+ writer.write(row);
+ }
+ writer.close();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+
Review comment:
done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[hidden email]
With regards,
Apache Git Services