https://slingdata.io logo
suggestion: a new mode:
# sling-help
i
suggestion: a new mode: mode: delete insert (in transaction) : begin; delete from stg.small_dim; insert into stg.small_dim select ... from source; commit; Why? Because DELETE does not block normal SELECT in the same aggressive way as TRUNCATE. If we need to query the STG while ELT is working, in our case it is every 15 minutes . if we need to verify or dbt starts with large transformation it can get locked. to put it in pre hook means the delete is not in transactions. What do you think ?
f
@itamar s can you try to do this in
pre_merge
hook stage +
merge_strategy: insert
?
Copy code
yaml
  target_options:
    merge_strategy: insert
  hooks:
    pre_merge:
      - type: query
        connection: '{target.name}'
        query: delete from {object.full_name}
i
@flarco the pre merge will do it in a transaction ? or the delete or there is a second that there will be no data in the table or if the event will fail after the delete we will stay without data at all. ?
i
great. that will do it 🙂
Hi, tested it. when there is no table, it fails
f
Thanks, i pushed a fix for next release, the
pre_merge
hooks should be applied after table is created. see [commit](https://github.com/slingdata-io/sling-cli/pull/754/changes/7f7e40b56a3d77d1b8baf2e28e78bf4d6d13817f).
i
Thank you 🙏