Forum Discussion
mrojze
2 years agoHelper II
Add partition to existing Delta Table
I have a Delta table with data. All columns have values. I want to add a partition. Is that possible? or I can only create partitions at creation time? This is what I have tried and the error I...
- 2 years ago
mrojze you can try something like this
CREATE TABLE NewTable
USING delta
PARTITIONED BY (part_1)
AS SELECT *, some_column AS part_1 FROM ExistingTable
or more simpledf = spark.read.table('ExistingTable')
df = df.withColumn('part_1', df.some_column)
df.write.partitionBy('part_1').format('delta').saveAsTable('NewTable')
mrojze
2 years agoHelper II
Thanks. This makes sense now, but what I am trying to do it to save the effort of creating a table manually, especially if the table is wide.
Could I create a partitioned table from another existing table?