1

我正在使用 jaydebeapi 连接到蜂巢。

我想使用 hive 选择 V​​ARCHAR(100) 的前 3 个字符。

我有名为 col1 和 col2 的列。col1 是字符串,col2 是 VARCHAR(100)

当我这样做时,它工作正常:

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)

但是,当我尝试对 col2 执行相同操作时,出现错误:

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)
回溯(最近一次通话最后):
  文件“/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py”,第 537 行,在执行中
    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

在处理上述异常的过程中,又出现了一个异常:

回溯(最近一次通话最后):
  <module> 中的文件“/test_query.py”,第 50 行
    cursor.execute("select substr(col2, 1, 3) from table1")
  文件“/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py”,第 539 行,在执行中
    _handle_sql_exception()
  _handle_sql_exception_jpype 中的文件“/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py”,第 165 行
    reraise(exc_type, exc_info[1], exc_info[2])
  文件“/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py”,第 57 行,在 reraise
    提高 value.with_traceback(tb)
  文件“/usr/local/lib/python3.7/site-packages/jaydebeapi/__init__.py”,第 537 行,在执行中
    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

关于如何解决这个问题的任何想法?

4

0 回答 0