KEMBAR78
ResultSet `getXXX` returns default value instead of `null` for nullable fields · Issue #3648 · googleapis/java-bigquery · GitHub
Skip to content

ResultSet getXXX returns default value instead of null for nullable fields #3648

@o-shevchenko

Description

@o-shevchenko

ResultSet getXXX returns default value instead of null for nullable fields.

BigQueryResultImpl implementation of getBoolean, getDouble, getLong should return null the same as others methods

Image

Schema
Image

Data (See row 4)

Image
private fun ResultSet.getFieldValue(field: Field): Any? {
    val fieldName = field.name
    return  when (field.type.standardType) {
            StandardSQLTypeName.BOOL -> getBoolean(fieldName)
            StandardSQLTypeName.INT64 -> getLong(fieldName)
            StandardSQLTypeName.FLOAT64 -> getDouble(fieldName)
            StandardSQLTypeName.NUMERIC, StandardSQLTypeName.BIGNUMERIC -> getBigDecimal(fieldName)
            StandardSQLTypeName.STRING -> getString(fieldName)
            StandardSQLTypeName.BYTES -> getBytes(fieldName)
            StandardSQLTypeName.TIMESTAMP -> getTimestamp(fieldName)?.toInstant()
            StandardSQLTypeName.DATE -> getDate(fieldName)?.toLocalDate()?.atStartOfDay()?.toInstant(ZoneOffset.UTC)
            StandardSQLTypeName.GEOGRAPHY -> getString(fieldName)?.toByteArray(StandardCharsets.UTF_8)
            StandardSQLTypeName.JSON -> getString(fieldName)
            StandardSQLTypeName.INTERVAL -> getObject(fieldName)
            StandardSQLTypeName.RANGE -> getObject(fieldName)
            else -> getObject(fieldName)
        }
}

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/java-bigquery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions