1

I am using jaydebeapi to connect to hive.

I want to select the first 3 characters of a VARCHAR(100) using hive.

I have columns named col1 and col2. col1 is a string and col2 is a VARCHAR(100)

When I do this, it works fine:

connection = jaydebeapi.connect(class_name, url)
cursor = connection.cursor()
cursor.execute('use db1')
cursor.execute("select substr(col1, 1, 3) from table1")
data = cursor.fetchall()
print(data)

When I try to do the same with col2 however, I get an error:

connection = jaydebeapi.connect(class_name, url)
cursor = connection.cursor()
cursor.execute('use db1')
cursor.execute("select substr(col2, 1, 3) from table1")
data = cursor.fetchall()
print(data)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 537, in execute
    is_rs = self._prep.execute()
jpype._jexception.SQLExceptionPyRaisable: java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.tez.TezTask

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/test_query.py", line 50, in <module>
    cursor.execute("select substr(col2, 1, 3) from table1")
  File "/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 539, in execute
    _handle_sql_exception()
  File "/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 165, in _handle_sql_exception_jpype
    reraise(exc_type, exc_info[1], exc_info[2])
  File "/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 57, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py", line 537, in execute
    is_rs = self._prep.execute()
jaydebeapi.InterfaceError: java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.tez.TezTask

Any ideas on how to solve this?

  • Does Hive have a query tool? Check whether it works with that. Maybe the subst method is not allowed for string? – bastian May 28 '20 at 19:14

0 Answers0