Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 21, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/bc8992d9b1a817b7b39b9f4cabae2795 to your computer and use it in GitHub Desktop.
Save 1ambda/bc8992d9b1a817b7b39b9f4cabae2795 to your computer and use it in GitHub Desktop.
df.createOrReplaceTempView("PURCHASE")
spark.sql("""
    SELECT *
    FROM PURCHASE
    LIMIT 10
""").show()
+--------------------+----------------+----------+-------------------+-------------+--------+------+---------+--------------------+
| event_time| event_type|product_id| category_id|category_code| brand| price| user_id| user_session|
+--------------------+----------------+----------+-------------------+-------------+--------+------+---------+--------------------+
|2020-01-01 00:00:...| view| 5809910|1602943681873052386| null| grattol| 5.24|595414620|4adb70bb-edbd-498...|
|2020-01-01 00:00:...| view| 5812943|1487580012121948301| null|kinetics| 3.97|595414640|c8c5205d-be43-4f1...|
|2020-01-01 00:00:...| view| 5798924|1783999068867920626| null| zinger| 3.97|595412617|46a5010f-bd69-4fb...|
|2020-01-01 00:00:...| view| 5793052|1487580005754995573| null| null| 4.92|420652863|546f6af3-a517-475...|
|2020-01-01 00:00:...| view| 5899926|2115334439910245200| null| null| 3.92|484071203|cff70ddf-529e-4b0...|
|2020-01-01 00:00:...| view| 5837111|1783999068867920626| null| staleks| 6.35|595412617|46a5010f-bd69-4fb...|
|2020-01-01 00:00:...| cart| 5850281|1487580006300255120| null|marathon|137.78|593016733|848f607c-1d14-474...|
|2020-01-01 00:00:...| view| 5802440|2151191070908613477| null| null| 2.16|595411904|74ca1cd5-5381-4ff...|
|2020-01-01 00:00:...| view| 5726464|1487580005268456287| null| null| 5.56|420652863|546f6af3-a517-475...|
|2020-01-01 00:01:...|remove_from_cart| 5850281|1487580006300255120| null|marathon|137.78|593016733|848f607c-1d14-474...|
+--------------------+----------------+----------+-------------------+-------------+--------+------+---------+--------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment