Skip to content

Commit

Permalink
branch-3.0: [fix](export) fix error in show export outfile info column
Browse files Browse the repository at this point in the history
…#46850 (#46953)

Cherry-picked from #46850

Co-authored-by: Mingyu Chen (Rayner) <[email protected]>
  • Loading branch information
github-actions[bot] and morningman authored Jan 15, 2025
1 parent c84c0a8 commit 15e6ba5
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private OutfileInfo getOutFileInfo(Map<String, String> resultAttachedInfo) {
OutfileInfo outfileInfo = new OutfileInfo();
outfileInfo.setFileNumber(resultAttachedInfo.get(OutFileClause.FILE_NUMBER));
outfileInfo.setTotalRows(resultAttachedInfo.get(OutFileClause.TOTAL_ROWS));
outfileInfo.setFileSize(resultAttachedInfo.get(OutFileClause.FILE_SIZE) + "bytes");
outfileInfo.setFileSize(resultAttachedInfo.get(OutFileClause.FILE_SIZE));
outfileInfo.setUrl(resultAttachedInfo.get(OutFileClause.URL));
return outfileInfo;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.load;

import org.apache.doris.persist.gson.GsonUtils;

import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

public class ExportOutfileInfoTest {

@Test
public void testOutfileInfo() throws Exception {
// outfileInfoList1
OutfileInfo outfileInfo1 = new OutfileInfo();
outfileInfo1.setFileNumber("2");
outfileInfo1.setTotalRows("1234");
outfileInfo1.setFileSize("10240");
outfileInfo1.setUrl("file:///172.20.32.136/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*");

OutfileInfo outfileInfo2 = new OutfileInfo();
outfileInfo2.setFileNumber("2");
outfileInfo2.setTotalRows("1235");
outfileInfo2.setFileSize("10250");
outfileInfo2.setUrl("file:///172.20.32.136/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*");

List<OutfileInfo> outfileInfoList1 = Lists.newArrayList();
outfileInfoList1.add(outfileInfo1);
outfileInfoList1.add(outfileInfo2);

// outfileInfoList2
OutfileInfo outfileInfo3 = new OutfileInfo();
outfileInfo3.setFileNumber("3");
outfileInfo3.setTotalRows("2345");
outfileInfo3.setFileSize("20260");
outfileInfo3.setUrl("file:///172.20.32.137/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*");

OutfileInfo outfileInfo4 = new OutfileInfo();
outfileInfo4.setFileNumber("3");
outfileInfo4.setTotalRows("2346");
outfileInfo4.setFileSize("20270");
outfileInfo4.setUrl("file:///172.20.32.137/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*");

List<OutfileInfo> outfileInfoList2 = Lists.newArrayList();
outfileInfoList2.add(outfileInfo3);
outfileInfoList2.add(outfileInfo4);

List<List<OutfileInfo>> allOutfileInfo = Lists.newArrayList();
allOutfileInfo.add(outfileInfoList1);
allOutfileInfo.add(outfileInfoList2);

String showInfo = GsonUtils.GSON.toJson(allOutfileInfo);
System.out.println(showInfo);
Assert.assertEquals(
"[[{\"fileNumber\":\"2\",\"totalRows\":\"1234\",\"fileSize\":\"10240\","
+ "\"url\":\"file:///172.20.32.136/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*\"},"
+ "{\"fileNumber\":\"2\",\"totalRows\":\"1235\",\"fileSize\":\"10250\","
+ "\"url\":\"file:///172.20.32.136/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*\"}],"
+ "[{\"fileNumber\":\"3\",\"totalRows\":\"2345\",\"fileSize\":\"20260\","
+ "\"url\":\"file:///172.20.32.137/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*\"},"
+ "{\"fileNumber\":\"3\",\"totalRows\":\"2346\",\"fileSize\":\"20270\","
+ "\"url\":\"file:///172.20.32.137/path/to/result2_c6df5f01bd664dde-a2168b019b6c2b3f_*\"}]]",
showInfo);
}

}
8 changes: 4 additions & 4 deletions regression-test/suites/export_p0/test_with_bom.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ suite("test_with_bom", "p0") {
"""

// check outfile bytes
check_bytes("145bytes", label)
check_bytes("145", label)
} finally {
}

Expand Down Expand Up @@ -165,7 +165,7 @@ suite("test_with_bom", "p0") {
"""

// check outfile bytes
check_bytes("148bytes", label)
check_bytes("148", label)
} finally {
}

Expand Down Expand Up @@ -204,7 +204,7 @@ suite("test_with_bom", "p0") {
"""

// check outfile bytes
check_bytes("161bytes", label)
check_bytes("161", label)
} finally {
}

Expand Down Expand Up @@ -243,7 +243,7 @@ suite("test_with_bom", "p0") {
"""

// check outfile bytes
check_bytes("172bytes", label)
check_bytes("172", label)
} finally {
}
}

0 comments on commit 15e6ba5

Please sign in to comment.