Skip to main content
PYSPARK โ€ข LESSON 259

Creating Hive/Spark Managed and External Tables via DDL

How can we create persistent partitioned Parquet tables in the metastore catalog using CREATE TABLE DDL in Spark SQL?

Advancedโฑ 3 Minutesโญ 880 XP
๐Ÿค” THE QUESTION

How can we create persistent partitioned Parquet tables in the metastore catalog using CREATE TABLE DDL in Spark SQL?

๐Ÿ’ก WHAT IS IT?

spark.sql('CREATE TABLE ... USING PARQUET PARTITIONED BY (...)') registers table schemas and partition schemes in the metastore.

๐ŸŽฏ WHAT IS IT USED FOR?

Setting up data lakehouse warehouse schemas for enterprise BI and reporting consumption.

๐Ÿ’ป EXAMPLE
spark.sql("""CREATE TABLE IF NOT EXISTS default.analytics_sales (order_id STRING, customer_id STRING, amount DOUBLE, sale_date DATE) USING PARQUET PARTITIONED BY (sale_date)""")

๐ŸŽฏ Mission Objectives

Practice typing production-grade PySpark code for Creating Hive/Spark Managed and External Tables via DDL.

  • โœ“ CREATE TABLE DDL in Spark SQL
  • โœ“ USING PARQUET storage format
  • โœ“ PARTITIONED BY registration