Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions runtime/drivers/clickhouse/olap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package clickhouse

import (
"context"
"database/sql"
"errors"
"fmt"
"strings"
Expand Down Expand Up @@ -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...)
Expand Down
67 changes: 67 additions & 0 deletions runtime/resolvers/testdata/metrics_clickhouse_playground.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading