<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>clearing_recruits_from_citizen_table</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/05/20 11:08:52.517</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/05/20 11:08:52.517</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>Dummy (do nothing)</from>
      <to>Copy rows to result</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Dummy (do nothing) 2</from>
      <to>Table input</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Dummy (do nothing) 3</from>
      <to>Execute SQL script delete citizen</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Execute SQL script delete citizen</name>
    <type>ExecSql</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <arguments>
</arguments>
    <connection>ervu-dashboard</connection>
    <execute_each_row>N</execute_each_row>
    <quoteString>N</quoteString>
    <replace_variables>N</replace_variables>
    <set_params>N</set_params>
    <single_statement>N</single_statement>
    <sql>delete from ervu_dashboard.citizen where recruit_id = '${}'</sql>
    <attributes/>
    <GUI>
      <xloc>1648</xloc>
      <yloc>400</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Table input</name>
    <type>TableInput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>ervu-dashboard</connection>
    <execute_each_row>N</execute_each_row>
    <limit>0</limit>
    <sql>WITH
/*
ids AS (
    SELECT unnest(string_to_array(trim(both '{}' from '${ARR_MC}'), ','))::uuid AS recruitment_id
),
*/
citizen AS (
    SELECT 
	    '${RCRT_C}'::uuid AS recruitment_id,
	    unnest(string_to_array(trim(both '{}' 
	    from '${CITIZ_ARR}' 
	    ), ','))::uuid AS recruit_id
),
recruits AS (
	SELECT
		'${RCRT_C}'::uuid AS recruitment_id,
	    unnest(string_to_array(trim(both '{}' 
	    from '${RECR_ARR}' 
	    ), ','))::uuid AS recruit_id	
),
except_result AS (
	SELECT 
		recruit_id,
		recruitment_id 
	FROM citizen
	EXCEPT
	SELECT 
		recruit_id,
		recruitment_id
	FROM recruits
)
SELECT
	recruitment_id AS RECRUITMENT_ID,
	array_agg(recruit_id) AS RECRUITS_ARRAY
FROM except_result
group by recruitment_id</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>960</xloc>
      <yloc>400</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Dummy (do nothing)</name>
    <type>Dummy</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>384</xloc>
      <yloc>240</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Copy rows to result</name>
    <type>RowsToResult</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>576</xloc>
      <yloc>240</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Dummy (do nothing) 2</name>
    <type>Dummy</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>720</xloc>
      <yloc>400</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Dummy (do nothing) 3</name>
    <type>Dummy</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>1328</xloc>
      <yloc>416</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
  </transform_error_handling>
  <attributes/>
</pipeline>
