Skip to content

[Go] How to use prepared statements with timestamps #39

@si-fernandes

Description

@si-fernandes

Describe the usage question you have. Please include as many useful details as possible.

Hello,

I'm trying to implement a prepared statement that has a timestamp parameter.
I have prepared statements working with strings, but with timestamps I'm getting a schema mismatch error.
I'm using v14.

The query for the prepared statement is SELECT * FROM x where name = $1 AND $2 <= timestamp.
I have no problems with the first parameter.
I'm building the second parameter using the type arrow.FixedWidthTypes.Timestamp_ns.
I've tried passing a time.Time as the value and it failed. Then I tried an arrow.Timestamp but that also failed with the same error.

The error I'm getting is:

Parameter schema does not equal Placeholder schema. (...) 
Received: (...) Field {name: \"$2\", data_type: Timestamp(Nanosecond, Some(\"UTC\")), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }
Expected: (...)Field { name: \"$2\", data_type: Timestamp(Nanosecond, None), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }

I would like to know what's the best way to overcome this timezone difference in the schemas.

Thank you

EDIT:
I have also tried casting the timestamp to timestamptz in the query, but that leads to the mismatch

Received: Timestamp(Nanosecond, Some(\"UTC\"))
Expected: Timestamp(Nanosecond, Some(\"+00:00\"))

Component(s)

Go

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