Closed SubhasmitaSw closed 1 year ago
Hi! is this calculation being done on your Trino or in Clickhouse?
hey, this calculation is being done on Metabase, the table (data) is stored in clickhouse, connected over via Trino to Metabase.
Please post the sql being generated
Entire SQL of the workout
SELECT date_trunc('month', "source"."charged_from") AS "charged_from", sum("source"."License Cost") AS "sum"
FROM (SELECT "source"."charged_from" AS "charged_from", "source"."Hourly cost NEV" AS "Hourly cost NEV", "source"."count" AS "count", ("source"."Hourly cost NEV" * "source"."count") AS "License Cost" FROM (SELECT date_trunc('month', "source"."charged_from") AS "charged_from", "source"."Hourly cost NEV" AS "Hourly cost NEV", count(*) AS "count" FROM (SELECT "prod_civo_dotcom"."invoice_items"."id" AS "id", "prod_civo_dotcom"."invoice_items"."invoice_id" AS "invoice_id", "prod_civo_dotcom"."invoice_items"."code" AS "code", "prod_civo_dotcom"."invoice_items"."label" AS "label", "prod_civo_dotcom"."invoice_items"."charged_from" AS "charged_from", "prod_civo_dotcom"."invoice_items"."charged_to" AS "charged_to", "prod_civo_dotcom"."invoice_items"."hours" AS "hours", "prod_civo_dotcom"."invoice_items"."cost" AS "cost", "prod_civo_dotcom"."invoice_items"."created_at" AS "created_at", "prod_civo_dotcom"."invoice_items"."updated_at" AS "updated_at", "prod_civo_dotcom"."invoice_items"."product_id" AS "product_id", "prod_civo_dotcom"."invoice_items"."region" AS "region", "prod_civo_dotcom"."invoice_items"."charge_id" AS "charge_id", ("prod_civo_dotcom"."invoice_items"."hours" * 0.022321) AS "Hourly cost NEV" FROM "prod_civo_dotcom"."invoice_items") "source"
WHERE ((lower("source"."code") like '%node%')
AND ("source"."region" = 'PHX1'
OR "source"."region" = 'true, :kubernetes=>true} country:uk out_of_capacity:true>') AND "source"."invoice_id" = 1672049)
GROUP BY date_trunc('month', "source"."charged_from"), "source"."Hourly cost NEV"
ORDER BY date_trunc('month', "source"."charged_from") ASC, "source"."Hourly cost NEV" ASC) "source") "source" GROUP BY date_trunc('month', "source"."charged_from") ORDER BY date_trunc('month', "source"."charged_from") ASC
Is it possible you’re using a question based on a sql question?
No custom sql questions are used here. Just a table from a database and some basic metabase functions (custom column, summarize, filter) applied to it.
@SubhasmitaSw by default we only show 2 decimal places in numbers. Based on the image above it's very like to be the source of confusion. Could you double check whether there are additional decimal places in numbers that you multiply?
@SubhasmitaSw please re-open if it's not related to the above. Thanks!
Describe the bug
Hello Metabase Team,
we've been setting up metabase for our team for some time now and it's a really integral part of the BI stack. Our scenario includes a discrepancy which I believe is a bug on your side (assuming), a simple multiplication of two columns to get a custom column returns incorrect values than expected.
In the above image, the License Cost column is a custom column where
License Cost = [Hourly cost NEV] * [count of rows]
which should match the calculations exactly as below but there's a total difference of0.42
.To Reproduce
Expected behavior
The calculations should be exactly.
Logs
[9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T15:58:19+05:30 DEBUG metabase.server.middleware.log POST /api/dataset 202 [ASYNC: completed] 442.1 ms (4 DB calls) App DB connections: 0/15 Jetty threads: 3/50 (3 idle, 0 queued) (112 total active threads) Queries in flight: 0 (0 queued); starburst DB 5 connections: 0/1 (0 threads blocked) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.task.sync-databases Starting sync task for Database 41. [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: Sync metadata for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'sync-timezone' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'sync-timezone' for starburst Database 41 'Trino_ClickhouseDB' (54.1 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'sync-tables' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.sync-metadata.tables Marking tables as inactive: (Table 'default.invoice_sizes') [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.sync-metadata.tables Updating description for tables: (Table 'default.ch_sizes' Table 'default.hardware_sizes') [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'sync-tables' for starburst Database 41 'Trino_ClickhouseDB' (15.0 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'sync-fields' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'sync-fields' for starburst Database 41 'Trino_ClickhouseDB' (347.3 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'sync-fks' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'sync-fks' for starburst Database 41 'Trino_ClickhouseDB' (875.2 µs) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'sync-metabase-metadata' for starburst Database 41 'Trino_ClickhouseDB' (147.8 µs) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'sync-metabase-metadata' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: Sync metadata for starburst Database 41 'Trino_ClickhouseDB' (427.2 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: Analyze data for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze fingerprint-fields Analyzed [*···········································] 😞 14% Table 516 'default.hardware_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'fingerprint-fields' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze fingerprint-fields Analyzed [**····································] 😒 29% Table 531 'default.ch_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'fingerprint-fields' for starburst Database 41 'Trino_ClickhouseDB' (2.9 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'classify-fields' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze classify-fields Analyzed [****······················] 😌 57% Table 531 'default.ch_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze classify-fields Analyzed [***·····························] 😐 43% Table 516 'default.hardware_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'classify-fields' for starburst Database 41 'Trino_ClickhouseDB' (967.2 µs) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util STARTING: step 'classify-tables' for starburst Database 41 'Trino_ClickhouseDB' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze classify-tables Analyzed [***···············] 😋 71% Table 516 'default.hardware_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.analyze classify-tables Analyzed [**········] 😊 86% Table 531 'default.ch_sizes' [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: step 'classify-tables' for starburst Database 41 'Trino_ClickhouseDB' (1.7 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:06:00+05:30 INFO metabase.sync.util FINISHED: Analyze data for starburst Database 41 'Trino_ClickhouseDB' (10.7 ms) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:16:56+05:30 DEBUG metabase.server.middleware.log GET /api/session/properties 200 21.9 ms (3 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (2 idle, 0 queued) (108 total active threads) Queries in flight: 0 (0 queued) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:16:56+05:30 DEBUG metabase.server.middleware.log GET /api/setting 200 26.4 ms (2 DB calls) App DB connections: 0/15 Jetty threads: 5/50 (2 idle, 0 queued) (110 total active threads) Queries in flight: 0 (0 queued) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:16:57+05:30 DEBUG metabase.server.middleware.log GET /api/setup/admin_checklist 200 7.7 ms (11 DB calls) App DB connections: 0/15 Jetty threads: 4/50 (3 idle, 0 queued) (112 total active threads) Queries in flight: 0 (0 queued) [9a495989-7487-46b2-ae71-da7c190f4d62] 2023-05-25T16:16:57+05:30 DEBUG metabase.server.middleware.log GET /api/util/bug_report_details 200 13.5 ms (1 DB calls) App DB connections: 0/15 Jetty threads: 4/50 (3 idle, 0 queued) (112 total active threads) Queries in flight: 0 (0 queued)
Information about your Metabase installation
Severity
It's blocking the invoice analytics and audit that is overdue by 1 month.
Additional context
No response