samuelperezh
08/13/2025, 11:24 PMsling = Sling(
src_stream=source_path,
src_options={
"format": "csv",
"header": True,
"compression": "gzip"
},
tgt_conn="BIGQUERY",
tgt_object=target_table,
tgt_options={
"use_bulk": True,
"add_new_columns": True,
"adjust_column_type": True,
"delete_missing": "soft"
},
mode="incremental",
primary_key=["vin", "source"],
update_key="scraped_at",
debug=True
)
But it doesn't work, Sling never adds _sling_deleted_at. From the docs, I see delete_missing mentioned in db to db incremental mode, but not in the file to db incremental examples. However, in reality what the pipeline is doing is creating a temp table in BigQuery and then upserting, it makes sense to have the _sling_deleted_at column in this case.
I appreciate your help!flarco
08/13/2025, 11:28 PMsamuelperezh
08/13/2025, 11:58 PMsamuelperezh
08/14/2025, 12:00 AMflarco
08/14/2025, 2:24 AMflarco
08/14/2025, 10:15 AMflarco
08/14/2025, 10:21 AMflarco
08/14/2025, 10:31 AMfile stream using incremental_val, so sling is filtering, but stills download the full files, and then filtering in-process. So the unfiltered PK values could be cached somewhere to use for delete_missing 🤔. A bit tricky though.samuelperezh
08/14/2025, 4:10 PMsamuelperezh
08/14/2025, 8:58 PMproject.dataset.table AS tgt
USING (
SELECT * EXCEPT(_sling_loaded_at)
FROM project.dataset.table_tmp
WHERE load_date = @run_date
) AS src
ON tgt.vin = src.vin AND tgt.source = src.source
WHEN MATCHED THEN
UPDATE SET
scraped_at = GREATEST(tgt.scraped_at, src.scraped_at),
/* ... other columns ... */
_sling_deleted_at = NULL
WHEN NOT MATCHED BY TARGET THEN
INSERT (vin,source,scraped_at,/*...*/, _sling_deleted_at)
VALUES (src.vin, src.source, src.scraped_at, /*...*/, NULL)
WHEN NOT MATCHED BY SOURCE THEN
UPDATE SET _sling_deleted_at = CURRENT_TIMESTAMP();flarco
08/14/2025, 10:33 PMproject.dataset.table_tmp has the full datasetflarco
08/14/2025, 10:50 PMfull-refresh mode, into a separate table (project.dataset.table_full), and then run a [post-hook query](https://docs.slingdata.io/concepts/hooks/query) of what you've suggested above (merge into project.dataset.table), and then drop project.dataset.table_full. You'd just have to manually add the _sling_deleted_at column one time on project.dataset.table.flarco
08/14/2025, 11:01 PMReplicationStream python class though, see [here](https://docs.slingdata.io/examples/sling-python#build-a-replication-dynamically), let me know if you have issues. Or use YAML :
from sling import Replication
replication = Replication(file_path="path/to/replication.yaml")
replication.run()