Created
March 5, 2022 14:34
-
-
Save MikeRzhevsky/35437c95320c8215bd6ead8bfa6950b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select customer_id, | |
| redeem_percentage, | |
| redeem_amount, | |
| cancelled_orders_amount, | |
| ordered_basic_goods_qty | |
| from clickhouse.cifra.ct_privilege_cards__calculated_indicators | |
| WHERE NOT EXISTS | |
| (SELECT dbt_statuses."покупатель", | |
| dbt_statuses."процентвыкупа", | |
| dbt_statuses."суммавыкупа", | |
| dbt_statuses."суммаотказов", | |
| dbt_statuses."заказаноcущественныхтоваров" | |
| from cifratest.dbt_stage."dm_stage_регистрсведений_статусыкартprivilege" as dbt_statuses ) |
Author
Author
модель dm
{{ config(
as_columnstore=false,
post_hook=["
{{ create_clustered_index(columns = ['Период']) }}
{{ create_nonclustered_index(columns = ['Покупатель']) }}
"]
)
}}
with datesort as (
select Период, {{ BinaryToChar('Покупатель') }} as Покупатель, СуммаВыкупа, СуммаОтказов, ПроцентВыкупа, Статус,
ЗаказаноCущественныхТоваров, СтатусКарты, СуммаВыкупаДляДР,
row_number() over(partition by Покупатель order by Период desc) as RowNum
from {{ source('1c' , 'РегистрСведений.СтатусыКартыPrivilege') }} --[1c]._InfoRg24231 -- РегистрСведений.СтатусыКартыPrivilege
)
select Период,
Покупатель,
СуммаВыкупа,
СуммаОтказов,
ПроцентВыкупа,
Статус,
ЗаказаноCущественныхТоваров,
СтатусКарты,
СуммаВыкупаДляДР
from datesort
where RowNum = 1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
select indi.customer_id--,
-- indi.redeem_percentage,
-- indi.redeem_amount,
-- indi.cancelled_orders_amount,
-- indi.ordered_basic_goods_qty
from clickhouse.cifra.ct_privilege_cards__calculated_indicators as indi
WHERE NOT EXISTS
(SELECT dbt_statuses."покупатель" --,
-- dbt_statuses."процентвыкупа",
-- dbt_statuses."суммавыкупа",
-- dbt_statuses."суммаотказов",
-- dbt_statuses."заказаноcущественныхтоваров"
from cifratest.dbt_stage."dm_stage_регистрсведений_статусыкартprivilege" as dbt_statuses
where indi.customer_id = dbt_statuses."покупатель"
and indi.redeem_percentage = dbt_statuses."процентвыкупа"
and indi.redeem_amount = dbt_statuses."суммавыкупа"
and indi.cancelled_orders_amount = dbt_statuses."суммаотказов"
and indi.ordered_basic_goods_qty = dbt_statuses."заказаноcущественныхтоваров"
)
limit 10
SQL Error [131079]: Query failed (#20220305_145152_00179_pn3tk): Query exceeded per-node memory limit of 307.20MB [Allocated: 303.82MB, Delta: 9.61MB, Top Consumers: {HashAggregationOperator=238.87MB, LazyOutputBuffer=32.47MB, ExchangeOperator=32.47MB}]