Skip to content

Date32 return ZonedDateTime rather then LocalDate strings #2448

@jaccozilla

Description

@jaccozilla

Description

Only Date clickhouse types are formatted and returned as local date strings. Date32 is returned as LocalDateTime. See

} else if (value instanceof ZonedDateTime) {
ClickHouseDataType dataType = column.getDataType();
ZonedDateTime zdt = (ZonedDateTime) value;
if (dataType == ClickHouseDataType.Date) {
return zdt.format(com.clickhouse.client.api.DataTypeUtils.DATE_FORMATTER);
}
return value.toString();

The fix for date was added in https://github.com/ClickHouse/clickhouse-java/pull/2062/files, not sure why Date32 was not added

As a user its surprising that Date32 come back as LocalDateTimes. The value returned by clickhouse is only the date, see https://fiddle.clickhouse.com/caed507d-8d72-48c5-92e2-fac7f5dff261

Steps to reproduce

 connection.createStatement().use { stmt -> val query = """ SELECT toDate('1900-01-01') AS Date, toDate32('1900-01-01') AS Date32 """.trimIndent() stmt.executeQuery(query).use { rs -> while (rs.next()) { val date = rs.getString("Date") val date32 = rs.getString("Date32") println("date=$date, date32=$date32") } } } 

prints: date=1970-01-01, date32=1900-01-01T00:00Z[UTC]

Expected Behaviour

Date32 columns are returned as LocalDates. date=1970-01-01, date32=1900-01-01

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions