Skip to content

Instantly share code, notes, and snippets.

@aialenti
Created September 13, 2020 14:04
Show Gist options
  • Save aialenti/a55fc5912018ad9368672a429254a7ca to your computer and use it in GitHub Desktop.
Save aialenti/a55fc5912018ad9368672a429254a7ca to your computer and use it in GitHub Desktop.
# Read the source tables in Parquet format
sales_table = spark.read.parquet("./data/sales_parquet")
'''
SELECT order_id AS the_order_id,
seller_id AS the_seller_id,
num_pieces_sold AS the_number_of_pieces_sold
FROM sales_table
'''
# Execution Plan and show action in one line
sales_table_execution_plan = sales_table.select(
col("order_id").alias("the_order_id"),
col("seller_id").alias("the_seller_id"),
col("num_pieces_sold").alias("the_number_of_pieces_sold")
).show(5, True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment