开始使用免费开始使用

快速充电器负载

机器学习团队希望预测充电器在"下一次会话"中的能耗,以便将电力优先分配给未来可能负载较高的充电器。为训练模型,他们希望您准备一个数据集,包含用户、车辆型号、充电站以及能耗的信息,并且这些信息能够"前瞻"到下一次充电。是时候展示您的实力了!

本练习是课程的一部分

Snowflake 中的 Window Functions

查看课程

练习说明

  • ELECTRIC_VEHICLES.charging 表中检索每条记录的 time_of_daycharging_rateenergy_consumed
  • 使用窗口函数"向前查看",检索下一次充电会话的能耗;若不存在则返回 0
  • charging_station_id 对记录分段,并使用 charging_start_time 以升序创建记录序列。

交互式实操练习

通过完成这段示例代码来试试这个练习。

SELECT
    user_id,
    charging_station_id,
    charging_start_time,
    
    -- Retrieve the time_of_day, charging_rate and energy_consumed fields
	___,
    ___,
    ___,
	
    -- "Look ahead" to the energy consumed in the next session
    ___ OVER(
      
      	-- Segment the records by charging station and sequence
      	-- records by the start time of the charge
        ___
        ___
      
    ) AS next_session_energy_consumed

FROM ELECTRIC_VEHICLES.charging;
编辑并运行代码