You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/redshift.spec.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ describe('redshift', () => {
11
11
}
12
12
13
13
it('should support qualify condition',()=>{
14
-
letsql=`SELECT sf_account_id, date_trunc('week', date_) as week_id, date_trunc('month', date_) as month_id, Last_VALUE(hermes_health_score IGNORE NULLS) OVER ( partition by sf_account_id, week_id ) as hermes_health_score,
15
-
Last_VALUE(hermes_health_score IGNORE NULLS) OVER ( partition by sf_account_id, month_id ) as hermes_health_score_monthly, row_number() OVER ( PARTITION BY sf_account_id, date_trunc('week', date_)
14
+
letsql=`SELECT sf_account_id, date_trunc('week', date_) as week_id, date_trunc('month', date_) as month_id, Last_VALUE(hermes_health_score) IGNORE NULLS OVER ( partition by sf_account_id, week_id ) as hermes_health_score,
15
+
Last_VALUE(hermes_health_score) IGNORE NULLS OVER ( partition by sf_account_id, month_id ) as hermes_health_score_monthly, row_number() OVER ( PARTITION BY sf_account_id, date_trunc('week', date_)
16
16
ORDER BY date_ desc ) AS o_key_week FROM dwh.dwh_health_score_hermes WHERE date_trunc('month', date_) >= '2023-01-01' Qualify o_key_week = 1`
17
-
expect(getParsedSql(sql)).to.be.equal(`SELECT sf_account_id, date_trunc('week', date_) AS "week_id", date_trunc('month', date_) AS "month_id", Last_VALUE(hermes_health_score IGNORE NULLS) OVER (PARTITION BY sf_account_id, week_id) AS "hermes_health_score", Last_VALUE(hermes_health_score IGNORE NULLS) OVER (PARTITION BY sf_account_id, month_id) AS "hermes_health_score_monthly", row_number() OVER (PARTITION BY sf_account_id, date_trunc('week', date_) ORDER BY date_ DESC) AS "o_key_week" FROM "dwh"."dwh_health_score_hermes" WHERE date_trunc('month', date_) >= '2023-01-01' QUALIFY o_key_week = 1`)
17
+
expect(getParsedSql(sql)).to.be.equal(`SELECT sf_account_id, date_trunc('week', date_) AS "week_id", date_trunc('month', date_) AS "month_id", Last_VALUE(hermes_health_score) IGNORE NULLS OVER (PARTITION BY sf_account_id, week_id) AS "hermes_health_score", Last_VALUE(hermes_health_score) IGNORE NULLS OVER (PARTITION BY sf_account_id, month_id) AS "hermes_health_score_monthly", row_number() OVER (PARTITION BY sf_account_id, date_trunc('week', date_) ORDER BY date_ DESC) AS "o_key_week" FROM "dwh"."dwh_health_score_hermes" WHERE date_trunc('month', date_) >= '2023-01-01' QUALIFY o_key_week = 1`)
`SELECT SUM("id") OVER (PARTITION BY "name" ORDER BY "created_at" ASC RANGE BETWEEN INTERVAL '9 DAYS' PRECEDING AND CURRENT ROW) AS "last10Dmatches" FROM "model1"`
501
501
]
502
502
},
503
+
{
504
+
title: 'window function ignore null',
505
+
sql: [
506
+
`SELECT
507
+
LAST_VALUE(ac_install_date)
508
+
IGNORE NULLS
509
+
OVER (PARTITION BY player_id ORDER BY date DESC) AS ac_install_date
510
+
FROM some_table;`,
511
+
'SELECT LAST_VALUE("ac_install_date") IGNORE NULLS OVER (PARTITION BY "player_id" ORDER BY "date" DESC) AS "ac_install_date" FROM "some_table"'
0 commit comments