<?xml version="1.0" encoding="UTF-8"?>
<pipeline>
  <info>
    <name>citizen_education_flow</name>
    <name_sync_with_filename>Y</name_sync_with_filename>
    <description/>
    <extended_description/>
    <pipeline_version/>
    <pipeline_type>Normal</pipeline_type>
    <pipeline_status>0</pipeline_status>
    <parameters>
      <parameter>
        <name>IDM_ID</name>
        <default_value>0e0535ab-5303-43ea-b36a-8c0a2a8d0ed5</default_value>
        <description/>
      </parameter>
      <parameter>
        <name>JOB_NAME</name>
        <default_value>education_test_job</default_value>
        <description/>
      </parameter>
    </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/08/28 08:20:00.808</created_date>
    <modified_user>-</modified_user>
    <modified_date>2025/08/28 08:20:00.808</modified_date>
  </info>
  <notepads>
  </notepads>
  <order>
    <hop>
      <from>change_job_status_on_error_main_upsert</from>
      <to>abort</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Create job execution record</from>
      <to>education_input</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Filter_null_parental_leave_dates</from>
      <to>block_until_main_finished</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>block_until_main_finished</from>
      <to>education_leave_output</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Detect empty stream</from>
      <to>Change job status on success</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>sort_by_recruit_id</from>
      <to>Update</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>education_input</from>
      <to>sort_by_recruit_id</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>education_input</from>
      <to>Filter_null_parental_leave_dates</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>education_input</from>
      <to>sort_by_source_id</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>citizen_education_output</from>
      <to>change_job_status_on_error_main_upsert</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>citizen_education_output</from>
      <to>Filter rows</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>sort_by_source_id</from>
      <to>citizen_education_output</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Update</from>
      <to>change_job_status_on_error_main_upsert</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>education_leave_output</from>
      <to>change_job_status_on_error_main_upsert</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>education_input</from>
      <to>Detect empty stream</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Filter rows</from>
      <to>Unique rows</to>
      <enabled>Y</enabled>
    </hop>
    <hop>
      <from>Unique rows</from>
      <to>Change job status on success</to>
      <enabled>Y</enabled>
    </hop>
  </order>
  <transform>
    <name>Change job status on success</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>Y</execute_each_row>
    <quoteString>N</quoteString>
    <replace_variables>Y</replace_variables>
    <set_params>N</set_params>
    <single_statement>N</single_statement>
    <sql>UPDATE etl.job_execution
SET status = 'SUCCESS',
    execution_end_datetime = current_timestamp
WHERE job_name = '${JOB_NAME}'
and recruitment_id = '${IDM_ID}';

</sql>
    <attributes/>
    <GUI>
      <xloc>1696</xloc>
      <yloc>32</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Create job execution record</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>Y</replace_variables>
    <set_params>N</set_params>
    <single_statement>N</single_statement>
    <sql>INSERT INTO etl.job_execution (id, job_name, status, execution_datetime, error_description, recruitment_id)
VALUES (DEFAULT, '${JOB_NAME}', 'PROCESSING', DEFAULT, null, '${IDM_ID}');

</sql>
    <attributes/>
    <GUI>
      <xloc>208</xloc>
      <yloc>432</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Detect empty stream</name>
    <type>DetectEmptyStream</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <attributes/>
    <GUI>
      <xloc>432</xloc>
      <yloc>32</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Filter rows</name>
    <type>FilterRows</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <compare>
      <condition>
        <conditions>
</conditions>
        <function>=</function>
        <leftvalue>last_row</leftvalue>
        <negated>N</negated>
        <operator>-</operator>
        <value>
          <isnull>N</isnull>
          <length>-1</length>
          <name>constant</name>
          <precision>-1</precision>
          <text>Y</text>
          <type>Boolean</type>
        </value>
      </condition>
    </compare>
    <send_true_to>Unique rows</send_true_to>
    <attributes/>
    <GUI>
      <xloc>1696</xloc>
      <yloc>320</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Filter_null_parental_leave_dates</name>
    <type>FilterRows</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <compare>
      <condition>
        <conditions>
