Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support read varbinary #76

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

chein-huang
Copy link

Support read trino type "varbinary" as []byte

@cla-bot
Copy link

cla-bot bot commented Apr 13, 2023

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

README.md Outdated
@@ -18,6 +18,7 @@ A [Trino](https://trino.io) client for the [Go](https://golang.org) programming
* `float64`, `sql.NullFloat64`
* `map`, `trino.NullMap`
* `time.Time`, `trino.NullTime`
* `[]byte`, `trino.NullVarbinary`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use Go's data types in the names of these structures, so it would be trino.NullSliceByte.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I change it to NullSliceByte now

@cla-bot
Copy link

cla-bot bot commented Apr 13, 2023

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
Copy link

cla-bot bot commented Apr 13, 2023

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
Copy link

cla-bot bot commented Apr 18, 2023

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

@@ -204,6 +205,8 @@ When passing arguments to queries, the driver supports the following Go data typ
* the result of `trino.TimeTz(hour, minute, second, nanosecond, location)` - passed to Trino as a time with a time zone
* the result of `trino.Timestamp(year, month, day, hour, minute, second, nanosecond)` - passed to Trino as a timestamp without a time zone

We can also implement driver.Valuer interface to return data of types above.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We can also implement driver.Valuer interface to return data of types above.
We can also implement the `driver.Valuer` interface to return data of the types above.

@@ -246,6 +249,7 @@ To read query results containing arrays or maps, pass one of the following struc
* `trino.NullSliceFloat64`
* `trino.NullSliceTime`
* `trino.NullSliceMap`
* `trino.NullSliceByte`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding trino.NullSliceByte here might be misleading, as it's used for VARBINARY. This section is about arrays and maps, so ARRAY(VARBINARY) will use trino.NullSlice2Byte.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add VARBINARY to the list in the beginning of this section, maybe after UUID.

b.Valid = true

var err error
switch v := value.(type) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the server really return []byte here or is it always a base64 encoded string? If the latter, remove the switch statement.

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

Successfully merging this pull request may close these issues.

None yet

3 participants