Acehaidrey opened a new pull request #8598:
URL: https://github.com/apache/airflow/pull/8598
With the current implementation of the hive macros encoding the resultant
from the metastore calls, in py2 this returns a string type still but in
python3 encoding forces the representation to be a byte type. See the example
below
```
ahaidrey-078HTD6:incubator-airflow ahaidrey$ python3
Python 3.7.0 (default, Oct 2 2018, 09:20:07)
[Clang 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'apple'
>>> b = a.encode('utf-8')
>>> type(b)
<class 'bytes'>
ahaidrey-078HTD6:~ ahaidrey$ python
Python 2.7.16 (default, Dec 3 2019, 02:03:47)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 'apple'
>>> b = a.encode('utf-8')
>>> type(b)
<type 'str'>
```
The issue with this is that the resultant for example being used by macros
returns a byte type that isn't templatable as a string and breaks the queries
it is used in. What this means is that all the templates need to be written as
something like this:
```
val = "{{ macros.hive.max_partition(table='mytable', schema='myschema',
field='myfield', filter_map={'key1': 'val1'}).decode('utf-8') }}"
```
Requiring from the users end to always decode the value is not the intention
of this method and should use a value that can be returned as is.
This PR is to fix this ordeal. We may be able to just remove the encoding
altogether but it could make things backwards incompatible.
---
Make sure to mark the boxes below before creating PR: [x]
- [x] Description above provides context of the change
- [x] Unit tests coverage for changes (not needed for documentation changes)
- [x] Target Github ISSUE in description if exists (not existing)
- [x] Commits follow "[How to write a good git commit
message](http://chris.beams.io/posts/git-commit/)"
- [x] Relevant documentation is updated including usage instructions.
- [x] I will engage committers as explained in [Contribution Workflow
Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
---
In case of fundamental code change, Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in
[UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
Read the [Pull Request
Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)
for more information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]