Forum Discussion

fabricator1's avatar
fabricator1
Advocate II
2 years ago
Solved

Add or remove column in Lakehouse table

Can I add or remove a column from an existing Lakehouse table? I tried doing that on a lakehouse table (by using notebook), but then the table was not visible in the SQL Endpoint and in the Defaul...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi fabricator1 
    Thanks for using Fabric Community.
    Currently ALTER TABLE command is not supported for tables in Lakehouse and Warehouse. So when you try to modify the table using Spark code it might result in some issues.

     

     


    But as a work around I would suggest the following steps:

    1) I have a table named List in my lakehouse with one of the column named "genre".

     


    2)  Run the below given code by dropping the column required. Create a new table named list1.

     

    3) Delete the original list table from the lakehouse. 


    4) Now run the below code which will create a new table with name as List with the dropped column.



    5) This table can be accessed from the SQL endpoint also.


    Hope this helps. Please let me know if you have any further questions. Glad to help.





  • fabricator1's avatar
    fabricator1
    2 years ago

    I didn't have the time to try this procedure. I started on it, and one thing I noticed was that when creating a table using Notebook, the table name can only have small letters. I guess that's normal.

    I had created the original table using Dataflows Gen 2, and the table name had capital letters.

    Anyway I decided to delete the table and recreate the table using Dataflows Gen 2. For my current purpose, that was okay.

    I hope there will be a feature to add or remove columns in a Lakehouse table without having to delete and recreate the table. I created it as an idea: Microsoft Idea