</conditions>
        <function>IS NOT NULL</function>
        <leftvalue>academ_reason</leftvalue>
        <negated>N</negated>
        <operator>-</operator>
      </condition>
    </compare>
    <send_true_to>block_until_main_finished</send_true_to>
    <attributes/>
    <GUI>
      <xloc>704</xloc>
      <yloc>432</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Update</name>
    <type>Update</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>10000</commit>
    <connection>ervu-dashboard</connection>
    <error_ignored>N</error_ignored>
    <lookup>
      <key>
        <condition>=</condition>
        <field>recruit_id</field>
        <name>recruit_id</name>
      </key>
      <schema>ervu_dashboard</schema>
      <table>citizen</table>
      <value>
        <name>has_educational_institution_info</name>
        <rename>has_educational_institution_info</rename>
      </value>
    </lookup>
    <skip_lookup>N</skip_lookup>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>1120</xloc>
      <yloc>544</yloc>
    </GUI>
  </transform>
  <transform>
    <name>abort</name>
    <type>Abort</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <abort_option>ABORT</abort_option>
    <always_log_rows>Y</always_log_rows>
    <row_threshold>0</row_threshold>
    <attributes/>
    <GUI>
      <xloc>1696</xloc>
      <yloc>448</yloc>
    </GUI>
  </transform>
  <transform>
    <name>block_until_main_finished</name>
    <type>BlockUntilTransformsFinish</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <transforms>
      <transform>
        <name>citizen_education_output</name>
      </transform>
    </transforms>
    <attributes/>
    <GUI>
      <xloc>928</xloc>
      <yloc>432</yloc>
    </GUI>
  </transform>
  <transform>
    <name>change_job_status_on_error_main_upsert</name>
    <type>ExecSql</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <arguments>
      <argument>
        <name>error_description</name>
      </argument>
    </arguments>
    <connection>ervu-dashboard</connection>
    <execute_each_row>Y</execute_each_row>
    <quoteString>N</quoteString>
    <replace_variables>Y</replace_variables>
    <set_params>Y</set_params>
    <single_statement>N</single_statement>
    <sql>UPDATE etl.job_execution
SET status = 'ERROR',
    error_description = ?
WHERE job_name = '${JOB_NAME}' 
and recruitment_id = '${IDM_ID}';

