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

Fixed Energy.toString and mandatory parquet value omission #244

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public value class Energy private constructor(
override fun toString(): String = fmtValue()

override fun fmtValue(fmt: String): String =
if (value >= 1000.0) {
if (value <= 1000.0) {
"${toJoule().fmt(fmt)} Joule"
} else {
"${toKJoule().fmt(fmt)} KJoule"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.FLOAT
import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT32
import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64
import org.apache.parquet.schema.Type
import org.apache.parquet.schema.Types
import org.opendc.trace.util.parquet.ParquetDataWriter
import java.io.File
Expand Down Expand Up @@ -122,7 +123,13 @@
val valueToAdd: Any =
column.getValue(
record,
) ?: return@forEachIndexed // Maybe add explicit check for optional fields
) ?: let {

Check warning on line 126 in opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt

View check run for this annotation

Codecov / codecov/patch

opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt#L126

Added line #L126 was not covered by tests
if (column.field.isRepetition(Type.Repetition.OPTIONAL)) {
return@forEachIndexed

Check warning on line 128 in opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt

View check run for this annotation

Codecov / codecov/patch

opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt#L128

Added line #L128 was not covered by tests
} else {
throw RuntimeException("trying to insert null value in required column $column")

Check warning on line 130 in opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt

View check run for this annotation

Codecov / codecov/patch

opendc-trace/opendc-trace-parquet/src/main/kotlin/org/opendc/trace/util/parquet/exporter/Exporter.kt#L130

Added line #L130 was not covered by tests
}
}

startField(column.name, idx)
when (column.primitiveTypeName) {
Expand Down
Loading