From 488152492ab1f5d5e5332da415382e604f1afb71 Mon Sep 17 00:00:00 2001 From: Abhishek Kapatkar Date: Wed, 18 Mar 2020 17:23:18 -0700 Subject: [PATCH] Append ; after new line for presto scripts as last line could be a comment --- pygenie/jobs/presto.py | 3 ++- tests/job_tests/test_prestojob.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pygenie/jobs/presto.py b/pygenie/jobs/presto.py index 8ee03a5..c05224a 100644 --- a/pygenie/jobs/presto.py +++ b/pygenie/jobs/presto.py @@ -70,7 +70,8 @@ def cmd_args(self): self._add_dependency(self._script) elif self._script is not None: if not self._script.strip().endswith(';'): - self._script = '{};'.format(self._script) + #\n ensures if the script ends with a comment ; still gets applied + self._script = '{}\n;'.format(self._script) self._add_dependency({'name': filename, 'data': self._script}) options_str = ' '.join([ diff --git a/tests/job_tests/test_prestojob.py b/tests/job_tests/test_prestojob.py index dbdc1ab..27d04ac 100644 --- a/tests/job_tests/test_prestojob.py +++ b/tests/job_tests/test_prestojob.py @@ -242,7 +242,7 @@ def test_genie2_payload_adhoc_script(self, os_isfile, to_att): u'attachments': [ {u'name': u'prestofile1', u'data': u'file contents'}, {u'name': u'prestofile2', u'data': u'file contents'}, - {u'name': u'script.presto', u'data': u'SELECT * FROM DUAL;'} + {u'name': u'script.presto', u'data': u'SELECT * FROM DUAL\n;'} ], u'clusterCriterias': [ {u'tags': [u'type:prestocluster1']}, @@ -351,7 +351,7 @@ def test_genie3_payload_adhoc_script(self, os_isfile, file_open): u'attachments': [ (u'prestofile1', u"open file '/prestofile1'"), (u'prestofile2', u"open file '/prestofile2'"), - (u'script.presto', u'SELECT * FROM DUAL;') + (u'script.presto', u'SELECT * FROM DUAL\n;') ], u'clusterCriterias': [ {u'tags': [u'type:prestocluster1']},