QuestionQ59

VerifiedPrepare data and use feature engineering in Snowflake

A Data Scientist wants to add extensive fraud analysis to the transactions flowing into a data pipeline. One feature they want to create is the number of transactions a customer performs over periods going back to the last day, last seven days, and last year.

What is the MOST efficient way to build that feature?

Explanation

Window functions perform per-customer analytic aggregations directly in SQL. Partitioning by customer and ordering by transaction time allows time-based window frames to compute rolling totals for the previous day, seven days, and year without transferring the transaction data into Python memory or using an external preprocessing workflow.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!