Forum Discussion

spartan27244's avatar
spartan27244
Resolver I
1 year ago
Solved

Why doesn't my onelake table support updates?

I am creating my tables using a PySpark notebook, but I am unable to use SQL to update values in the table. I thought these tables supported updates, deletes, etc.    tables are created like so d...
  • Gpop13's avatar
    1 year ago

    Hi spartan27244 The SQL endpoints in Microsoft Fabric are read-only when connected to a Lakehouse.

    (SQL Endpoints are readonly)
    To update data in a Lakehouse table in Microsoft Fabric, you cannot use SQL directly, but you can do it using a notebook (typically PySpark)
    Something like this:
    df = spark.read.format("delta").load("Tables/your_table")
    df_updated = df.withColumn("status",when(col("user_id") == 123, "active").otherwise(col("status")))
    df_updated.write.format("delta").mode("overwrite").save("Tables/your_table")