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

Allow passing X-Trino-Time-Zone header from config #88

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions trino/trino.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const (
trinoClearSessionHeader = trinoHeaderPrefix + `Clear-Session`
trinoSetRoleHeader = trinoHeaderPrefix + `Set-Role`
trinoExtraCredentialHeader = trinoHeaderPrefix + `Extra-Credential`
trinoTimeZoneHeader = trinoHeaderPrefix + `Time-Zone`

trinoProgressCallbackParam = trinoHeaderPrefix + `Progress-Callback`
trinoProgressCallbackPeriodParam = trinoHeaderPrefix + `Progress-Callback-Period`
Expand Down Expand Up @@ -173,6 +174,7 @@ type Config struct {
KerberosConfigPath string // The krb5 config path (optional)
SSLCertPath string // The SSL cert path for TLS verification (optional)
SSLCert string // The SSL cert for TLS verification (optional)
TimeZone string // The timezone for query processing (optional)
}

// FormatDSN returns a DSN string from the configuration.
Expand Down Expand Up @@ -249,6 +251,7 @@ func (c *Config) FormatDSN() (string, error) {
"session_properties": strings.Join(sessionkv, ","),
"extra_credentials": strings.Join(credkv, ","),
"custom_client": c.CustomClientName,
"time_zone": c.TimeZone,
} {
if v != "" {
query[k] = []string{v}
Expand Down Expand Up @@ -362,6 +365,7 @@ func newConn(dsn string) (*Conn, error) {
trinoSchemaHeader: query.Get("schema"),
trinoSessionHeader: query.Get("session_properties"),
trinoExtraCredentialHeader: query.Get("extra_credentials"),
trinoTimeZoneHeader: query.Get("time_zone"),
} {
if v != "" {
c.httpHeaders.Add(k, v)
Expand Down