feat: Add option to change max_execution_time setting for clickhouse … (#5683)

This commit is contained in:
thesnallygaster 2024-08-23 16:41:49 +02:00 committed by GitHub
parent a2ac49bfc2
commit d7fd1d032b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -184,6 +184,7 @@ func NewReaderFromClickhouseConnection(
wrap := clickhouseConnWrapper{ wrap := clickhouseConnWrapper{
conn: db, conn: db,
settings: ClickhouseQuerySettings{ settings: ClickhouseQuerySettings{
MaxExecutionTime: os.Getenv("ClickHouseMaxExecutionTime"),
MaxExecutionTimeLeaf: os.Getenv("ClickHouseMaxExecutionTimeLeaf"), MaxExecutionTimeLeaf: os.Getenv("ClickHouseMaxExecutionTimeLeaf"),
TimeoutBeforeCheckingExecutionSpeed: os.Getenv("ClickHouseTimeoutBeforeCheckingExecutionSpeed"), TimeoutBeforeCheckingExecutionSpeed: os.Getenv("ClickHouseTimeoutBeforeCheckingExecutionSpeed"),
MaxBytesToRead: os.Getenv("ClickHouseMaxBytesToRead"), MaxBytesToRead: os.Getenv("ClickHouseMaxBytesToRead"),

View File

@ -11,6 +11,7 @@ import (
) )
type ClickhouseQuerySettings struct { type ClickhouseQuerySettings struct {
MaxExecutionTime string
MaxExecutionTimeLeaf string MaxExecutionTimeLeaf string
TimeoutBeforeCheckingExecutionSpeed string TimeoutBeforeCheckingExecutionSpeed string
MaxBytesToRead string MaxBytesToRead string
@ -47,6 +48,10 @@ func (c clickhouseConnWrapper) addClickHouseSettings(ctx context.Context, query
settings["max_bytes_to_read"] = c.settings.MaxBytesToRead settings["max_bytes_to_read"] = c.settings.MaxBytesToRead
} }
if c.settings.MaxExecutionTime != "" {
settings["max_execution_time"] = c.settings.MaxExecutionTime
}
if c.settings.MaxExecutionTimeLeaf != "" { if c.settings.MaxExecutionTimeLeaf != "" {
settings["max_execution_time_leaf"] = c.settings.MaxExecutionTimeLeaf settings["max_execution_time_leaf"] = c.settings.MaxExecutionTimeLeaf
} }