pengding-stripe commented on issue #16024:
URL: https://github.com/apache/pinot/issues/16024#issuecomment-2956509678
thanks @ankitsultana, I feel this option should be default to true for this
case? Our queries are sent from the user, it's hard for us to validate all of
them and users could make mistakes. Below is an example of query sent by user,
I hide the merchant id though
```
WITH "billing_meter_date_spine" AS (
SELECT *
FROM "prod_rdp_express_12h_billing_meter_date_spine_data"
WHERE "_viewing_merchant" = '_public_shared_merchant_id'
),
"billing_meter_granular_ratings_analytics_nw_v2" AS (
SELECT *
FROM
"prod_rdp_express_12h_billing_meter_granular_ratings_analytics_nw_v2_data"
WHERE "_viewing_merchant" = 'xxx'
),
"billing_meter_prices_v1" AS (
SELECT *
FROM "prod_rdp_express_12h_billing_meter_prices_v1_data"
WHERE "_viewing_merchant" = 'xxx'
),
"billing_meter_products_v1" AS (
SELECT *
FROM "prod_rdp_express_12h_billing_meter_products_v1_data"
WHERE "_viewing_merchant" = 'xxx'
),
"ubb_analytics_denorm_fx_rates" AS (
SELECT *
FROM "prod_rdp_express_12h_ubb_analytics_denorm_fx_rates_data"
WHERE "_viewing_merchant" = 'xxx'
)
SELECT *
FROM (
WITH "enriched_filtered_ratings_table" AS (
SELECT "ratings_table"."ts_bucket",
"ratings_table"."mode",
"ratings_table"."metric_value_bucketed",
"ratings_table"."currency",
"products"."product_exposed_id" AS "product_mrchid",
"prices"."price_exposed_id" AS "price_mrchid",
"products"."name" AS "product_name",
"max_received_at"
FROM "billing_meter_granular_ratings_analytics_nw_v2" AS
"ratings_table"
LEFT JOIN "billing_meter_products_v1" AS "products" ON
"ratings_table"."product_id" = "products"."product_id"
LEFT JOIN "billing_meter_prices_v1" AS "prices" ON
"ratings_table"."price_id" = "prices"."price_id"
),
"meters_with_fx_dates" AS (
SELECT "date_trunc"('day', "ts_bucket") AS "fx_date",
*
FROM "enriched_filtered_ratings_table"
),
"meters_with_to_rate" AS (
SELECT *,
"fx_to"."rate" AS "fx_to_rate"
FROM "meters_with_fx_dates"
INNER JOIN "ubb_analytics_denorm_fx_rates" AS "fx_to" ON
"fx_to"."currency" = 'usd'
AND "fx_to"."rate_start_date" = "fx_date"
),
"precomputed_meters" AS (
SELECT "ts_bucket",
"mode",
"roundDecimal"(
"metric_value_bucketed" * ("fx_to_rate" / "fx_from"."rate"),
0
) AS "metric_value_bucketed",
"price_mrchid",
"product_mrchid",
"product_name",
"max_received_at"
FROM "meters_with_to_rate"
INNER JOIN "ubb_analytics_denorm_fx_rates" AS "fx_from" ON
"fx_from"."currency" = "meters_with_to_rate"."currency"
AND "fx_from"."rate_start_date" = "meters_with_to_rate"."fx_date"
),
"final_groups" AS (
SELECT "ts_bucket",
"metric_value_bucketed",
"max_received_at",
'All' AS "group_id",
'All' AS "group_name"
FROM "precomputed_meters"
WHERE "mode" = 'LIVEMODE'
),
"date_spine" AS (
SELECT CAST("date_timestamp" - -21600000 AS TIMESTAMP) AS "ts_bucket",
0 AS "metric_value_bucketed",
-1 AS "max_received_at",
"groupings"."group_id" AS "group_id",
"groupings"."group_name" AS "group_name"
FROM "billing_meter_date_spine"
CROSS JOIN (
SELECT 'All' AS "group_id",
'All' AS "group_name" FETCH NEXT 1 ROWS ONLY
) AS "groupings"
),
"final_groups_gapfilled" AS (
SELECT COALESCE(
"final_groups"."ts_bucket",
"date_spine"."ts_bucket"
) AS "ts_bucket",
COALESCE(
"final_groups"."metric_value_bucketed",
"date_spine"."metric_value_bucketed"
) AS "metric_value_bucketed",
COALESCE(
"final_groups"."max_received_at",
"date_spine"."metric_value_bucketed"
) AS "max_received_at",
COALESCE(
"final_groups"."group_id",
"date_spine"."group_id"
) AS "group_id",
COALESCE(
"final_groups"."group_name",
"date_spine"."group_name"
) AS "group_name"
FROM "final_groups"
FULL JOIN "date_spine" ON "date_spine"."ts_bucket" =
"final_groups"."ts_bucket"
)
SELECT "ToDateTime"(
"date_trunc"(
'day',
CAST("ts_bucket" AS BIGINT) + "from_epoch_days"(0),
'MILLISECONDS',
'America/Lima'
) - "from_epoch_days"(0),
'yyyy-MM-dd'
) AS "start_time",
CAST(SUM("metric_value_bucketed") AS BIGINT) AS "total",
'' AS "group_id",
'' AS "group_name"
FROM "final_groups_gapfilled"
WHERE "ts_bucket" >= "FromDateTime"('2025-04-02 05:00:00', 'yyyy-MM-dd
HH:mm:ss')
AND "ts_bucket" < "FromDateTime"('2025-03-28 04:59:59', 'yyyy-MM-dd
HH:mm:ss')
AND "max_received_at" < CAST(
"FromDateTime"('2025-05-19 19:46:59', 'yyyy-MM-dd HH:mm:ss') AS
BIGINT
)
GROUP BY 1
ORDER BY 1 FETCH NEXT 10000 ROWS ONLY
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]