</sql>
    <attributes/>
    <GUI>
      <xloc>1456</xloc>
      <yloc>448</yloc>
    </GUI>
  </transform>
  <transform>
    <name>citizen_education_output</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>10000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
      <field>
        <column_name>source_id</column_name>
        <stream_name>source_id</stream_name>
      </field>
      <field>
        <column_name>recruit_id</column_name>
        <stream_name>recruit_id</stream_name>
      </field>
      <field>
        <column_name>source_update_date</column_name>
        <stream_name>source_update_date</stream_name>
      </field>
      <field>
        <column_name>educational_institution_type</column_name>
        <stream_name>educational_institution_type</stream_name>
      </field>
      <field>
        <column_name>org_type</column_name>
        <stream_name>org_type</stream_name>
      </field>
      <field>
        <column_name>inn</column_name>
        <stream_name>inn</stream_name>
      </field>
      <field>
        <column_name>kpp</column_name>
        <stream_name>kpp</stream_name>
      </field>
      <field>
        <column_name>ogrn</column_name>
        <stream_name>ogrn</stream_name>
      </field>
      <field>
        <column_name>educational_institution_address</column_name>
        <stream_name>educational_institution_address</stream_name>
      </field>
      <field>
        <column_name>educational_organization_separate_unit_type</column_name>
        <stream_name>educational_organization_separate_unit_type</stream_name>
      </field>
      <field>
        <column_name>educational_organization_separate_unit_address</column_name>
        <stream_name>educational_organization_separate_unit_address</stream_name>
      </field>
      <field>
        <column_name>student_status</column_name>
        <stream_name>student_status</stream_name>
      </field>
      <field>
        <column_name>grade_number</column_name>
        <stream_name>grade_number</stream_name>
      </field>
      <field>
        <column_name>education_level_code</column_name>
        <stream_name>education_level_code</stream_name>
      </field>
      <field>
        <column_name>admission_date</column_name>
        <stream_name>admission_date</stream_name>
      </field>
      <field>
        <column_name>enrollment_date</column_name>
        <stream_name>enrollment_date</stream_name>
      </field>
      <field>
        <column_name>enrollment_order_number</column_name>
        <stream_name>enrollment_order_number</stream_name>
      </field>
      <field>
        <column_name>enrollment_order_date</column_name>
        <stream_name>enrollment_order_date</stream_name>
      </field>
      <field>
        <column_name>completion_date</column_name>
        <stream_name>completion_date</stream_name>
      </field>
      <field>
        <column_name>education_form</column_name>
        <stream_name>education_form</stream_name>
      </field>
      <field>
        <column_name>education_program_start_date</column_name>
        <stream_name>education_program_start_date</stream_name>
      </field>
      <field>
        <column_name>education_start_date</column_name>
        <stream_name>education_start_date</stream_name>
      </field>
      <field>
        <column_name>planned_completion_date</column_name>
        <stream_name>planned_completion_date</stream_name>
      </field>
      <field>
        <column_name>minobr_speciality_code</column_name>
        <stream_name>minobr_speciality_code</stream_name>
      </field>
      <field>
        <column_name>minprosv_speciality_code</column_name>
        <stream_name>minprosv_speciality_code</stream_name>
      </field>
      <field>
        <column_name>recovery_info</column_name>
        <stream_name>recovery_info</stream_name>
      </field>
      <field>
        <column_name>recovery_date</column_name>
        <stream_name>recovery_date</stream_name>
      </field>
      <field>
        <column_name>recovery_order_date</column_name>
        <stream_name>recovery_order_date</stream_name>
      </field>
      <field>
        <column_name>recovery_order_number</column_name>
        <stream_name>recovery_order_number</stream_name>
      </field>
      <field>
        <column_name>expulsion_info</column_name>
        <stream_name>expulsion_info</stream_name>
      </field>
      <field>
        <column_name>expulsion_date</column_name>
        <stream_name>expulsion_date</stream_name>
      </field>
      <field>
        <column_name>expulsion_order_date</column_name>
        <stream_name>expulsion_order_date</stream_name>
      </field>
      <field>
        <column_name>expulsion_order_number</column_name>
        <stream_name>expulsion_order_number</stream_name>
      </field>
      <field>
        <column_name>academical_leave_info</column_name>
        <stream_name>academical_leave_info</stream_name>
      </field>
      <field>
        <column_name>first_education</column_name>
        <stream_name>first_education</stream_name>
      </field>
      <field>
        <column_name>vus_spec</column_name>
        <stream_name>vus_spec</stream_name>
      </field>
      <field>
        <column_name>military_center_education_info</column_name>
        <stream_name>military_center_education_info</stream_name>
      </field>
      <field>
        <column_name>military_center_education_start_date</column_name>
        <stream_name>military_center_education_start_date</stream_name>
      </field>
      <field>
        <column_name>military_center_education_end_date</column_name>
        <stream_name>military_center_education_end_date</stream_name>
      </field>
      <field>
        <column_name>military_center_education_period</column_name>
        <stream_name>military_center_education_period</stream_name>
      </field>
      <field>
        <column_name>military_center_completion</column_name>
        <stream_name>military_center_completion</stream_name>
      </field>
      <field>
        <column_name>military_department_education_info</column_name>
        <stream_name>military_department_education_info</stream_name>
      </field>
      <field>
        <column_name>military_department_start_date</column_name>
        <stream_name>military_department_start_date</stream_name>
      </field>
      <field>
        <column_name>military_department_end_date</column_name>
        <stream_name>military_department_end_date</stream_name>
      </field>
      <field>
        <column_name>educational_institution_name</column_name>
        <stream_name>educational_institution_name</stream_name>
      </field>
      <field>
        <column_name>educational_institution_status_code</column_name>
        <stream_name>educational_institution_status_code</stream_name>
      </field>
    </fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>educational_institution_learning</table>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>1120</xloc>
      <yloc>320</yloc>
    </GUI>
  </transform>
  <transform>
    <name>education_input</name>
    <type>TableInput</type>
    <description/>
    <distribute>N</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <connection>ervu-dashboard</connection>
    <execute_each_row>N</execute_each_row>
    <sql>WITH filteredData AS (SELECT ri.recruit_id,
                             education_elem,
                             academ_elem,
                             'Образовательная организация высшего образования' as educational_institution_type,
				 ri.ctid
                      FROM ervu_dashboard.recruits_info ri
                               CROSS JOIN LATERAL jsonb_array_elements(
                              ri.info -> 'svedFL' -> 'svedVUZ' -> 'vuz') AS education_elem
                               LEFT JOIN LATERAL jsonb_array_elements(
                              CASE
                                  WHEN jsonb_typeof(education_elem -> 'svedOtpusk') = 'array'
                                      THEN education_elem -> 'svedOtpusk'
                                  ELSE '[]'::jsonb
                                  END
                                                 ) AS academ_elem ON true
                      WHERE jsonb_typeof(ri.info -> 'svedFL' -> 'svedVUZ' -> 'vuz') = 'array'
                        AND (ri.current_recruitment_id = '${IDM_ID}' or (ri.current_recruitment_id is null and ri.target_recruitment_id = '${IDM_ID}'))

                      union all

                      SELECT ri.recruit_id,
                             education_elem,
                             academ_elem,
                             'Профессиональная образовательная организация' as educational_institution_type,
				 ri.ctid
                      FROM ervu_dashboard.recruits_info ri
                               CROSS JOIN LATERAL jsonb_array_elements(
                              ri.info -> 'svedFL' -> 'svedKolledzh' -> 'kolledzh') AS education_elem
                               LEFT JOIN LATERAL jsonb_array_elements(
                              CASE
                                  WHEN jsonb_typeof(education_elem -> 'svedOtpusk') = 'array'
                                      THEN education_elem -> 'svedOtpusk'
                                  ELSE '[]'::jsonb
                                  END
                                                 ) AS academ_elem ON true
                      WHERE jsonb_typeof(ri.info -> 'svedFL' -> 'svedKolledzh' -> 'kolledzh') = 'array'
                        AND (ri.current_recruitment_id = '${IDM_ID}' or (ri.current_recruitment_id is null and ri.target_recruitment_id = '${IDM_ID}'))

                      union all

                      SELECT ri.recruit_id,
                             education_elem,
                             academ_elem,
                             'Общеобразовательная организация' as educational_institution_type,
 				 ri.ctid
                      FROM ervu_dashboard.recruits_info ri
                               CROSS JOIN LATERAL jsonb_array_elements(
                              ri.info -> 'svedFL' -> 'svedSHkola' -> 'shkola') AS education_elem
                               LEFT JOIN LATERAL jsonb_array_elements(
                              CASE
                                  WHEN jsonb_typeof(education_elem -> 'svedOtpusk') = 'array'
                                      THEN education_elem -> 'svedOtpusk'
                                  ELSE '[]'::jsonb
                                  END
                                                 ) AS academ_elem ON true
                      WHERE jsonb_typeof(ri.info -> 'svedFL' -> 'svedSHkola' -> 'shkola') = 'array'
                        AND (ri.current_recruitment_id = '${IDM_ID}' or (ri.current_recruitment_id is null and ri.target_recruitment_id = '${IDM_ID}')))
