我有一个实木复合地板文件,其中包含许多类型的列converted_type (legacy): TIMESTAMP_MICROS
。我想检查标志isAjustedToUTC
是否为真。我可以这样得到:
import pyarrow.parquet as pq
import re
arrow = pq.ParquetFile("/Parquet/File/Path/filename.parquet")
timestamp_string = str(arrow.metadata.row_group(0).column(79).statistics.logical_type)
re.search("isAdjustedToUTC=(.*), timeUnit",timestamp_string).group(1)
这给了我要么true
或false
作为字符串。是否有另一种isAdjustedToUTC
不用正则表达式来检索值的方法?
据我所知这是不可能的。logical_type
的类型pyarrow._parquet.ParquetLogicalType
不会直接公开其基础成员。
唯一可用的字段是:
dir(logical_type)
>> ['__class__',
'__delattr__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__ne__',
'__new__',
'__pyx_vtable__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__setstate__',
'__sizeof__',
'__str__',
'__subclasshook__',
'to_json',
'type']
您可以使用该to_json
函数,但是它与您建议的选项一样脏:
import json
json.loads(logical_type.to_json())['isAdjustedToUTC']
>> true
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句