This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new c78e2a5  Make hive macros py3 compatible (#8598)
c78e2a5 is described below

commit c78e2a5feae15e84b05430cfc5935f0e289fb6b4
Author: Ace Haidrey <[email protected]>
AuthorDate: Tue Jun 16 13:19:41 2020 -0700

    Make hive macros py3 compatible (#8598)
    
    Co-authored-by: Ace Haidrey <[email protected]>
---
 airflow/providers/apache/hive/hooks/hive.py    |  3 ++-
 tests/providers/apache/hive/hooks/test_hive.py | 15 ++++++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/airflow/providers/apache/hive/hooks/hive.py 
b/airflow/providers/apache/hive/hooks/hive.py
index d8b6a16..7134a8c 100644
--- a/airflow/providers/apache/hive/hooks/hive.py
+++ b/airflow/providers/apache/hive/hooks/hive.py
@@ -685,6 +685,7 @@ class HiveMetastoreHook(BaseHook):
                            pairs will be considered as candidates of max 
partition.
         :type filter_map: map
         :return: Max partition or None if part_specs is empty.
+        :rtype: basestring
         """
         if not part_specs:
             return None
@@ -708,7 +709,7 @@ class HiveMetastoreHook(BaseHook):
         if not candidates:
             return None
         else:
-            return max(candidates).encode('utf-8')
+            return max(candidates)
 
     def max_partition(self, schema, table_name, field=None, filter_map=None):
         """
diff --git a/tests/providers/apache/hive/hooks/test_hive.py 
b/tests/providers/apache/hive/hooks/test_hive.py
index 5f56d0a..12d196c 100644
--- a/tests/providers/apache/hive/hooks/test_hive.py
+++ b/tests/providers/apache/hive/hooks/test_hive.py
@@ -363,7 +363,7 @@ class TestHiveMetastoreHook(TestHiveEnvironment):
                 None)
 
         # No partition will be filtered out.
-        self.assertEqual(max_partition, b'value3')
+        self.assertEqual(max_partition, 'value3')
 
     def test_get_max_partition_from_valid_part_specs(self):
         max_partition = \
@@ -372,7 +372,16 @@ class TestHiveMetastoreHook(TestHiveEnvironment):
                  {'key1': 'value3', 'key2': 'value4'}],
                 'key1',
                 self.VALID_FILTER_MAP)
-        self.assertEqual(max_partition, b'value1')
+        self.assertEqual(max_partition, 'value1')
+
+    def test_get_max_partition_from_valid_part_specs_return_type(self):
+        max_partition = \
+            HiveMetastoreHook._get_max_partition_from_part_specs(
+                [{'key1': 'value1', 'key2': 'value2'},
+                 {'key1': 'value3', 'key2': 'value4'}],
+                'key1',
+                self.VALID_FILTER_MAP)
+        self.assertIsInstance(max_partition, str)
 
     
@mock.patch("airflow.providers.apache.hive.hooks.hive.HiveMetastoreHook.get_connection",
                 return_value=[Connection(host="localhost", port="9802")])
@@ -523,7 +532,7 @@ class TestHiveMetastoreHook(TestHiveEnvironment):
                                             table_name=self.table,
                                             field=self.partition_by,
                                             filter_map=filter_map)
-        self.assertEqual(partition, DEFAULT_DATE_DS.encode('utf-8'))
+        self.assertEqual(partition, DEFAULT_DATE_DS)
 
         metastore.get_table.assert_called_with(
             dbname=self.database, tbl_name=self.table)

Reply via email to