Hello,
I have my 1st version of query.
select
creative_catalog.`values`.scores.karmic_hotness.score as scores_creative_karmic_hotness,
creative_catalog.`values`.scores.sales_hotness_creative.score as scores_sales_hotness_creative,
meta('catalog_dump').id,
catalog_dump.`values`.title,
(ARRAY x FOR x in scores WHEN x.score = ARRAY_MAX(scores[*].score) END)[0] as defaultSkuScore
from catalog_dump left join catalog_dump as creative_catalog on keys "prefix" || REPLACE(SPLIT(catalog_dump.id, "p")[0], "s6-", "")
let scores = ARRAY x.scores.sales_hotness_sku FOR x in OBJECT_VALUES(catalog_dump.`values`.skus) END, timestamp = NOW_MILLIS()
where
catalog_dump.form = 'product'
and
catalog_dump.`values`.product_type = 9393
Is there a way to remove repetition in the followin section? ARRAY_MAX is essentially calculating the same value. I’ve tried setting the value by using let but it wasn’t working for me.
(ARRAY x FOR x in scores WHEN x.score = ARRAY_MAX(scores[*].score) END)[0] as defaultSkuScore
I’ve tried
let scores = ARRAY x.scores.sales_hotness_sku FOR x in OBJECT_VALUES(catalog_dump.`values`.skus) END,
timestamp = NOW_MILLIS(),
max_score = ARRAY_MAX(scores[*].score)
Thanks,
Moon