Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

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

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)
        }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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