Set NOT NULL columns in koalas to_table

89 Views Asked by At

when I create a Delta table I can set some columns to be NOT NULL

CREATE TABLE [db_name.]table_name
  [(col_name1 col_type1 [NOT NULL], ...)]
  USING DELTA

Is there any way to set non null columns with koalas.to_table?

1

There are 1 best solutions below

0
On

It's not possible to do directly from koalas.to_table, but you can use ALTER TABLE statement to add the constraint after you wrote the data (full docs):

ALTER TABLE <table_name> CHANGE COLUMN <col_name> SET NOT NULL;

(for example, via spark.sql command)