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

    https://github.com/apache/carbondata/pull/2338#discussion_r191097577
  
    --- Diff: 
store/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonReaderBuilder.java 
---
    @@ -152,9 +179,10 @@ public CarbonReaderBuilder setEndPoint(String value) {
         if (filterExpression != null) {
           format.setFilterPredicates(job.getConfiguration(), filterExpression);
         }
    -    if (projectionColumns != null) {
    -      format.setColumnProjection(job.getConfiguration(), new 
CarbonProjection(projectionColumns));
    +    if (projectionColumns == null) {
    --- End diff --
    
    If changed like you said, it will not support this build method :
    
        CarbonReader reader = CarbonReader
            .builder(path, "_temp")
            .build();
    
    Test case:
    
      @Test
      public void testReadFilesWithDefaultProjection() throws IOException, 
InterruptedException {
        String path = "./testWriteFiles";
        FileUtils.deleteDirectory(new File(path));
    
        Field[] fields = new Field[2];
        fields[0] = new Field("name", DataTypes.STRING);
        fields[1] = new Field("age", DataTypes.INT);
    
        TestUtil.writeFilesAndVerify(new Schema(fields), path, true);
    
        CarbonReader reader = CarbonReader
            .builder(path, "_temp")
            .build();
    
        // expected output after sorting
        String[] name = new String[100];
        int[] age = new int[100];
        for (int i = 0; i < 100; i++) {
          name[i] = "robot" + (i / 10);
          age[i] = (i % 10) * 10 + i / 10;
        }
        // Default sort column is applied for dimensions. So, need  to validate 
accordingly
    
        int i = 0;
        while (reader.hasNext()) {
          Object[] row = (Object[]) reader.readNextRow();
          // Default sort column is applied for dimensions. So, need  to 
validate accordingly
          Assert.assertEquals(name[i], row[0]);
          Assert.assertEquals(age[i], row[1]);
          i++;
        }
        Assert.assertEquals(i, 100);
      }


---

Reply via email to