-
Notifications
You must be signed in to change notification settings - Fork 125
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
Setup test fixtures for resolvers #5317
Changes from 10 commits
698fcc1
c76d60c
4836668
c5e1560
eb344c1
eeab03b
4b7baa6
7979b7d
a980ad2
a2989ec
7fce8af
a9d5ec7
ead0534
0dd4820
5976e37
a028a8a
2246de9
27456cd
578e919
4ffb84c
ac3bb1c
3d9ad74
10d5848
4f3da82
a457f04
5b51e56
594ba0c
1da4e0d
5188c19
ddf6c00
ba55ff7
2191e3c
bd11fd8
d38f6b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"net/http" | ||
"reflect" | ||
"strconv" | ||
"strings" | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
|
@@ -65,12 +66,18 @@ func (c *sqlConnection) QueryContext(ctx context.Context, query string, args []d | |
}) | ||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.dsn, bodyReader) | ||
if err != nil { | ||
if strings.Contains(err.Error(), c.dsn) { // avoid returning the actual DSN with the password which will be logged | ||
return nil, fmt.Errorf("invalid dsn") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps return the original error, but with something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
return nil, err | ||
} | ||
|
||
req.Header.Add("Content-Type", "application/json") | ||
resp, err := c.client.Do(req) | ||
if err != nil { | ||
if strings.Contains(err.Error(), c.dsn) { // avoid returning the actual DSN with the password which will be logged | ||
return nil, fmt.Errorf("invalid dsn") | ||
} | ||
return nil, err | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
project: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
models: | ||
ad_bids_mini.yaml: | ||
type: model | ||
sql: SELECT * FROM url('https://raw.githubusercontent.com/rilldata/rill/main/runtime/testruntime/testdata/ad_bids/data/AdBids_mini.csv', CSV) | ||
output: | ||
columns: (id UInt32,timestamp DateTime64,publisher varchar,domain varchar,bid_price Float32,volume UInt8,impressions UInt8,"ad words" varchar,clicks Float32,device varchar) | ||
materialize: true | ||
incremental_strategy: append | ||
dashboards: | ||
ad_bids_mini_metrics_with_policy.yaml: | ||
model: ad_bids_mini | ||
display_name: Ad bids | ||
description: | ||
|
||
timeseries: timestamp | ||
smallest_time_grain: "" | ||
|
||
dimensions: | ||
- label: Publisher | ||
name: publisher | ||
expression: publisher | ||
description: "" | ||
- label: Domain | ||
property: domain | ||
description: "" | ||
|
||
measures: | ||
- label: "Number of bids" | ||
name: bid's number | ||
expression: count(*) | ||
- label: "Total volume" | ||
name: total volume | ||
expression: sum(volume) | ||
- label: "Total impressions" | ||
name: total impressions | ||
expression: sum(impressions) | ||
- label: "Total clicks" | ||
name: total click"s | ||
expression: sum(clicks) | ||
|
||
security: | ||
access: true | ||
row_filter: "domain = '{{ .user.domain }}'" | ||
exclude: | ||
- if: "'{{ .user.domain }}' != 'msn.com'" | ||
names: | ||
- total volume | ||
apis: | ||
mv_sql_policy_api.yaml: | ||
kind : api | ||
metrics_sql: | | ||
select | ||
publisher, | ||
domain, | ||
"total impressions" | ||
FROM | ||
ad_bids_mini_metrics_with_policy | ||
connectors: | ||
clickhouse: ~ | ||
tests: | ||
simple: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: yahoo.com | ||
email: user@yahoo.com | ||
result: | ||
- domain: yahoo.com | ||
publisher: Yahoo | ||
"total impressions": 3.0 | ||
msn: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: msn.com | ||
email: user@msn.com | ||
result: | ||
- domain: msn.com | ||
publisher: "" | ||
"total impressions": 3.0 | ||
empty: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: google.com | ||
email: user@google.com | ||
result: ~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
project: | ||
sources: {} | ||
models: {} | ||
dashboards: | ||
ad_bids_mini_metrics_with_policy.yaml: | ||
model: AdBids | ||
display_name: Ad bids | ||
description: | ||
timeseries: __time | ||
smallest_time_grain: "" | ||
dimensions: | ||
- label: Publisher | ||
name: publisher | ||
expression: publisher | ||
description: "" | ||
- label: Domain | ||
property: domain | ||
description: "" | ||
measures: | ||
- label: "Number of bids" | ||
name: bid's number | ||
expression: count(*) | ||
- label: "Max bid price" | ||
name: max bid price | ||
expression: max(bid_price) | ||
- label: "min bid price" | ||
name: min bid price | ||
expression: min(bid_price) | ||
security: | ||
access: true | ||
# row_filter: "domain = '{{ .user.domain }}'" is not supported in Druid | ||
# exclude: is not supported in Druid | ||
apis: | ||
mv_sql_policy_api.yaml: | ||
kind: api | ||
metrics_sql: "select \n publisher,\n domain, \n \"min bid price\",\n \"max bid price\"\nFROM \n ad_bids_mini_metrics_with_policy \nWHERE\n publisher is not null AND domain = 'news.yahoo.com'\nORDER BY \n publisher,\n domain\nLIMIT 1\n" | ||
connectors: | ||
druid: null | ||
tests: | ||
simple: | ||
resolver: mv_sql_policy_api | ||
options: | ||
instanceid: "" | ||
resolver: "" | ||
resolverproperties: {} | ||
args: {} | ||
claims: | ||
user_attributes: | ||
domain: yahoo.com | ||
email: user@yahoo.com | ||
additionalrules: [] | ||
skipchecks: false | ||
result: | ||
- domain: news.yahoo.com | ||
max bid price: 6.00 | ||
min bid price: 1.00 | ||
publisher: Yahoo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
project: | ||
sources: | ||
ad_bids_mini_source.yaml: | ||
connector: https | ||
path: https://raw.githubusercontent.com/rilldata/rill/main/runtime/testruntime/testdata/ad_bids/data/AdBids_mini.csv | ||
models: | ||
"ad_bids_mini.yaml": | ||
sql: | | ||
select | ||
id, | ||
timestamp, | ||
publisher, | ||
domain, | ||
volume, | ||
impressions, | ||
clicks | ||
from ad_bids_mini_source | ||
dashboards: | ||
ad_bids_mini_metrics_with_policy.yaml: | ||
model: ad_bids_mini | ||
display_name: Ad bids | ||
description: | ||
|
||
timeseries: timestamp | ||
smallest_time_grain: "" | ||
|
||
dimensions: | ||
- label: Publisher | ||
name: publisher | ||
expression: upper(publisher) | ||
description: "" | ||
- label: Domain | ||
property: domain | ||
description: "" | ||
|
||
measures: | ||
- label: "Number of bids" | ||
name: bid's number | ||
expression: count(*) | ||
- label: "Total volume" | ||
name: total volume | ||
expression: sum(volume) | ||
- label: "Total impressions" | ||
name: total impressions | ||
expression: sum(impressions) | ||
- label: "Total clicks" | ||
name: total click"s | ||
expression: sum(clicks) | ||
|
||
security: | ||
access: true | ||
row_filter: "domain = '{{ .user.domain }}'" | ||
exclude: | ||
- if: "'{{ .user.domain }}' != 'msn.com'" | ||
names: | ||
- total volume | ||
apis: | ||
mv_sql_policy_api.yaml: | ||
kind : api | ||
metrics_sql: | | ||
select | ||
publisher, | ||
domain, | ||
"total impressions" | ||
FROM | ||
ad_bids_mini_metrics_with_policy | ||
connectors: | ||
duckdb: ~ | ||
tests: | ||
simple: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: yahoo.com | ||
email: user@yahoo.com | ||
result: | ||
- domain: yahoo.com | ||
publisher: YAHOO | ||
"total impressions": 3.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are many output values, this might get tedious to type – do you think it would make sense to optionally support a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You cannot specify the type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
msn: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: msn.com | ||
email: user@msn.com | ||
result: | ||
- domain: msn.com | ||
publisher: ~ | ||
"total impressions": 3.0 | ||
empty: | ||
resolver: mv_sql_policy_api | ||
options: | ||
claims: | ||
user_attributes: | ||
domain: google.com | ||
email: user@google.com | ||
result: ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indirect dependency added without change to a direct dependency – try running
go mod tidy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.