<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>recruitment_season_combination_uniq</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description/>
    <extended_description/>
    <pipeline_version/>
    <pipeline_type>Normal</pipeline_type>
    <parameters>
    </parameters>
    <capture_transform_performance>N</capture_transform_performance>
    <transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
    <transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
    <created_user>-</created_user>
    <created_date>2025/03/20 14:06:15.043</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/03/20 14:06:15.043</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Table input (person_registry) регион/осень</from>
      <to>Insert / update (recruitment_campaign.subpoenas)</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Insert / update (recruitment_campaign.subpoenas)</name>
    <type>InsertUpdate</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>100</commit>
    <connection>ervu-dashboard</connection>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruitment_id</field>
        <name>recruitment_id</name>
        <name2/>
      </key>
      <key>
        <condition>=</condition>
        <field>recording_date</field>
        <name>recording_date</name>
        <name2/>
      </key>
      <key>
        <condition>=</condition>
        <field>spring_autumn</field>
        <name>spring_autumn</name>
        <name2/>
      </key>
      <schema>recruitment_campaign</schema>
      <table>subpoenas</table>
      <value>
        <name>recruitment_id</name>
        <rename>recruitment_id</rename>
        <update>N</update>
      </value>
      <value>
        <name>spring_autumn</name>
        <rename>spring_autumn</rename>
        <update>N</update>
      </value>
      <value>
        <name>recording_date</name>
        <rename>recording_date</rename>
        <update>N</update>
      </value>
    </lookup>
    <update_bypassed>N</update_bypassed>
    <attributes/>
    <GUI>
      <xloc>1056</xloc>
      <yloc>320</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table input (person_registry) регион/осень</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>postgres.person_registry</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>WITH ids AS (
    -- Весенние ID
    SELECT unnest(string_to_array(nullif(trim(both '{}' from '${ARR_MC_SP}'), ''), ','))::uuid AS recruitment_id,
           'Весна' AS spring_autumn
    UNION ALL
    -- Осенние ID
    SELECT unnest(string_to_array(nullif(trim(both '{}' from '${ARR_MC_AU}'), ''), ','))::uuid AS recruitment_id,
           'Осень' AS spring_autumn
)
SELECT 
    current_date AS recording_date,
    i.recruitment_id AS recruitment_id,
    i.spring_autumn
FROM ids i;</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>512</xloc>
      <yloc>320</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
