使用ibis python向impala表插入数据

deikduxw  于 2021-06-26  发布在  Impala
关注(0)|答案(2)|浏览(626)

我正在尝试将df插入到ibis创建的带有分区的impala表中。我在远程内核上运行它,在windows10机器上使用spyder3.2.4,在运行centos的边缘节点机器上使用python3.6.2。
我得到以下错误:

Writing DataFrame to temporary file
Writing CSV to: /tmp/ibis/pandas_0032f9dd1916426da62c8b4d8f4dfb92/0.csv
Traceback (most recent call last):

File "/usr/local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in 
insert = target_table.insert(df3)

File "/usr/local/lib/python3.6/site-packages/ibis/impala/client.py", line 1674, in insert
writer, expr = write_temp_dataframe(self._client, obj)

File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 225, in write_temp_dataframe
return writer, writer.delimited_table(path)

File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 188, in delimited_table
schema = self.get_schema()

File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 184, in get_schema
return pandas_to_ibis_schema(self.df)

File "/usr/local/lib/python3.6/site-packages/ibis/impala/pandas_interop.py", line 219, in pandas_to_ibis_schema
return schema(pairs)

File "/usr/local/lib/python3.6/site-packages/ibis/expr/api.py", line 105, in schema
return Schema.from_tuples(pairs)

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 109, in from_tuples
return Schema(names, types)

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 55, in init
self.types = [validate_type(typ) for typ in types]

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 55, in 
self.types = [validate_type(typ) for typ in types]

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 1040, in validate_type
return TypeParser(t).parse()

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 901, in parse
t = self.type()

File "/usr/local/lib/python3.6/site-packages/ibis/expr/datatypes.py", line 1033, in type
raise SyntaxError('Type cannot be parsed: {}'.format(self.text))

File "", line unknown
SyntaxError: Type cannot be parsed: integer
6ljaweal

6ljaweal1#

而不是编辑前面提到的config\u init.py
https://stackoverflow.com/a/47543691/5485370
使用ibis选项更容易分配临时数据库和路径:

ibis.options.impala.temp_db = 'your_temp_db'
ibis.options.impala.temp_hdfs_path = 'your_temp_hdfs_path'
u1ehiz5o

u1ehiz5o2#

由于hadoop系统的结构和安全性,出现了错误。ibis包尝试分别在ibis\u tmp和/tmp/ibis/中创建temp\u db和temp\u hdfs\u位置。因为在我们的系统中,除了根/系统管理员之外,默认位置不向任何用户开放。。。insert命令在从/tmp/ibis/获取数据到实际数据库时出错(仍然不清楚,但可能是通过\uibis\utmpdbase)。一旦我们将ibis包的config\u init.py文件编辑到允许的temp location/db。它起了很大的作用。

相关问题