@Billy Wong :
You can overwrite the inferred schema of the table by specifying the schema explicitly when you create the table. You can do this by setting the cloudFiles.schema parameter to the desired schema in the Databricks Delta Lake table properties. To do this, you can follow these steps:
- Drop the existing table using the DROP TABLE command in Databricks.
- Rerun the pipeline with cloudFiles.inferColumnTypes set to true to infer the schema.
- Use the DESCRIBE command to retrieve the schema of the table. You can use this schema to create a new table with the same name and overwrite the schema with the desired schema.
- Create a new table with the same name using the CREATE TABLE command and specifying the cloudFiles.schema parameter with the desired schema. Here's an example:
CREATE TABLE my_table
USING DELTA
LOCATION 'path/to/table'
OPTIONS ('cloudFiles.schema' 'id INT, name STRING, age INT')
In this example, the cloudFiles.schema parameter is set to a string representation of the desired schema, which includes column names and data types.
Note that this will overwrite the existing schema and any data in the table will be read according to the new schema. If you want to remove the table altogether, you can use the DROP TABLE command again.