SELECT education_elem ->> 'id'                                                                                       AS source_id,
       fd.recruit_id,
       to_date(education_elem ->> 'dataSved', 'YYYY-MM-DD')                                                          as source_update_date,
       educational_institution_type,
       education_elem -> 'svedOrg' ->> 'naimTipOrg'                                                                  as org_type,
       education_elem -> 'svedOrg' ->> 'inn'                                                                         as inn,
       education_elem -> 'svedOrg' ->> 'kpp'                                                                         as kpp,
       coalesce(education_elem -> 'svedOrg' ->> 'ogrn', education_elem -> 'svedOrg' ->>
                                                        'ogrnip')                                                    as ogrn,
       education_elem -> 'svedOrg' ->> 'adresOrg'                                                                    as educational_institution_address,
       education_elem -> 'svedOrg' ->> 'naimOrg'                                                                     as educational_institution_name,
       education_elem -> 'svedOrg' -> 'extend' ->> 'statusOrg'                                                       as educational_institution_status_code,
       education_elem -> 'svedOrg' -> 'extend' ->> 'vidPodrazdOrg'                                                   as educational_organization_separate_unit_type,
       education_elem -> 'svedOrg' -> 'extend' ->> 'adresPodrazdOrg'                                                 as educational_organization_separate_unit_address,
       education_elem ->> 'naimStatus'                                                                               as student_status,
       case
           when educational_institution_type = 'Образовательная организация высшего образования'
               then education_elem ->> 'nomerKursa'
           when educational_institution_type = 'Профессиональная образовательная организация'
               then education_elem -> 'extend' ->> 'klass'
           when educational_institution_type = 'Общеобразовательная организация' then education_elem ->> 'klass'
           end                                                                                                       as grade_number,
       education_elem ->> 'kodUrovObr'                                                                               as education_level_code,
       to_date(coalesce(education_elem -> 'extend' ->> 'dataPostup', education_elem ->> 'dataPostup'),
               'YYYY-MM-DD')                                                                                         as admission_date,
       to_date(education_elem ->> 'dataZachisl', 'YYYY-MM-DD')                                                       as enrollment_date,
       education_elem ->> 'nomPrikazZachisl'                                                                         as enrollment_order_number,
       to_date(education_elem ->> 'dataPrikazZachisl', 'YYYY-MM-DD')                                                 as enrollment_order_date,
       to_date(coalesce(education_elem -> 'extend' ->> 'dataZavershObuch', education_elem ->> 'dataOkonch'),
               'YYYY-MM-DD')                                                                                         as completion_date,
       education_elem -> 'svedObrProg' ->> 'naimFormaObuch'                                                          as education_form,
       to_date(education_elem -> 'svedObrProg' ->> 'dataNachObuch', 'YYYY-MM-DD')                                    as education_program_start_date,
       to_date(education_elem -> 'extend' ->> 'dataNachObuch', 'YYYY-MM-DD')                                         as education_start_date,
       to_date(coalesce(education_elem -> 'svedObrProg' ->> 'planDataOkonch', education_elem ->> 'dataOzhid'),
               'YYYY-MM-DD')                                                                                         as planned_completion_date,
       education_elem -> 'svedObrProg' -> 'svedSpeczMinobr' ->> 'kodSpecz'                                           as minobr_speciality_code,
       education_elem -> 'svedObrProg' -> 'svedSpeczMinprosv' ->> 'kodSpecz'                                         as minprosv_speciality_code,
       coalesce(education_elem ->> 'svedVosst' &lt;&gt; 'null', false)                                                     as recovery_info,
       to_date(education_elem -> 'svedVosst' ->> 'dataVosst', 'YYYY-MM-DD')                                          as recovery_date,
       to_date(education_elem -> 'svedVosst' ->> 'dataPrikazVosst',
               'YYYY-MM-DD')                                                                                         as recovery_order_date,
       education_elem -> 'svedVosst' ->> 'nomPrikazVosst'                                                            as recovery_order_number,
       coalesce(education_elem ->> 'svedOtchisl' &lt;&gt; 'null', false)                                                   as expulsion_info,
       to_date(education_elem -> 'svedOtchisl' ->> 'dataOtchisl', 'YYYY-MM-DD')                                      as expulsion_date,
       to_date(education_elem -> 'svedOtchisl' ->> 'dataPrikazOtchisl',
               'YYYY-MM-DD')                                                                                         as expulsion_order_date,
       education_elem -> 'svedOtchisl' ->> 'nomPrikazOtchisl'                                                        as expulsion_order_number,
       coalesce(education_elem ->> 'svedOtpusk' &lt;&gt; 'null', false)                                                    as academical_leave_info,
       coalesce(education_elem ->> 'prPervObuch' = '1', false)                                                       as first_education,
       coalesce(education_elem -> 'svedObrProg' ->> 'prVUSpecz' = '1', false)                                        as vus_spec,
       coalesce(education_elem ->> 'svedVoenObuch' &lt;&gt; 'null', false)                                                 as military_center_education_info,
       to_date(education_elem -> 'svedVoenObuch' ->> 'dataNach', 'YYYY-MM-DD')                                       as military_center_education_start_date,
       to_date(education_elem -> 'svedVoenObuch' ->> 'dataOkonch',
               'YYYY-MM-DD')                                                                                         as military_center_education_end_date,
       education_elem -> 'svedVoenObuch' -> 'extend' ->> 'srokObuch'                                                 as military_center_education_period,
       coalesce(education_elem -> 'svedVoenObuch' -> 'extend' ->> 'svedUspeshZaverObuch' = '1',
                false)                                                                                               as military_center_completion,
       coalesce(education_elem -> 'extend' ->> 'svedVoenKaf' &lt;&gt; 'null', false)                                       as military_department_education_info,
       to_date(education_elem -> 'extend' -> 'svedVoenKaf' ->> 'dataNach',
               'YYYY-MM-DD')                                                                                         as military_department_start_date,
       to_date(education_elem -> 'extend' -> 'svedVoenKaf' ->> 'dataOkonch',
               'YYYY-MM-DD')                                                                                         as military_department_end_date,
       to_date(academ_elem ->> 'dataNach', 'YYYY-MM-DD')                                                              as academ_start_date,
       to_date(academ_elem ->> 'dataOkonch', 'YYYY-MM-DD')                                                            as academ_end_date,
       academ_elem -> 'naimPrichOtpusk'                                                                              as academ_reason,
	true as has_educational_institution_info,
       fd.ctid = (SELECT max(ctid) FROM filteredData) AS last_row
