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

External tables support for HTTP protocol #942

Merged
merged 41 commits into from
Apr 13, 2023

Conversation

crisismaple
Copy link
Contributor

@crisismaple crisismaple commented Mar 25, 2023

Summary

use mutipart http request to send both external tables and query

Checklist

  • Unit and integration tests covering the common scenarios were added

@jkaflik
Copy link
Contributor

jkaflik commented Mar 27, 2023

Thanks @crisismaple. Let me have a look on this today!

@jkaflik
Copy link
Contributor

jkaflik commented Mar 28, 2023

@crisismaple I didn't manage to review it yesterday. Hopefully, I will have time today.

@crisismaple
Copy link
Contributor Author

@crisismaple I didn't manage to review it yesterday. Hopefully, I will have time today.

Take your time please~

@jkaflik
Copy link
Contributor

jkaflik commented Mar 29, 2023

@crisismaple could you rebase your PR?

@CLAassistant
Copy link

CLAassistant commented Mar 29, 2023

CLA assistant check
All committers have signed the CLA.

@crisismaple
Copy link
Contributor Author

@crisismaple could you rebase your PR?

just updated

@@ -265,7 +267,7 @@ func (h *httpConnect) isBad() bool {
}

func (h *httpConnect) readTimeZone(ctx context.Context) (*time.Location, error) {
rows, err := h.query(ctx, func(*connect, error) {}, "SELECT timezone()")
rows, err := h.query(Context(ctx, ignoreExternalTables()), func(*connect, error) {}, "SELECT timezone()")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's an internal logic for HTTP proto, we should not leak it into Options struct.

Instead, can we reset external in context? Or can we pass implicit bool to query func?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like query is defined in stdConnect interface with a generic signature, modify context from caller side seems a more reasonable way to optimize internal calls for timezone and ping.

conn_http.go Show resolved Hide resolved
conn_http.go Outdated
return req, nil
}

func (h *httpConnect) prepareRequest(ctx context.Context, query string, options *QueryOptions, headers map[string]string) (*http.Request, error) {
if options == nil || options.ignoreExternalTables || len(options.external) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if options == nil || options.ignoreExternalTables || len(options.external) == 0 {
if options == nil || len(options.external) == 0 {

ignoreExternalTables looks redundant in this use case, if we properly pass the context here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just pushed an update to remove ignoreExternalTables in options

conn_http.go Show resolved Hide resolved
@@ -148,6 +148,13 @@ func WithUserLocation(location *time.Location) QueryOption {
}
}

func ignoreExternalTables() QueryOption {
return func(o *QueryOptions) error {
o.external = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

force set external to nil here

Copy link
Contributor

@jkaflik jkaflik left a comment

Choose a reason for hiding this comment

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

Thanks. Staging it to a next release

@jkaflik jkaflik merged commit adc71da into ClickHouse:main Apr 13, 2023
@jkaflik jkaflik changed the title support query with external tables via http connection External tables support for HTTP protocol Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants