Skip to content

Delta SQL

Delta Lake registers custom SQL statements (using DeltaSparkSessionExtension to inject DeltaSqlParser with DeltaSqlAstBuilder).

The SQL statements support table of the format delta.`path` (with backticks), e.g. delta.`/tmp/delta/t1` while path is between single quotes, e.g. '/tmp/delta/t1'.

The SQL statements can also refer to a table registered in a metastore.

ALTER TABLE ADD CONSTRAINT

ALTER TABLE table
ADD CONSTRAINT name constraint

Creates a AlterTableAddConstraintStatement

ALTER TABLE DROP CONSTRAINT

ALTER TABLE table
DROP CONSTRAINT (IF EXISTS)? name

Creates a AlterTableDropConstraintStatement

CONVERT TO DELTA

CONVERT TO DELTA table
  (PARTITIONED BY '(' colTypeList ')')?

Executes ConvertToDeltaCommand

DESCRIBE DETAIL

(DESC | DESCRIBE) DETAIL (path | table)

Executes DescribeDeltaDetailCommand

DESCRIBE HISTORY

(DESC | DESCRIBE) HISTORY (path | table)
  (LIMIT limit)?

Executes DescribeDeltaHistoryCommand

GENERATE

GENERATE modeName FOR TABLE table

Executes DeltaGenerateCommand

VACUUM

VACUUM (path | table)
  (RETAIN number HOURS)? (DRY RUN)?

Executes VacuumTableCommand


Last update: 2021-06-12
Back to top