FROM filteredData fd;</sql>
    <variables_active>Y</variables_active>
    <attributes/>
    <GUI>
      <xloc>432</xloc>
      <yloc>432</yloc>
    </GUI>
  </transform>
  <transform>
    <name>education_leave_output</name>
    <type>TableOutput</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <commit>10000</commit>
    <connection>ervu-dashboard</connection>
    <fields>
      <field>
        <column_name>start_date</column_name>
        <stream_name>academ_start_date</stream_name>
      </field>
      <field>
        <column_name>end_date</column_name>
        <stream_name>academ_end_date</stream_name>
      </field>
      <field>
        <column_name>reason</column_name>
        <stream_name>academ_reason</stream_name>
      </field>
      <field>
        <column_name>educational_institution_learning_source_id</column_name>
        <stream_name>source_id</stream_name>
      </field>
    </fields>
    <ignore_errors>N</ignore_errors>
    <only_when_have_rows>N</only_when_have_rows>
    <partitioning_daily>N</partitioning_daily>
    <partitioning_enabled>N</partitioning_enabled>
    <partitioning_monthly>Y</partitioning_monthly>
    <return_keys>N</return_keys>
    <schema>ervu_dashboard</schema>
    <specify_fields>Y</specify_fields>
    <table>educational_leave</table>
    <tablename_in_field>N</tablename_in_field>
    <tablename_in_table>Y</tablename_in_table>
    <truncate>N</truncate>
    <use_batch>Y</use_batch>
    <attributes/>
    <GUI>
      <xloc>1120</xloc>
      <yloc>432</yloc>
    </GUI>
  </transform>
  <transform>
    <name>sort_by_recruit_id</name>
    <type>SortRows</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <directory>${java.io.tmpdir}</directory>
    <prefix>srt</prefix>
    <sort_size>100000</sort_size>
    <free_memory/>
    <compress>N</compress>
    <compress_variable/>
    <unique_rows>Y</unique_rows>
    <fields>
      <field>
        <name>recruit_id</name>
        <ascending>Y</ascending>
        <case_sensitive>N</case_sensitive>
        <collator_enabled>N</collator_enabled>
        <collator_strength>0</collator_strength>
        <presorted>N</presorted>
      </field>
    </fields>
    <attributes/>
    <GUI>
      <xloc>704</xloc>
      <yloc>544</yloc>
    </GUI>
  </transform>
  <transform>
    <name>sort_by_source_id</name>
    <type>SortRows</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <directory>${java.io.tmpdir}</directory>
    <prefix>srt</prefix>
    <sort_size>100000</sort_size>
    <free_memory/>
    <compress>N</compress>
    <compress_variable/>
    <unique_rows>Y</unique_rows>
    <fields>
      <field>
        <name>source_id</name>
        <ascending>Y</ascending>
        <case_sensitive>N</case_sensitive>
        <collator_enabled>N</collator_enabled>
        <collator_strength>0</collator_strength>
        <presorted>N</presorted>
      </field>
    </fields>
    <attributes/>
    <GUI>
      <xloc>704</xloc>
      <yloc>320</yloc>
    </GUI>
  </transform>
  <transform>
    <name>Unique rows</name>
    <type>Unique</type>
    <description/>
    <distribute>Y</distribute>
    <custom_distribution/>
    <copies>1</copies>
    <partitioning>
      <method>none</method>
      <schema_name/>
    </partitioning>
    <count_field/>
    <count_rows>N</count_rows>
    <error_description/>
    <fields>
      <field>
        <case_insensitive>N</case_insensitive>
        <name>recruit_id</name>
      </field>
    </fields>
    <reject_duplicate_row>N</reject_duplicate_row>
    <attributes/>
    <GUI>
      <xloc>1696</xloc>
      <yloc>160</yloc>
    </GUI>
  </transform>
  <transform_error_handling>
    <error>
      <source_transform>Update</source_transform>
      <target_transform>change_job_status_on_error_main_upsert</target_transform>
      <is_enabled>Y</is_enabled>
      <nr_valuename/>
      <descriptions_valuename/>
      <fields_valuename/>
      <codes_valuename/>
      <max_errors/>
      <max_pct_errors/>
      <min_pct_rows/>
    </error>
    <error>
      <source_transform>citizen_education_output</source_transform>
      <target_transform>change_job_status_on_error_main_upsert</target_transform>
      <is_enabled>Y</is_enabled>
      <nr_valuename/>
      <descriptions_valuename>error_description</descriptions_valuename>
      <fields_valuename/>
      <codes_valuename/>
      <max_errors/>
      <max_pct_errors/>
      <min_pct_rows/>
    </error>
    <error>
      <source_transform>education_leave_output</source_transform>
      <target_transform>change_job_status_on_error_main_upsert</target_transform>
      <is_enabled>Y</is_enabled>
      <nr_valuename/>
      <descriptions_valuename>error_description</descriptions_valuename>
      <fields_valuename/>
      <codes_valuename/>
      <max_errors/>
      <max_pct_errors/>
      <min_pct_rows/>
    </error>
  </transform_error_handling>
  <attributes/>
</pipeline>
