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:
SSH into the Hue server host.
Change directory to the following:
cd /opt/cloudera/parcels/CDH-7.x/lib/
Back up the
hue
directory.
cp -R hue hue_orginal
Change to the hue directory.
cd hue
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.
Install the Python Setuptools package for Hue:
./build/env/bin/pip install setuptools==44.1.0
Install Tablib version 0.12.1:
./build/env/bin/pip install tablib==0.12.1
Update the permissions of the Tablib library and other packages that were
installed during the process by using the following command:
chmod 0755 [***TABLIB-LIBRARY-NAME***]
Go to Cloudera Manager and restart the Hue service.