Skip to content

Commit e1ab25a

Browse files
authored
h2oaiGH-16161 Fix parquet export NPE (h2oai#16175)
1 parent e751e35 commit e1ab25a

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

h2o-parsers/h2o-parquet-parser/src/main/java/water/parser/parquet/FrameParquetExporter.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ public void map(Chunk[] cs) {
112112
group = group.append(currColName, cs[j].at8(i));
113113
break;
114114
case (T_STR):
115-
group = group.append(currColName, cs[j].atStr(new BufferedString(), i).toString());
115+
if (cs[j].isNA(i)) {
116+
group = group.append(currColName, "");
117+
} else {
118+
group = group.append(currColName, cs[j].atStr(new BufferedString(), i).toString());
119+
}
116120
break;
117121
case (T_CAT):
118122
if (cs[j].isNA(i)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
import tempfile
3+
4+
sys.path.insert(1, "../../../")
5+
import h2o
6+
from tests import pyunit_utils
7+
8+
9+
def test_export_file_npe_gh_16161():
10+
with tempfile.TemporaryDirectory() as dir:
11+
df = h2o.create_frame(rows=100, cols=10, string_fraction=0.1, seed=5, seed_for_column_types=25)
12+
h2o.export_file(df, path=dir, format="parquet", write_checksum=False)
13+
14+
15+
if __name__ == "__main__":
16+
pyunit_utils.standalone_test(test_export_file_npe_gh_16161)
17+
else:
18+
test_export_file_npe_gh_16161()
19+
20+
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
setwd(normalizePath(dirname(R.utils::commandArgs(asValues = TRUE)$"f")))
2+
source("../../scripts/h2o-r-test-setup.R")
3+
4+
test.parseParquetString<- function() {
5+
df <- h2o.createFrame(rows = 100,
6+
cols = 10,
7+
string_fraction = 0.1, # create one string column
8+
seed = 5,
9+
seed_for_column_types = 25)
10+
target <- file.path(sandbox(), "createdFrame.parquet")
11+
h2o.exportFile(data = df,
12+
path = target,
13+
format = "parquet",
14+
write_checksum = FALSE)
15+
df2 <- h2o.importFile(target)
16+
compareFrames(df, df2)
17+
}
18+
19+
doTest("Test Parquet String export error.", test.parseParquetString)

0 commit comments

Comments
 (0)