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

implement ExecContext #16

Merged
merged 4 commits into from
Jan 15, 2021
Merged

implement ExecContext #16

merged 4 commits into from
Jan 15, 2021

Conversation

nineinchnick
Copy link
Member

This PR implements driver.ExecContext() to be able to run queries like USE <catalog>.<schema> and possibly other DDL/DML queries. While this is rarely used in application code, I noticed this when trying to use the usql CLI client.

I also included few minor changes to satisfy golangci-lint linter, like adding comments and removing dead code.

When working on this I was reading https://github.com/prestosql/presto/blob/master/presto-jdbc/src/main/java/io/prestosql/jdbc/PrestoStatement.java as a reference.

@cla-bot
Copy link

cla-bot bot commented Dec 23, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla.

@losipiuk
Copy link
Member

Thanks @nineinchnick!

I also included few minor changes to satisfy golangci-lint linter, like adding comments and removing dead code.

Can you please split PR into multiple commits so logically separate changes are in separate commits?

As for the "adding comments" part. I do not believe we want all of those. I know that some notable golang projects require every public member to be documented. But I strongly believe that it does not improve code quality. Rather does the opposite. We should use common sense and add comments where they are useful.

@cla-bot
Copy link

cla-bot bot commented Dec 23, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla.

@nineinchnick
Copy link
Member Author

Can you please split PR into multiple commits so logically separate changes are in separate commits?

Done!

As for the "adding comments" part. I do not believe we want all of those. I know that some notable golang projects require every public member to be documented. But I strongly believe that it does not improve code quality. Rather does the opposite. We should use common sense and add comments where they are useful.

Fully agree, I tried to make them as relevant as possible.

presto/presto_test.go Outdated Show resolved Hide resolved
presto/presto.go Outdated Show resolved Hide resolved
presto/presto_test.go Outdated Show resolved Hide resolved
presto/presto.go Outdated Show resolved Hide resolved
presto/presto.go Outdated
if catalog != "" {
c.httpHeaders.Set(prestoCatalogHeader, catalog)
}
schema := resp.Header.Get(prestoSetSchemaHeader)
Copy link
Member

Choose a reason for hiding this comment

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

should we handle X-Set-Path here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. It's not set in the initial connection. In what cases the server would send it and expect it to be set in future requests?

Copy link
Member Author

Choose a reason for hiding this comment

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

LMK if you think we should add this for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Actually there are more of those:

https://github.com/trinodb/trino/blob/83bcdffc4c8dd0ce377c5f12609c69b9088ba6a0/presto-client/src/main/java/io/prestosql/client/PrestoHeaders.java#L27-L32

I think we do not have to support all of those initially. But we should at least notice that they are present in the response and return an error to the caller, if we get an unsupported X-Prest-Set-... header. Otherwise we will pretend that we support SET SESSION ... syntax, but we would not send set session properties in followup queries.

Could you please add validation and test coverage?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Added this as a separate commit.

Copy link
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

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

Thanks. Mostly looks good. Some cleanup comments.

And also please capitalize commit messages.

@cla-bot
Copy link

cla-bot bot commented Dec 23, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/prestosql/cla.

@cla-bot
Copy link

cla-bot bot commented Dec 29, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

1 similar comment
@cla-bot
Copy link

cla-bot bot commented Dec 29, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

Copy link
Member

@losipiuk losipiuk left a comment

Choose a reason for hiding this comment

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

Awesome. Minor comments.

trino/trino.go Outdated Show resolved Hide resolved
trino/trino.go Outdated Show resolved Hide resolved
@@ -321,6 +321,23 @@ func TestExec(t *testing.T) {
}
}

func TestUnsupportedHeader(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you also add and integration test calling out to

  • SET SESSION grouped_execution=true
  • SET ROLE dummy
  • SET PATH dummy
  • RESET SESSION grouped_execution (not sure if this one will work; may not send X-Presto-Clear-Session header if it was not set before, which we cannot do)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Actually only SET PATH failed since there's some client capability negotiation mechanism, this client doesn't report any capabilities and setting PATH is not allowed by default.

trino/trino_test.go Outdated Show resolved Hide resolved
trino/trino_test.go Outdated Show resolved Hide resolved
@cla-bot
Copy link

cla-bot bot commented Dec 31, 2020

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@losipiuk
Copy link
Member

losipiuk commented Jan 4, 2021

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Jan 4, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@cla-bot
Copy link

cla-bot bot commented Jan 4, 2021

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

@losipiuk
Copy link
Member

/cla-bot check

@losipiuk
Copy link
Member

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Jan 12, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@cla-bot
Copy link

cla-bot bot commented Jan 12, 2021

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

@nineinchnick
Copy link
Member Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Jan 15, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please submit the signed CLA to [email protected]. For more information, see https://github.com/trinodb/cla.

@cla-bot
Copy link

cla-bot bot commented Jan 15, 2021

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

@nineinchnick
Copy link
Member Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Jan 15, 2021
@cla-bot
Copy link

cla-bot bot commented Jan 15, 2021

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

@losipiuk
Copy link
Member

Merged, thanks!

@losipiuk losipiuk merged commit c70f249 into trinodb:master Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants