Skip to content

Commit

Permalink
Fix Python 3 TypeError in contrib.hive.HiveTableTarget.exists()
Browse files Browse the repository at this point in the history
Closes #1012
  • Loading branch information
Ben Sully committed Jan 9, 2018
1 parent da12e03 commit 8fd2525
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion luigi/contrib/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run_hive(args, check_return_code=True):
if check_return_code and p.returncode != 0:
raise HiveCommandError("Hive command: {0} failed with error code: {1}".format(" ".join(cmd), p.returncode),
stdout, stderr)
return stdout
return stdout.decode('utf-8')


def run_hive_cmd(hivecmd, check_return_code=True):
Expand Down
6 changes: 3 additions & 3 deletions test/contrib/hive_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class HiveTest(unittest.TestCase):
def mock_hive_cmd(self, args, check_return=True):
self.last_hive_cmd = args
self.count += 1
return "statement{0}".format(self.count)
return six.u("statement{0}".format(self.count))

def setUp(self):
self.run_hive_cmd_saved = luigi.contrib.hive.run_hive
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_run_hive_command(self, popen):
# I'm testing this again to check the return codes
# I didn't want to tear up all the existing tests to change how run_hive is mocked
comm = mock.Mock(name='communicate_mock')
comm.return_value = "some return stuff", ""
comm.return_value = six.b("some return stuff"), ""

preturn = mock.Mock(name='open_mock')
preturn.returncode = 0
Expand All @@ -275,7 +275,7 @@ def test_run_hive_command(self, popen):
preturn.returncode = 17
self.assertRaises(luigi.contrib.hive.HiveCommandError, luigi.contrib.hive.run_hive, ["blah", "blah"])

comm.return_value = "", "some stderr stuff"
comm.return_value = six.b(""), "some stderr stuff"
returned = luigi.contrib.hive.run_hive(["blah", "blah"], False)
self.assertEqual("", returned)

Expand Down

0 comments on commit 8fd2525

Please sign in to comment.