Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3 TypeError in contrib.hive.HiveTableTarget.exists() #2323

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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