How to assign default value in deltalake

Viewed 1106

I have following ddl for customer table

CREATE TABLE customer (
  name string NOT NULL
  ,id string NOT NULL DEFAULT 'No ID'
  ,age INT
) using delta

While creating table in deltalake getting issue with default keyword

Can anyone help me , how to define default value in ddl for deltalake ?

1 Answers

Create delta table does not support DEFAULT keyword :

CREATE [ OR REPLACE ] table_identifier [ ( col_name1 col_type1 [ NOT NULL ] [ GENERATED ALWAYS AS ( generation_expression1 ) ] [ COMMENT col_comment1 ], ... ) ] USING DELTA [ LOCATION ]

This is called generated-column:

id STRING GENERATED ALWAYS AS (CAST('No ID' AS STRING)),
Related