This section covers DDL operations in Apache Iceberg with Spark. You can execute them using either SQL or the DataFrame API (DataFrameWriterV2), though some DDL features are SQL-only. Examples for both approaches are included.

Creating table

1. Using Spark SQL

 spark.sql(f"""
    CREATE TABLE IF NOT EXISTS ecommerce_db.consumers (
        consumer_id STRING,
        name STRING,
        age INT,
        address STRING,
        email STRING
    )
    USING iceberg
    """)

2. DataFrame API

 spark.sql(f"""
    CREATE TABLE IF NOT EXISTS ecommerce_db.consumers (
        consumer_id STRING,
        name STRING,
        age INT,
        address STRING,
        email STRING
    )
    USING iceberg
    """)

Create a table with partitions

TODO

Use the CREATE TABLE…AS SELECT statement

TODO