Anonymous
Not applicable

@Mohammad Saber​ : can you check out - https://www.dbdemos.ai/

also giving you some code -

# Import necessary libraries
from delta import DeltaTable
from pyspark.sql.functions import *
 
# Define the Delta Lake table path
table_path = "/mnt/delta/my_table"
 
# Load data into a Spark DataFrame
df = spark.read.format("csv").option("header", "true").load("/mnt/my_data.csv")
 
# Filter the data to only include rows with a certain value
df_filtered = df.filter(col("my_column") == "my_value")
 
# Create a DeltaTable object for the table
delta_table = DeltaTable.forPath(spark, table_path)
 
# Check if the table exists and create it if it doesn't
if not DeltaTable.isDeltaTable(spark, table_path):
    delta_table.create(
        df_filtered.schema,
        partitionBy="my_column"
    )
 
# Insert the filtered data into the table
delta_table.alias("t").merge(
    df_filtered.alias("s"),
    "t.my_column = s.my_column"
).whenNotMatchedInsertAll().execute()

In this example, we first load some data into a Spark DataFrame and filter it to only include rows with a certain value. We then create a DeltaTable object for the DLT table at the specified path and check if it exists. If the table doesn't exist, we create it with the schema of the filtered DataFrame and partition it by a column. Finally, we use the DeltaTable merge() function to insert the filtered data into the table. The merge() function performs an upsert operation, updating rows that match a given condition and inserting rows that don't. In this case, we're using the my_column column as the merge condition, which means that if a row with the same value of my_column already exists in the table, it will be updated with the values from the filtered DataFrame, and if it doesn't exist, a new row will be inserted.