{% macro conditional_truncate(target_relation, source_relation) %}
DECLARE
    row_count NUMBER;
BEGIN
    SELECT COUNT(*) INTO row_count FROM {{ source_relation }};
    IF row_count > 0 THEN
        EXECUTE IMMEDIATE 'TRUNCATE TABLE ' || '{{ target_relation }}';
    END IF;
END;
{% endmacro %}