開始使用免費開始

運用微分割與資料叢集

你在走廊上和資深資料工程師簡短聊到,她告訴你 Snowflake 正使用資料叢集,依照 olympic_medals 資料表中的 year 欄位來在微分割中排序資料。你有幾個經常對這個資料表執行的查詢,現在想更新它們,以更充分利用 Snowflake 的微分割與資料叢集。

已經從 sqlalchemy 模組匯入 create_engine 函式,並已建立連線物件存放在變數 conn

本練習屬於課程

NoSQL 入門

檢視課程

練習說明

  • 更新 Snowflake 查詢,只回傳在 2000 年之後舉辦的賽事紀錄。
  • 將 Snowflake 查詢結果回傳為 pandasDataFrame,並列印結果集。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Leverage the existing micro-partitions and data clustering
query = """
SELECT
	team,
    year,
    sport,
    event,
    medal
FROM olympic_medals
____ year >= ____;
"""

# Execute the query, print the results
results = conn.cursor().____(query).fetch_pandas_all()
print(____)
編輯並執行程式碼