Python 配置单元字符串函数使用VARCHAR失败,但使用字符串

Python 配置单元字符串函数使用VARCHAR失败,但使用字符串,python,hadoop,hive,apache-tez,jaydebeapi,Python,Hadoop,Hive,Apache Tez,Jaydebeapi,我正在使用jaydebeapi连接到蜂巢 我想使用配置单元选择VARCHAR(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

我正在使用jaydebeapi连接到蜂巢

我想使用配置单元选择VARCHAR(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行,在execute中 is_rs=self._prep.execute() jpype.\u jexception.SQLExceptionPyRaisable:java.sql.SQLException:处理语句时出错:失败:执行错误,从org.apache.hadoop.hive.ql.exec.tez.TezTask返回代码1 在处理上述异常期间,发生了另一个异常: 回溯(最近一次呼叫最后一次): 文件“/test_query.py”,第50行,在 execute(“从表1中选择substr(col2,1,3)) 文件“/usr/local/lib/python3.7/site packages/jaydebeapi/_init__.py”,第539行,在execute中 _句柄\u sql\u异常() 文件“/usr/local/lib/python3.7/site packages/jaydebeapi/_init__.py”,第165行,在_handle_sql_exception_jpype中 重新发布(exc_类型、exc_信息[1]、exc_信息[2]) 文件“/usr/local/lib/python3.7/site packages/jaydebeapi/_init__.py”,第57行,在reraise中 通过_回溯(tb)提升值 文件“/usr/local/lib/python3.7/site packages/jaydebeapi/_init__.py”,第537行,在execute中 is_rs=self._prep.execute() jaydebeapi.interface错误:java.sql.SQLException:处理语句时出错:失败:执行错误,从org.apache.hadoop.hive.ql.exec.tez.TezTask返回代码1
有什么办法解决这个问题吗?

Hive有查询工具吗?检查它是否与此配合使用。可能字符串不允许使用subst方法?配置单元是否有查询工具?检查它是否与此配合使用。可能字符串不允许使用subst方法? 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