- nebula 版本:v2-nightly
- 部署方式:单机compose
- 硬件信息
- 磁盘:SSD
- CPU、内存信息:Intel® Xeon® Gold 6240 CPU @ 2.60GHz、32G
- 问题的具体描述
昨天针对nightly
版本返回数据解析方面的改动,研究了一下新的数据格式,发现当前的fetch返回数据对于所有__NULL__
的数据都会返回为数字0
,在studio中查询可以查询到为__NULL__
,请问一下是否有解决方案?nebula-python
的版本是直接pip下载的。数据如下:
studio查询:
nebula-python返回:
Amber
2
可能代码更新了,服务 docker-compose down -v,然后重新导入数据
你打印的这些东西用的是nebula-python的什么接口?我看代码里对null是有特殊处理的呀:
def as_null(self):
"""
:return: Null
"""
if self._value.getType() == ttypes.Value.NVAL:
return Null(self._value.get_nVal())
raise InvalidValueTypeException("expect NULL type, but is " + self._get_type_name())
class Null(object):
__NULL__ = NullType.__NULL__
NaN = NullType.NaN
BAD_DATA = NullType.BAD_DATA
BAD_TYPE = NullType.BAD_TYPE
ERR_OVERFLOW = NullType.ERR_OVERFLOW
UNKNOWN_PROP = NullType.UNKNOWN_PROP
DIV_BY_ZERO = NullType.DIV_BY_ZERO
OUT_OF_RANGE = NullType.OUT_OF_RANGE
def __init__(self, type):
self._type = type
def __repr__(self):
return NullType._VALUES_TO_NAMES[self._type]
def __eq__(self, other):
return self._type == other._type
我不知道用哪个接口,就是根据resp = self.client.execute('FETCH PROP ON {} {};'.format(which_tag, self._add_quota(tag_info)))
这个反馈回来的值,解析用的是example里面FormatResp.py返回的值,得到的就是这张图:
这里面这个东西就用__dict__
看了下属性,自己写了个解析的小接口,您看有什么现成的接口可以用吗?
记录一下,fetch新返回的数据可以用如下代码解析:
def pre_val(col):
if col.is_empty():
return '__EMPTY__'
elif col.is_null():
return '__NULL__'
elif col.is_bool():
return col.as_bool()
elif col.is_int():
return col.as_int()
elif col.is_double():
return col.as_double()
elif col.is_string():
return col.as_string()
elif col.is_time():
return col.as_time()
elif col.is_date():
return col.as_date()
elif col.is_datetime():
return col.as_datetime()
elif col.is_list():
return col.as_list()
elif col.is_set():
return col.as_set()
elif col.is_map():
return col.as_map()
elif col.is_vertex():
return col.as_node()
elif col.is_edge():
return col.as_relationship()
elif col.is_path():
return col.as_path()
else:
print('ERROR: Type unsupported')
return
def get_fetch(fetch_info, tag_name):
''' return from fetch '''
all_result = {}
for _, node_val in temp_result.items():
for k, v in node_val.propertys(tag_name).items():
all_result[k] = pre_val(v)
return all_result
1 个赞