diff --git a/runtime/drivers/clickhouse/olap.go b/runtime/drivers/clickhouse/olap.go index 1033385746b..4c8a20c4210 100644 --- a/runtime/drivers/clickhouse/olap.go +++ b/runtime/drivers/clickhouse/olap.go @@ -2,6 +2,7 @@ package clickhouse import ( "context" + "database/sql" "errors" "fmt" "strings" @@ -447,6 +448,14 @@ type SQLConn struct { supportSettings bool } +func (sc *SQLConn) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) { + if sc.supportSettings { + return sc.Conn.ExecContext(ctx, query, args...) + } + ctx2 := contextWithoutDeadline(ctx) + return sc.Conn.ExecContext(ctx2, query, args...) +} + func (sc *SQLConn) QueryxContext(ctx context.Context, query string, args ...any) (*sqlx.Rows, error) { if sc.supportSettings { return sc.Conn.QueryxContext(ctx, query, args...) diff --git a/runtime/resolvers/testdata/metrics_clickhouse_playground.yaml b/runtime/resolvers/testdata/metrics_clickhouse_playground.yaml new file mode 100644 index 00000000000..94381560bc4 --- /dev/null +++ b/runtime/resolvers/testdata/metrics_clickhouse_playground.yaml @@ -0,0 +1,67 @@ +project_files: + clickhouse.yaml: + type: connector + driver: clickhouse + host: play.clickhouse.com + port: 9440 + username: play + ssl: true + uk_price_paid.yaml: + type: metrics_view + connector: clickhouse + model: uk_price_paid + timeseries: date + dimensions: + - column: date + - column: postcode1 + - column: postcode2 + - column: type + - column: duration + - column: addr1 + - column: addr2 + - column: street + - column: locality + - column: town + - column: district + - column: county + measures: + - name: total_transactions + expression: COUNT(*) + - name: total_price_paid + expression: SUM(price) + - name: average_sale_price + expression: AVG(price) + - name: min_sale_price + expression: MIN(price) + - name: max_sale_price + expression: MAX(price) + - name: new_build_transactions + expression: SUM(is_new) + - name: average_price_new_build_flag_weighted + expression: AVG(price * is_new) + - name: distinct_postcode1_count + expression: COUNT(DISTINCT postcode1) + - name: distinct_town_count + expression: COUNT(DISTINCT town) + - name: distinct_county_count + expression: COUNT(DISTINCT county) +tests: + - name: simple_query + resolver: metrics + properties: + metrics_view: uk_price_paid + dimensions: + - name: type + measures: + - name: total_transactions + result: + - total_transactions: 602799 + type: other + - total_transactions: 9.142255e+06 + type: terraced + - total_transactions: 8.409109e+06 + type: semi-detached + - total_transactions: 7.107089e+06 + type: detached + - total_transactions: 5.552052e+06 + type: flat