Skip to content

Commit

Permalink
only set precision for decimal columns
Browse files Browse the repository at this point in the history
Signed-off-by: sperlingxx <[email protected]>
  • Loading branch information
sperlingxx committed Feb 14, 2022
1 parent 7f2a16f commit f5dfe4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 6 additions & 3 deletions java/src/main/java/ai/rapids/cudf/ColumnWriterOptions.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021, NVIDIA CORPORATION.
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,9 @@ private ColumnWriterOptions(AbstractStructBuilder builder) {
(ColumnWriterOptions[]) builder.children.toArray(new ColumnWriterOptions[0]);
}

// The sentinel value of unknown precision (default value)
public static int UNKNOWN_PRECISION = -1;

/**
* Constructor used for list
*/
Expand Down Expand Up @@ -103,7 +106,7 @@ protected ColumnWriterOptions withDecimal(String name, int precision,

protected ColumnWriterOptions withTimestamp(String name, boolean isInt96,
boolean isNullable) {
return new ColumnWriterOptions(name, isInt96, 0, isNullable);
return new ColumnWriterOptions(name, isInt96, UNKNOWN_PRECISION, isNullable);
}

/**
Expand Down Expand Up @@ -243,7 +246,7 @@ public ColumnWriterOptions(String columnName, boolean isTimestampTypeInt96,

public ColumnWriterOptions(String columnName, boolean isNullable) {
this.isTimestampTypeInt96 = false;
this.precision = 0;
this.precision = UNKNOWN_PRECISION;
this.isNullable = isNullable;
this.columnName = columnName;
}
Expand Down
11 changes: 8 additions & 3 deletions java/src/main/native/src/TableJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,10 @@ int set_column_metadata(cudf::io::column_in_metadata &column_metadata,
for (int i = 0; i < num_children; i++, write_index++) {
cudf::io::column_in_metadata child;
child.set_name(col_names[read_index])
.set_decimal_precision(precisions[read_index])
.set_nullability(nullability[read_index]);
if (precisions[read_index] > - 1) {
child.set_decimal_precision(precisions[read_index]);
}
if (!is_int96.is_null()) {
child.set_int96_timestamps(is_int96[read_index]);
}
Expand Down Expand Up @@ -717,8 +719,11 @@ void createTableMetaData(JNIEnv *env, jint num_children, jobjectArray &j_col_nam
for (int i = read_index, write_index = 0; i < top_level_children; i++, write_index++) {
metadata.column_metadata[write_index]
.set_name(cpp_names[read_index])
.set_nullability(col_nullability[read_index])
.set_decimal_precision(precisions[read_index]);
.set_nullability(col_nullability[read_index]);
if (precisions[read_index] > - 1) {
metadata.column_metadata[write_index]
.set_decimal_precision(precisions[read_index]);
}
if (!is_int96.is_null()) {
metadata.column_metadata[write_index].set_int96_timestamps(is_int96[read_index]);
}
Expand Down

0 comments on commit f5dfe4f

Please sign in to comment.