I have a requirement to set a particular column as primary key while writing a dataframe from pyspark to sql using jdbc. Tried using the function 'createTableColumnTypes'
# Calling the action and writing the results to SQL DB
result.write \
.format("jdbc") \
.mode("overwrite") \
.option("url", jdbcUrl) \
.option('createTableColumnTypes', 'KEY_IDENTIFER_COLUMN VARCHAR(255) NOT NULL PRIMARY KEY') \
.option("dbtable","test") \
.option("user", db_username) \
.option("password", db_password) \
.save()
It fails with an error. Any solutions on how this can be done? Thanks in advance.