Skip to content

Commit aaeeb47

Browse files
Merge pull request #333 from ClickHouse/snwoflake_pricings
Snowflake pricings
2 parents 291fcbf + 0355ff0 commit aaeeb47

File tree

3 files changed

+297
-0
lines changed

3 files changed

+297
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
./enrich.sh clickbench/results/xs.json \
2+
pricings/standard_warehouse.json \
3+
results/xs_enriched.json \
4+
--cloud aws --region us-east-1
5+
6+
./enrich.sh clickbench/results/large.json \
7+
pricings/standard_warehouse.json \
8+
results/large_enriched.json \
9+
--cloud aws --region us-east-1
10+
11+
./enrich.sh clickbench/results/4xl.json \
12+
pricings/standard_warehouse.json \
13+
results/4xl_enriched.json \
14+
--cloud aws --region us-east-1
15+
16+
17+
18+
19+
20+
./enrich.sh clickbench/results_1b/xs.json \
21+
pricings/standard_warehouse.json \
22+
results_1B/xs_enriched.json \
23+
--cloud aws --region us-east-1
24+
25+
./enrich.sh clickbench/results_1b/large.json \
26+
pricings/standard_warehouse.json \
27+
results_1B/large_enriched.json \
28+
--cloud aws --region us-east-1
29+
30+
./enrich.sh clickbench/results_1b/4xl.json \
31+
pricings/standard_warehouse.json \
32+
results_1B/4xl_enriched.json \
33+
--cloud aws --region us-east-1
34+
35+
36+
37+
./enrich.sh clickbench/results_10b/xs.json \
38+
pricings/standard_warehouse.json \
39+
results_10B/xs_enriched.json \
40+
--cloud aws --region us-east-1
41+
42+
./enrich.sh clickbench/results_10b/large.json \
43+
pricings/standard_warehouse.json \
44+
results_10B/large_enriched.json \
45+
--cloud aws --region us-east-1
46+
47+
./enrich.sh clickbench/results_10b/4xl.json \
48+
pricings/standard_warehouse.json \
49+
results_10B/4xl_enriched.json \
50+
--cloud aws --region us-east-1
51+
52+
53+
54+
./enrich.sh clickbench/results_100b/xs.json \
55+
pricings/standard_warehouse.json \
56+
results_100B/xs_enriched.json \
57+
--cloud aws --region us-east-1
58+
59+
./enrich.sh clickbench/results_100b/large.json \
60+
pricings/standard_warehouse.json \
61+
results_100B/large_enriched.json \
62+
--cloud aws --region us-east-1
63+
64+
./enrich.sh clickbench/results_100b/4xl.json \
65+
pricings/standard_warehouse.json \
66+
results_100B/4xl_enriched.json \
67+
--cloud aws --region us-east-1
68+
69+
70+
71+
72+
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ---------------------------------------------
5+
# Enrich Snowflake ClickBench results with cost info
6+
# using a pricing JSON (standard_warehouse.json).
7+
#
8+
# Usage:
9+
# ./enrich.sh <clickbench_json> <pricing_json> <output_json> \
10+
# [--cloud <val>] [--region <val>]
11+
#
12+
# Example:
13+
# ./enrich.sh clickbench/results/4xl.json \
14+
# pricings/standard_warehouse.json \
15+
# results/4xl_enriched.json \
16+
# --cloud aws --region us-east-1
17+
#
18+
# This computes costs for *all* matching pricing plans
19+
# (standard, enterprise, business_critical, …) and writes
20+
# them into the .costs[] array, one entry per plan.
21+
# ---------------------------------------------
22+
23+
CLOUD="aws"
24+
REGION="us-east-1"
25+
26+
if [ "$#" -lt 3 ]; then
27+
echo "Usage: $0 <clickbench_json> <pricing_json> <output_json> [--cloud <val>] [--region <val>]" >&2
28+
exit 1
29+
fi
30+
31+
BENCH_FILE="$1"
32+
PRICING_FILE="$2"
33+
OUT_FILE="$3"
34+
shift 3
35+
36+
while [[ $# -gt 0 ]]; do
37+
case "$1" in
38+
--cloud) CLOUD="$2"; shift 2 ;;
39+
--region) REGION="$2"; shift 2 ;;
40+
*)
41+
echo "Unknown option: $1" >&2
42+
exit 1
43+
;;
44+
esac
45+
done
46+
47+
if ! command -v jq >/dev/null 2>&1; then
48+
echo "❌ jq is required." >&2
49+
exit 1
50+
fi
51+
52+
OUT_DIR=$(dirname "$OUT_FILE")
53+
mkdir -p "$OUT_DIR"
54+
55+
echo "→ Enriching Snowflake ClickBench results"
56+
echo " Cloud : ${CLOUD}"
57+
echo " Region: ${REGION}"
58+
echo
59+
60+
jq -s \
61+
--arg cloud "$CLOUD" \
62+
--arg region "$REGION" '
63+
.[0] as $bench |
64+
.[1] as $pricing |
65+
66+
# we use cluster_size as the "credits per hour" key
67+
# e.g. 128 → 4X-Large entry in pricing.warehouses[]
68+
($bench.cluster_size) as $cluster_credits |
69+
70+
# build one cost entry per matching pricing block (plan)
71+
[
72+
$pricing.pricing[]
73+
| select(.cloud == $cloud and .region == $region)
74+
| . as $block
75+
76+
# find warehouse entry whose credits_per_hour == cluster_size
77+
| ($block.warehouses[]
78+
| select(.credits_per_hour == $cluster_credits)) as $wh
79+
80+
# base prices
81+
| ($block.credit_price_per_hour) as $credit_price
82+
| ($wh.credits_per_hour) as $credits_per_hour
83+
84+
# storage pricing
85+
| ($block.storage.storage) as $storage_price
86+
| ($block.storage.storage_price_unit) as $storage_unit
87+
88+
# compute costs: seconds * (credits_per_hour * credit_price / 3600)
89+
| ($bench.result
90+
| map(
91+
map(
92+
if . == null then null
93+
else (. * ($credits_per_hour * $credit_price / 3600.0))
94+
end
95+
)
96+
)
97+
) as $compute_costs
98+
99+
# storage cost: bytes / unit * price
100+
| ($bench.data_size / $storage_unit * $storage_price) as $storage_cost
101+
102+
# one cost object per plan
103+
| {
104+
tier: .plan,
105+
provider: $cloud,
106+
service: $pricing.service,
107+
cloud: $cloud,
108+
region: $region,
109+
110+
warehouse_size: $wh.name,
111+
data_size: $bench.data_size,
112+
113+
storage_cost: $storage_cost,
114+
storage_costs: [
115+
{
116+
model: "object",
117+
term: "active",
118+
period: "monthly",
119+
price_per_byte: ($storage_price / $storage_unit),
120+
bytes: $bench.data_size,
121+
estimated_cost: $storage_cost,
122+
pricing_base: {
123+
price_usd: $storage_price,
124+
price_unit: "byte_month",
125+
price_unit_bytes: $storage_unit,
126+
notes: "Snowflake storage (list price)."
127+
}
128+
}
129+
],
130+
131+
compute_costs: $compute_costs,
132+
133+
pricing_base: {
134+
credits_per_hour: $credits_per_hour,
135+
credit_price_per_hour: $credit_price,
136+
storage: $storage_price,
137+
storage_price_unit: $storage_unit
138+
}
139+
}
140+
] as $all_costs
141+
| $bench + { costs: $all_costs }
142+
' "$BENCH_FILE" "$PRICING_FILE" > "$OUT_FILE"
143+
144+
echo "✅ Written to $OUT_FILE"
145+
echo "💰 Total compute cost per tier:"
146+
jq -r '.costs[]
147+
| "\(.tier): \([.compute_costs[][]] | add)"' "$OUT_FILE"
148+
echo "💾 Storage cost (same per tier):"
149+
jq -r '.costs[0].storage_cost' "$OUT_FILE"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"provider": "snowflake",
3+
"service": "warehouse_compute",
4+
"currency": "USD",
5+
6+
"pricing": [
7+
{
8+
"cloud": "aws",
9+
"region": "us-east-1",
10+
"plan": "standard",
11+
12+
"credit_price_per_hour": 2.00,
13+
14+
"warehouses": [
15+
{ "name": "X-Small", "credits_per_hour": 1 },
16+
{ "name": "Small", "credits_per_hour": 2 },
17+
{ "name": "Medium", "credits_per_hour": 4 },
18+
{ "name": "Large", "credits_per_hour": 8 },
19+
{ "name": "X-Large", "credits_per_hour": 16 },
20+
{ "name": "2X-Large", "credits_per_hour": 32 },
21+
{ "name": "3X-Large", "credits_per_hour": 64 },
22+
{ "name": "4X-Large", "credits_per_hour": 128 }
23+
],
24+
"storage": {
25+
"storage": 23.0,
26+
"storage_price_unit": 1000000000000
27+
}
28+
},
29+
30+
{
31+
"cloud": "aws",
32+
"region": "us-east-1",
33+
"plan": "enterprise",
34+
35+
"credit_price_per_hour": 3.00,
36+
37+
"warehouses": [
38+
{ "name": "X-Small", "credits_per_hour": 1 },
39+
{ "name": "Small", "credits_per_hour": 2 },
40+
{ "name": "Medium", "credits_per_hour": 4 },
41+
{ "name": "Large", "credits_per_hour": 8 },
42+
{ "name": "X-Large", "credits_per_hour": 16 },
43+
{ "name": "2X-Large", "credits_per_hour": 32 },
44+
{ "name": "3X-Large", "credits_per_hour": 64 },
45+
{ "name": "4X-Large", "credits_per_hour": 128 }
46+
],
47+
"storage": {
48+
"storage": 23.0,
49+
"storage_price_unit": 1000000000000
50+
}
51+
},
52+
53+
{
54+
"cloud": "aws",
55+
"region": "us-east-1",
56+
"plan": "business_critical",
57+
58+
"credit_price_per_hour": 4.00,
59+
60+
"warehouses": [
61+
{ "name": "X-Small", "credits_per_hour": 1 },
62+
{ "name": "Small", "credits_per_hour": 2 },
63+
{ "name": "Medium", "credits_per_hour": 4 },
64+
{ "name": "Large", "credits_per_hour": 8 },
65+
{ "name": "X-Large", "credits_per_hour": 16 },
66+
{ "name": "2X-Large", "credits_per_hour": 32 },
67+
{ "name": "3X-Large", "credits_per_hour": 64 },
68+
{ "name": "4X-Large", "credits_per_hour": 128 }
69+
],
70+
"storage": {
71+
"storage": 23.0,
72+
"storage_price_unit": 1000000000000
73+
}
74+
}
75+
]
76+
}

0 commit comments

Comments
 (0)