Exemplo n.º 1
0
    def test_export_cmd(self):
        """
        Tests to verify the hook export command is building correct Sqoop export command.
        """
        hook = SqoopHook()

        # The subprocess requires an array but we build the cmd by joining on a space
        cmd = ' '.join(
            hook._export_cmd(
                self._config_export['table'],
                self._config_export['export_dir'],
                input_null_string=self._config_export['input_null_string'],
                input_null_non_string=self._config_export[
                    'input_null_non_string'],
                staging_table=self._config_export['staging_table'],
                clear_staging_table=self._config_export['clear_staging_table'],
                enclosed_by=self._config_export['enclosed_by'],
                escaped_by=self._config_export['escaped_by'],
                input_fields_terminated_by=self._config_export[
                    'input_fields_terminated_by'],
                input_lines_terminated_by=self._config_export[
                    'input_lines_terminated_by'],
                input_optionally_enclosed_by=self._config_export[
                    'input_optionally_enclosed_by'],
                batch=self._config_export['batch'],
                relaxed_isolation=self._config_export['relaxed_isolation'],
                extra_export_options=self._config_export['extra_export_options']
            )
        )

        self.assertIn("--input-null-string {}".format(
            self._config_export['input_null_string']), cmd)
        self.assertIn("--input-null-non-string {}".format(
            self._config_export['input_null_non_string']), cmd)
        self.assertIn("--staging-table {}".format(
            self._config_export['staging_table']), cmd)
        self.assertIn("--enclosed-by {}".format(
            self._config_export['enclosed_by']), cmd)
        self.assertIn("--escaped-by {}".format(
            self._config_export['escaped_by']), cmd)
        self.assertIn("--input-fields-terminated-by {}".format(
            self._config_export['input_fields_terminated_by']), cmd)
        self.assertIn("--input-lines-terminated-by {}".format(
            self._config_export['input_lines_terminated_by']), cmd)
        self.assertIn("--input-optionally-enclosed-by {}".format(
            self._config_export['input_optionally_enclosed_by']), cmd)
        # these options are from the extra export options
        self.assertIn("--update-key id", cmd)
        self.assertIn("--update-mode allowinsert", cmd)

        if self._config_export['clear_staging_table']:
            self.assertIn("--clear-staging-table", cmd)

        if self._config_export['batch']:
            self.assertIn("--batch", cmd)

        if self._config_export['relaxed_isolation']:
            self.assertIn("--relaxed-isolation", cmd)
