UnicodeDecodeError: 'ascii' codec cannot decode byte in position

You may see an error such as the following while downloading Impala query results in CSV format from Hue: "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 49: ordinal not in range(128)". This occurs when the query results contain special characters of non-ASCII encoding.

In CDP, Hue is compatible with Python 2.7.x, but the Tablib library for Hue has been upgraded from 0.10.x to 0.14.x, which is generally used with the Python 3 release. If you try to download Impala query results having special characters in the result set in a CSV format, then the download may fail with the ASCII unicode decode error. To fix this issue, downgrade the Tablib library to 0.12.x as follows:
  1. SSH into the Hue server host.
  2. Change directory to the following:
    cd /opt/cloudera/parcels/CDH-7.x/lib/
  3. Back up the hue directory.
    cp -R hue hue_orginal
  4. Change to the hue directory.
    cd hue
  5. Install the Wheel package using pip.
    ./build/env/bin/pip install wheel
    The Wheel package is used to avoid recompiling your software during every install.
  6. Install the Python Setuptools package for Hue:
    ./build/env/bin/pip install setuptools==44.1.0
  7. Install Tablib version 0.12.1:
    ./build/env/bin/pip install tablib==0.12.1
  8. Go to Cloudera Manager and restart the Hue service.