Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-16161 Fix parquet export NPE #16175

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
krasinski marked this conversation as resolved.
Show resolved Hide resolved
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)

valenad1 marked this conversation as resolved.
Show resolved Hide resolved

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)