Skip to content

duckdb_from_timestamp throws for infinity and -infinity #10138

@Giorgi

Description

@Giorgi

What happens?

When trying to read infinity and -infinity timestamps with C Api, duckdb_from_timestamp throws an exception

To Reproduce

    duckdb_database db;
    duckdb_connection con;
    duckdb_state state;
    duckdb_result result;

    if (duckdb_open(NULL, &db) == DuckDBError) {
        // handle error
    }
    if (duckdb_connect(db, &con) == DuckDBError) {
        // handle error
    }

    state = duckdb_query(con, "SELECT timestamp_array FROM test_all_types()", &result);
    duckdb_data_chunk chunk = duckdb_result_get_chunk(result, 0);
    idx_t row_count = duckdb_data_chunk_get_size(chunk);
    duckdb_vector vector = duckdb_data_chunk_get_vector(chunk, 0);
    duckdb_vector childVector= duckdb_list_vector_get_child(vector);

    duckdb_timestamp* timeData = (duckdb_timestamp *)duckdb_vector_get_data(childVector);

    //Works fine for the first element which is 1970, 1, 1 but throws for second and third
    duckdb_timestamp_struct timestampStruct = duckdb_from_timestamp(timeData[0]);
    timestampStruct = duckdb_from_timestamp(timeData[1]);

// cleanup
    duckdb_destroy_data_chunk(&chunk);
    duckdb_destroy_result(&result);
    duckdb_disconnect(&con);
    duckdb_close(&db);

image
image

OS:

Windows 11

DuckDB Version:

0.9.2

DuckDB Client:

C

Full Name:

Giorgi Dalakishvili

Affiliation:

Space International

Have you tried this on the latest main branch?

I have tested with a release build (and could not test with a main build)

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions