trinodb / trino-go-client

Go client for Trino
Apache License 2.0
131 stars 60 forks source link

Parsing of datetime to take UTC if timezone is not provided #119

Open silent-lad opened 3 months ago

silent-lad commented 3 months ago

This is causing problem for us in cases where we have set the trino sql timestamp to be UTC and our database has datetime columns without location information because we assume UTC as default.

In DBs like postgres if not given location is taken as UTC whereas this client parses date to EPOCH with time.Local as the location. WHich gives different result on different machine(cloud/ local laptop)

cla-bot[bot] commented 3 months ago

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] commented 3 months ago

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

silent-lad commented 3 months ago

Have fixed the tests @nineinchnick

nineinchnick commented 3 months ago

I've thought about this, and this is a breaking change for anyone using this data type. What's worse, it's silent, meaning the behavior will just change for anyone not pinned to a specific version of this driver. Even if this change is correct, we should only do this in a v2 version.

If you don't mind, I'd keep this open for a while, hoping we can get more feedback from other people. In the meantime, I'd suggest using a workaround, like you can create a struct implementing sql.Scanner in your application and pass it to Scan() instead of trino.Time.

silent-lad commented 3 months ago

Can we have the default timezone passed with the connection string like we have for custom http client. Something like ->

if tzKey := query.Get("default_tz"); tzKey != "" {
     loc, err := time.LoadLocation(tzKey)
     if err == nil {
          time.Local = loc
     }
}

That way its both configurable and backwards compatible

nineinchnick commented 3 weeks ago

@cla-bot check

cla-bot[bot] commented 3 weeks ago

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] commented 3 weeks ago

The cla-bot has been summoned, and re-checked this pull request!

nineinchnick commented 3 weeks ago

@silent-lad I like your last suggestion, can we get back to this? You haven't signed the CLA yet.

silent-lad commented 3 weeks ago

https://github.com/trinodb/cla/pull/8/files I have a PR for the CLA. Haven't gotten it approved. @nineinchnick

nineinchnick commented 3 weeks ago

PRs are not processed in that repository, you need to send the signed CLA via email.

silent-lad commented 3 weeks ago

can we get back to this?

I will update the PR with changes today.

you need to send the signed CLA via email.

Is the procedure documented somewhere so I can follow?

nineinchnick commented 3 weeks ago

Is the procedure documented somewhere so I can follow?

Yes, please read the cla-bot comments.