stiga-huang commented on a change in pull request #1044:
URL: https://github.com/apache/orc/pull/1044#discussion_r809721331
##########
File path: tools/test/TestCSVFileImport.cc
##########
@@ -90,3 +92,36 @@ TEST (TestCSVFileImport, testTimezoneOption) {
EXPECT_EQ("", error);
}
}
+
+TEST (TestCSVFileImport, testLongString) {
+ // create an ORC file from importing the CSV file
+ const std::string pgm1 = findProgram("tools/src/csv-import");
+ const std::string csvFile = "/tmp/test_csv_import_test_long_string.csv";
+ const std::string orcFile = "/tmp/test_csv_import_test_long_string.orc";
+ const std::string schema = "'struct<_a:string,b_:binary,_c:varchar(10)>'";
+ std::string output;
+ std::string error;
+
+ std::ofstream csvFileStream(csvFile, std::ios::binary | std::ios::out |
std::ios::trunc);
+ if(csvFileStream.is_open())
+ {
+ std::string longStr;
+ longStr.resize(4 * 1024 * 1024 + 1, 'x');
+ csvFileStream << "str1," << longStr << ",var1\n";
+ csvFileStream << "str2," << longStr << ",var2\n";
+ csvFileStream.close();
+ }
+
+ EXPECT_EQ(0, runProgram({pgm1, schema, csvFile, orcFile}, output, error));
+ EXPECT_EQ("", error);
+
+ // verify the ORC file content
+ const std::string pgm2 = findProgram("tools/src/orc-contents");
+ std::string option = "--columns=0,2";
+ const std::string expected =
+ "{\"_a\": \"str1\", \"_c\": \"var1\"}\n"
+ "{\"_a\": \"str2\", \"_c\": \"var2\"}\n";
+ EXPECT_EQ(0, runProgram({pgm2, option, orcFile}, output, error));
+ EXPECT_EQ(expected, output);
+ EXPECT_EQ("", error);
Review comment:
Without the fix, the test failed in my env too
```
$ tools/test/tool-test --gtest_filter='*testLongString*'
ORC version: 1.8.0-SNAPSHOT
example dir = --gtest_filter=*testLongString*
build dir = .
Note: Google Test filter = *testLongString*
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from TestCSVFileImport
[ RUN ] TestCSVFileImport.testLongString
/home/quanlong/workspace/orc/tools/test/TestCSVFileImport.cc:113: Failure
Expected: 0
To be equal to: runProgram({pgm1, schema, csvFile, orcFile}, output, error)
Which is: 139
/home/quanlong/workspace/orc/tools/test/TestCSVFileImport.cc:114: Failure
Expected: ""
To be equal to: error
Which is: "Segmentation fault (core dumped)\n"
/home/quanlong/workspace/orc/tools/test/TestCSVFileImport.cc:122: Failure
Expected: 0
To be equal to: runProgram({pgm2, option, orcFile}, output, error)
Which is: 1
/home/quanlong/workspace/orc/tools/test/TestCSVFileImport.cc:123: Failure
Expected: expected
Which is: "{\"_a\": \"str1\", \"_c\": \"var1\"}\n{\"_a\": \"str2\",
\"_c\": \"var2\"}\n"
To be equal to: output
Which is: ""
With diff:
@@ -1,2 +1,1 @@
-{\"_a\": \"str1\", \"_c\": \"var1\"}
-{\"_a\": \"str2\", \"_c\": \"var2\"}\n
+""
/home/quanlong/workspace/orc/tools/test/TestCSVFileImport.cc:124: Failure
Expected: ""
To be equal to: error
Which is: "Caught exception in
/tmp/test_csv_import_test_long_string.orc: File size too small\n"
[ FAILED ] TestCSVFileImport.testLongString (687 ms)
[----------] 1 test from TestCSVFileImport (687 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (687 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestCSVFileImport.testLongString
1 FAILED TEST
```
I'm on Ubuntu 16.04.6. The invalid pointers might have undefined behaviors.
I think it's ok if this catch the bug in some env but not all.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]