Skip to content

Commit

Permalink
GH-16161 Fix parquet export NPE (#16175)
Browse files Browse the repository at this point in the history
  • Loading branch information
krasinski committed May 7, 2024
1 parent e751e35 commit e1ab25a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public void map(Chunk[] cs) {
group = group.append(currColName, cs[j].at8(i));
break;
case (T_STR):
group = group.append(currColName, cs[j].atStr(new BufferedString(), i).toString());
if (cs[j].isNA(i)) {
group = group.append(currColName, "");
} else {
group = group.append(currColName, cs[j].atStr(new BufferedString(), i).toString());
}
break;
case (T_CAT):
if (cs[j].isNA(i)) {
Expand Down
21 changes: 21 additions & 0 deletions h2o-py/tests/testdir_misc/pyunit_export_parquet_npe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import sys
import tempfile

sys.path.insert(1, "../../../")
import h2o
from tests import pyunit_utils


def test_export_file_npe_gh_16161():
with tempfile.TemporaryDirectory() as dir:
df = h2o.create_frame(rows=100, cols=10, string_fraction=0.1, seed=5, seed_for_column_types=25)
h2o.export_file(df, path=dir, format="parquet", write_checksum=False)


if __name__ == "__main__":
pyunit_utils.standalone_test(test_export_file_npe_gh_16161)
else:
test_export_file_npe_gh_16161()



19 changes: 19 additions & 0 deletions h2o-r/tests/testdir_parser/runit_GH_16161_parquet_npe.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
setwd(normalizePath(dirname(R.utils::commandArgs(asValues = TRUE)$"f")))
source("../../scripts/h2o-r-test-setup.R")

test.parseParquetString<- function() {
df <- h2o.createFrame(rows = 100,
cols = 10,
string_fraction = 0.1, # create one string column
seed = 5,
seed_for_column_types = 25)
target <- file.path(sandbox(), "createdFrame.parquet")
h2o.exportFile(data = df,
path = target,
format = "parquet",
write_checksum = FALSE)
df2 <- h2o.importFile(target)
compareFrames(df, df2)
}

doTest("Test Parquet String export error.", test.parseParquetString)

0 comments on commit e1ab25a

Please sign in to comment.