Exemplo n.º 2
0
    def test_export_cmd(self):
        """
        Tests to verify the hook export command is building correct Sqoop export command.
        """
        hook = SqoopHook()

        # The subprocess requires an array but we build the cmd by joining on a space
        cmd = ' '.join(
            hook._export_cmd(
                self._config_export['table'],
                self._config_export['export_dir'],
                input_null_string=self._config_export['input_null_string'],
                input_null_non_string=self._config_export[
                    'input_null_non_string'],
                staging_table=self._config_export['staging_table'],
                clear_staging_table=self._config_export['clear_staging_table'],
                enclosed_by=self._config_export['enclosed_by'],
                escaped_by=self._config_export['escaped_by'],
                input_fields_terminated_by=self._config_export[
                    'input_fields_terminated_by'],
                input_lines_terminated_by=self._config_export[
                    'input_lines_terminated_by'],
                input_optionally_enclosed_by=self._config_export[
                    'input_optionally_enclosed_by'],
                batch=self._config_export['batch'],
                relaxed_isolation=self._config_export['relaxed_isolation'],
                extra_export_options=self._config_export['extra_export_options']
            )
        )

        self.assertIn("--input-null-string {}".format(
            self._config_export['input_null_string']), cmd)
        self.assertIn("--input-null-non-string {}".format(
            self._config_export['input_null_non_string']), cmd)
        self.assertIn("--staging-table {}".format(
            self._config_export['staging_table']), cmd)
        self.assertIn("--enclosed-by {}".format(
            self._config_export['enclosed_by']), cmd)
        self.assertIn("--escaped-by {}".format(
            self._config_export['escaped_by']), cmd)
        self.assertIn("--input-fields-terminated-by {}".format(
            self._config_export['input_fields_terminated_by']), cmd)
        self.assertIn("--input-lines-terminated-by {}".format(
            self._config_export['input_lines_terminated_by']), cmd)
        self.assertIn("--input-optionally-enclosed-by {}".format(
            self._config_export['input_optionally_enclosed_by']), cmd)
        # these options are from the extra export options
        self.assertIn("--update-key id", cmd)
        self.assertIn("--update-mode allowinsert", cmd)

        if self._config_export['clear_staging_table']:
            self.assertIn("--clear-staging-table", cmd)

        if self._config_export['batch']:
            self.assertIn("--batch", cmd)

        if self._config_export['relaxed_isolation']:
            self.assertIn("--relaxed-isolation", cmd)
    def test_export_cmd(self):
        hook = SqoopHook()

        # The subprocess requires an array but we build the cmd by joining on a space
        cmd = ' '.join(
            hook._export_cmd(
                self._config_export['table'],
                self._config_export['export_dir'],
                input_null_string=self._config_export['input_null_string'],
                input_null_non_string=self.
                _config_export['input_null_non_string'],
                staging_table=self._config_export['staging_table'],
                clear_staging_table=self._config_export['clear_staging_table'],
                enclosed_by=self._config_export['enclosed_by'],
                escaped_by=self._config_export['escaped_by'],
                input_fields_terminated_by=self.
                _config_export['input_fields_terminated_by'],
                input_lines_terminated_by=self.
                _config_export['input_lines_terminated_by'],
                input_optionally_enclosed_by=self.
                _config_export['input_optionally_enclosed_by'],
                batch=self._config_export['batch'],
                relaxed_isolation=self._config_export['relaxed_isolation']))

        self.assertIn(
            "--input-null-string {}".format(
                self._config_export['input_null_string']), cmd)
        self.assertIn(
            "--input-null-non-string {}".format(
                self._config_export['input_null_non_string']), cmd)
        self.assertIn(
            "--staging-table {}".format(self._config_export['staging_table']),
            cmd)
        self.assertIn(
            "--enclosed-by {}".format(self._config_export['enclosed_by']), cmd)
        self.assertIn(
            "--escaped-by {}".format(self._config_export['escaped_by']), cmd)
        self.assertIn(
            "--input-fields-terminated-by {}".format(
                self._config_export['input_fields_terminated_by']), cmd)
        self.assertIn(
            "--input-lines-terminated-by {}".format(
                self._config_export['input_lines_terminated_by']), cmd)
        self.assertIn(
            "--input-optionally-enclosed-by {}".format(
                self._config_export['input_optionally_enclosed_by']), cmd)

        if self._config_export['clear_staging_table']:
            self.assertIn("--clear-staging-table", cmd)

        if self._config_export['batch']:
            self.assertIn("--batch", cmd)

        if self._config_export['relaxed_isolation']:
            self.assertIn("--relaxed-isolation", cmd)
Exemplo n.º 4
0
    def test_export_cmd(self):
        hook = SqoopHook()

        # The subprocess requires an array but we build the cmd by joining on a space
        cmd = ' '.join(
            hook._export_cmd(
                self._config_export['table'],
                self._config_export['export_dir'],
                input_null_string=self._config_export['input_null_string'],
                input_null_non_string=self._config_export[
                    'input_null_non_string'],
                staging_table=self._config_export['staging_table'],
                clear_staging_table=self._config_export['clear_staging_table'],
                enclosed_by=self._config_export['enclosed_by'],
                escaped_by=self._config_export['escaped_by'],
                input_fields_terminated_by=self._config_export[
                    'input_fields_terminated_by'],
                input_lines_terminated_by=self._config_export[
                    'input_lines_terminated_by'],
                input_optionally_enclosed_by=self._config_export[
                    'input_optionally_enclosed_by'],
                batch=self._config_export['batch'],
                relaxed_isolation=self._config_export['relaxed_isolation'])
        )

        self.assertIn("--input-null-string {}".format(
            self._config_export['input_null_string']), cmd)
        self.assertIn("--input-null-non-string {}".format(
            self._config_export['input_null_non_string']), cmd)
        self.assertIn("--staging-table {}".format(
            self._config_export['staging_table']), cmd)
        self.assertIn("--enclosed-by {}".format(
            self._config_export['enclosed_by']), cmd)
        self.assertIn("--escaped-by {}".format(
            self._config_export['escaped_by']), cmd)
        self.assertIn("--input-fields-terminated-by {}".format(
            self._config_export['input_fields_terminated_by']), cmd)
        self.assertIn("--input-lines-terminated-by {}".format(
            self._config_export['input_lines_terminated_by']), cmd)
        self.assertIn("--input-optionally-enclosed-by {}".format(
            self._config_export['input_optionally_enclosed_by']), cmd)

        if self._config_export['clear_staging_table']:
            self.assertIn("--clear-staging-table", cmd)

        if self._config_export['batch']:
            self.assertIn("--batch", cmd)

        if self._config_export['relaxed_isolation']:
            self.assertIn("--relaxed-isolation", cmd)