/usr/local/lib64/python3.6/site-packages/pyarrow/__pycache__
NameSizeModeActions
benchmark.cpython-36.pyc2080644editdlrm
cffi.cpython-36.pyc14820644editdlrm
compat.cpython-36.pyc3810644editdlrm
compute.cpython-36.pyc202630644editdlrm
csv.cpython-36.pyc3820644editdlrm
cuda.cpython-36.pyc4050644editdlrm
dataset.cpython-36.pyc279700644editdlrm
feather.cpython-36.pyc77390644editdlrm
filesystem.cpython-36.pyc144020644editdlrm
flight.cpython-36.pyc13530644editdlrm
fs.cpython-36.pyc103950644editdlrm
hdfs.cpython-36.pyc70550644editdlrm
ipc.cpython-36.pyc73940644editdlrm
json.cpython-36.pyc2310644editdlrm
jvm.cpython-36.pyc80350644editdlrm
orc.cpython-36.pyc51400644editdlrm
pandas_compat.cpython-36.pyc276950644editdlrm
parquet.cpython-36.pyc666090644editdlrm
plasma.cpython-36.pyc40690644editdlrm
serialization.cpython-36.pyc137370644editdlrm
types.cpython-36.pyc120830644editdlrm
util.cpython-36.pyc41500644editdlrm
_generated_version.cpython-36.pyc2230644editdlrm
__init__.cpython-36.pyc164760644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/pyarrow/__pycache__/parquet.cpython-36.pyc (66609B)
3 8%Egd/d0Z?d1d2Z@d3hZAGd4d5d5ZBdcd6d7ZCd8ZDd9ZEGd:d;d;ZFddd>d?ZGd@dAZHGdBdCdCZIdDZJdedGdHZKeJjLdIdJjMeEdKfdLe/eK_NdfdMdNZOeJjLdOdJjMeEdPfdQe/eO_NdgdTdUZPdVjLe7eP_NdWdXZQdhdYdZZRdid[d\ZSdjd]d^ZTdkd_d`ZUdS)l) defaultdict)futures)partialreduceN) Collection) ParquetReader Statistics FileMetaDataRowGroupMetaDataColumnChunkMetaData ParquetSchema ColumnSchema)LocalFileSystem FileSystem_resolve_filesystem_and_path_ensure_filesystem) filesystem)guid _is_path_like_stringify_pathhdfscCs,t|}tjj|}|jtkr$|jS|SdS)N)rurllibparseurlparsescheme_URI_STRIP_SCHEMESpath)rZ parsed_urir;/usr/local/lib64/python3.6/site-packages/pyarrow/parquet.py _parse_uri0s   rcCs2|dkrtj||Stj|}t|}||fSdS)N)legacyfsresolve_filesystem_and_pathrr)Zpassed_filesystemrZ parsed_pathrrr_get_filesystem_and_path;s   r"cCsTt|tr>xD|D](}t|tr(td}nd}||krdSqWnt|trPd|kSdS)NrTF) isinstancebyteschrstr)valbyteZ compare_torrr_check_contains_nullDs      r*TcCs|dk rt|dks&tdd|Dr.tdt|ddtrF|g}|rxL|D]D}x>|D]6\}}}t|trtdd|Dst|rZtdqZWqPW|S)z+ Check if filters are well-formed. Nrcss|]}t|dkVqdS)rN)len).0frrr Wsz!_check_filters..zMalformed filterscss|]}t|VqdS)N)r*)r,vrrrr.cszBNull-terminated binary strings are not supported as filter values.) r+any ValueErrorr$r'listallr*NotImplementedError)filterscheck_null_strings conjunctioncolopr(rrr_check_filtersRs  r:azPredicates are expressed in disjunctive normal form (DNF), like ``[[('x', '=', 0), ...], ...]``. DNF allows arbitrary boolean logical combinations of single column predicates. The innermost tuples each describe a single column predicate. The list of inner predicates is interpreted as a conjunction (AND), forming a more selective and multiple column predicate. Finally, the most outer list combines these filters as a disjunction (OR). Predicates may also be passed as List[Tuple]. This form is interpreted as a single conjunction. To express OR in predicates, one must use the (preferred) List[List[Tuple]] notation. Each tuple has format: (``key``, ``op``, ``value``) and compares the ``key`` with the ``value``. The supported ``op`` are: ``=`` or ``==``, ``!=``, ``<``, ``>``, ``<=``, ``>=``, ``in`` and ``not in``. If the ``op`` is ``in`` or ``not in``, the ``value`` must be a collection such as a ``list``, a ``set`` or a ``tuple``. Examples: .. code-block:: python ('x', '=', 0) ('y', 'in', ['a', 'b', 'c']) ('z', 'not in', {'a','b'}) cstddljt|jr|St|dd}fddg}x0|D](}fdd|D}|jttj|qz<=z>=inznot inz,"{0}" is not a valid operator in predicates.)fieldisinr1format)r8r9r(r?)dsrrconvert_single_predicates(   z8_filters_to_expression..convert_single_predicatecsg|]\}}}|||qSrr)r,r8r9r()rCrr sz*_filters_to_expression..) pyarrow.datasetdatasetr$ Expressionr:appendroperatorand_or_)r5Zdisjunction_membersr7Zconjunction_membersr)rCrBr_filters_to_expressions      rLc@seZdZdZdddZddZed d Zed d Zed dZ eddZ d ddZ d!ddZ d"ddZ d#ddZd$ddZd%ddZdS)& ParquetFilea Reader interface for a single Parquet file. Parameters ---------- source : str, pathlib.Path, pyarrow.NativeFile, or file-like object Readable source. For passing bytes or buffer-like file containing a Parquet file, use pyarrow.BufferReader. metadata : FileMetaData, default None Use existing metadata object, rather than reading from file. common_metadata : FileMetaData, default None Will be used in reads for pandas schema metadata if not found in the main file's metadata, no other uses at the moment. memory_map : bool, default False If the source is a file path, use a memory map to read file, which can improve performance in some environments. buffer_size : int, default 0 If positive, perform read buffering when deserializing individual column chunks. Otherwise IO calls are unbuffered. pre_buffer : bool, default False Coalesce and issue file reads in parallel to improve performance on high-latency filesystems (e.g. S3). If True, Arrow will use a background I/O thread pool. read_dictionary : list List of column names to read directly as DictionaryArray. coerce_int96_timestamp_unit : str, default None. Cast timestamps that are stored in INT96 format to a particular resolution (e.g. 'ms'). Setting to None is equivalent to 'ns' and therefore INT96 timestamps will be infered as timestamps in nanoseconds. NFrc Cs6t|_|jj|||||||d||_|j|_dS)N)Zuse_memory_map buffer_size pre_bufferread_dictionarymetadatacoerce_int96_timestamp_unit)rreaderopencommon_metadata_build_nested_paths_nested_paths_by_prefix) selfsourcerQrUrP memory_maprNrOrRrrr__init__szParquetFile.__init__cCsv|jj}tt}x`t|D]T\}}|d}|dd}x6||j||sLPdj||df}|dd}q8WqW|S)Nr.)rSZ column_pathsrr2 enumeraterHjoin)rXpathsresultirkeyrestrrrrVs zParquetFile._build_nested_pathscCs|jjS)N)rSrQ)rXrrrrQszParquetFile.metadatacCs|jjS)zG Return the Parquet schema, unconverted to Arrow types )rQschema)rXrrrreszParquetFile.schemacCs|jjS)zj Return the inferred Arrow schema, converted from the whole Parquet file's schema )rS schema_arrow)rXrrrrf szParquetFile.schema_arrowcCs|jjS)N)rSnum_row_groups)rXrrrrgszParquetFile.num_row_groupsTcCs |j||d}|jj|||dS)a Read a single row group from a Parquet file. Parameters ---------- i : int Index of the individual row group that we want to read. columns : list If not None, only these columns will be read from the row group. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'. use_threads : bool, default True Perform multi-threaded column reads. use_pandas_metadata : bool, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded. Returns ------- pyarrow.table.Table Content of the row group as a table (of columns) )use_pandas_metadata)column_indices use_threads)_get_column_indicesrSread_row_group)rXrbcolumnsrjrhrirrrrls  zParquetFile.read_row_groupcCs |j||d}|jj|||dS)a Read a multiple row groups from a Parquet file. Parameters ---------- row_groups : list Only these row groups will be read from the file. columns : list If not None, only these columns will be read from the row group. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'. use_threads : bool, default True Perform multi-threaded column reads. use_pandas_metadata : bool, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded. Returns ------- pyarrow.table.Table Content of the row groups as a table (of columns). )rh)rirj)rkrSread_row_groups)rX row_groupsrmrjrhrirrrrn6s  zParquetFile.read_row_groupscCs<|dkrtd|jj}|j||d}|jj||||d}|S)a Read streaming batches from a Parquet file Parameters ---------- batch_size : int, default 64K Maximum number of records to yield per batch. Batches may be smaller if there aren't enough rows in the file. row_groups : list Only these row groups will be read from the file. columns : list If not None, only these columns will be read from the file. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'. use_threads : boolean, default True Perform multi-threaded column reads. use_pandas_metadata : boolean, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded. Returns ------- iterator of pyarrow.RecordBatch Contents of each batch as a record batch Nr)rh)rorirj)rangerQrgrkrS iter_batches)rX batch_sizerormrjrhriZbatchesrrrrrTs zParquetFile.iter_batchescCs|j||d}|jj||dS)a Read a Table from Parquet format, Parameters ---------- columns : list If not None, only these columns will be read from the file. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'. use_threads : bool, default True Perform multi-threaded column reads. use_pandas_metadata : bool, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded. Returns ------- pyarrow.table.Table Content of the file as a table (of columns). )rh)rirj)rkrSZread_all)rXrmrjrhrirrrreadzs zParquetFile.readcCs|j|}|jj||dS)a Read contents of file for the given columns and batch size. Notes ----- This function's primary purpose is benchmarking. The scan is executed on a single thread. Parameters ---------- columns : list of integers, default None Select columns to read, if None scan all columns. batch_size : int, default 64K Number of rows to read at a time internally. Returns ------- num_rows : number of rows in file )rs)rkrS scan_contents)rXrmrsrirrrrus zParquetFile.scan_contentscs|dkr dSg}x&|D]}|jkr|jj|qW|rjj}jdk rVjjnd}|rpd|krpt|}n|rd|krt|}ng}|dk r|r|fdd|D7}|S)Nspandascs"g|]}t|tsjj|qSr)r$dictrSZcolumn_name_idx)r,descr)rXrrrDsz3ParquetFile._get_column_indices..)rWextendrQrU_get_pandas_index_columns)rXZ column_namesrhindicesnameZfile_keyvaluesZcommon_keyvalues index_columnsr)rXrrks&         zParquetFile._get_column_indices)NNNFrFN)NTF)NTF)rpNNTF)NTF)Nrp)F)__name__ __module__ __qualname____doc__r[rVpropertyrQrerfrgrlrnrrrtrurkrrrrrMs$        %  rMz [ ,;{}() =]cCs tjd|S)N_)_SPARK_DISALLOWED_CHARSsub)r{rrr_sanitized_spark_field_namesrc Csd|kr|g}d}xR|D]J}|j}t|}||krVd}tj||j|j|j}|j|q|j|qWtj||jd}||fS|dfSdS)NsparkFT)rQ) r{rpar?typeZnullablerQrHre) reflavorZsanitized_fieldsschema_changedr?r{Zsanitized_nameZsanitized_field new_schemarrr_sanitize_schemas    rcs8d|kr0fddtjD}tjj||dSSdS)Nrcsg|] }|qSrr)r,rb)tablerrrDsz#_sanitize_table..)re)rqZ num_columnsrTable from_arrays)rrrZ column_datar)rr_sanitize_tablesraversion : {"1.0", "2.4", "2.6"}, default "1.0" Determine which Parquet logical types are available for use, whether the reduced set from the Parquet 1.x.x format or the expanded logical types added in later format versions. Files written with version='2.4' or '2.6' may not be readable in all Parquet implementations, so version='1.0' is likely the choice that maximizes file compatibility. UINT32 and some logical types are only available with version '2.4'. Nanosecond timestamps are only available with version '2.6'. Other features such as compression algorithms or the new serialized data page format must be enabled separately (see 'compression' and 'data_page_version'). use_dictionary : bool or list Specify if we should use dictionary encoding in general or only for some columns. use_deprecated_int96_timestamps : bool, default None Write timestamps to INT96 Parquet format. Defaults to False unless enabled by flavor argument. This take priority over the coerce_timestamps option. coerce_timestamps : str, default None Cast timestamps to a particular resolution. If omitted, defaults are chosen depending on `version`. By default, for ``version='1.0'`` (the default) and ``version='2.4'``, nanoseconds are cast to microseconds ('us'), while for other `version` values, they are written natively without loss of resolution. Seconds are always cast to milliseconds ('ms') by default, as Parquet does not have any temporal type with seconds resolution. If the casting results in loss of data, it will raise an exception unless ``allow_truncated_timestamps=True`` is given. Valid values: {None, 'ms', 'us'} data_page_size : int, default None Set a target threshold for the approximate encoded size of data pages within a column chunk (in bytes). If None, use the default data page size of 1MByte. allow_truncated_timestamps : bool, default False Allow loss of data when coercing timestamps to a particular resolution. E.g. if microsecond or nanosecond data is lost when coercing to 'ms', do not raise an exception. Passing ``allow_truncated_timestamp=True`` will NOT result in the truncation exception being ignored unless ``coerce_timestamps`` is not None. compression : str or dict Specify the compression codec, either on a general basis or per-column. Valid values: {'NONE', 'SNAPPY', 'GZIP', 'BROTLI', 'LZ4', 'ZSTD'}. write_statistics : bool or list Specify if we should write statistics in general (default is True) or only for some columns. flavor : {'spark'}, default None Sanitize schema or set other compatibility options to work with various target systems. filesystem : FileSystem, default None If nothing passed, will be inferred from `where` if path-like, else `where` is already a file-like object so no filesystem is needed. compression_level : int or dict, default None Specify the compression level for a codec, either on a general basis or per-column. If None is passed, arrow selects the compression level for the compression codec in use. The compression level has a different meaning for each codec, so you have to read the documentation of the codec you are using. An exception is thrown if the compression codec does not allow specifying a compression level. use_byte_stream_split : bool or list, default False Specify if the byte_stream_split encoding should be used in general or only for some columns. If both dictionary and byte_stream_stream are enabled, then dictionary is preferred. The byte_stream_split encoding is valid only for floating-point data types and should be combined with a compression codec. data_page_version : {"1.0", "2.0"}, default "1.0" The serialized Parquet data page format version to write, defaults to 1.0. This does not impact the file schema logical types and Arrow to Parquet type casting behavior; for that use the "version" option. use_compliant_nested_type : bool, default False Whether to write compliant Parquet nested type (lists) as defined `here `_, defaults to ``False``. For ``use_compliant_nested_type=True``, this will write into a list with 3-level structure where the middle level, named ``list``, is a repeated group with a single field named ``element``:: group (LIST) { repeated group list { element; } } For ``use_compliant_nested_type=False``, this will also write into a list with 3-level structure, where the name of the single field of the middle level ``list`` is taken from the element name for nested columns in Arrow, which defaults to ``item``:: group (LIST) { repeated group list { item; } } c @sJeZdZdjeZdddZd d Zd d Zd dZ dddZ ddZ dS) ParquetWritera Class for incrementally building a Parquet file for Arrow tables. Parameters ---------- where : path or file-like object schema : arrow Schema {} writer_engine_version : unused **options : dict If options contains a key `metadata_collector` then the corresponding value is assumed to be a list (or any object with `.append` method) that will be filled with the file metadata instance of the written file. N1.0TsnappyFc Ks| dkr"|dk rd|krd} nd} ||_|dk rBt||\}|_nd|_||_||_d|_t||dd\}}|dk rt|tj r|j |d}|_q|j |dd}|_n|}|j dd|_ d}tj||f||||| | | || |d ||_d|_dS) NrTF)Zallow_legacy_filesystemwb) compressionmetadata_collectorZV2) versionruse_dictionarywrite_statisticsuse_deprecated_int96_timestampscompression_leveluse_byte_stream_splitwriter_engine_versiondata_page_versionuse_compliant_nested_type)rrrrewhere file_handlerr$r rrTZopen_output_streampop_metadata_collector_parquetrwriteris_open)rXrrerrrrrrrrrrrroptionsrZsinkZengine_versionrrrr[dsF   zParquetWriter.__init__cCst|ddr|jdS)NrF)getattrclose)rXrrr__del__s zParquetWriter.__del__cCs|S)Nr)rXrrr __enter__szParquetWriter.__enter__cOs |jdS)NF)r)rXargskwargsrrr__exit__szParquetWriter.__exit__cCs^|jrt||j|j}|js t|jj|jddsJdj|j|j}t||j j ||ddS)NF)check_metadatazTTable schema does not match schema used to create file: table: {!s} vs. file: {!s})row_group_size) rrrerrAssertionErrorequalsrAr1r write_table)rXrrmsgrrrrs  zParquetWriter.write_tablecCsH|jr0|jjd|_|jdk r0|jj|jj|jdk rD|jjdS)NF)rrrrrHrQr)rXrrrrs   zParquetWriter.close) NNrTrTNNFNrF)N) r}r~rrA_parquet_writer_arg_docsrr[rrrrrrrrrrRs$  7 rcCstj|djddS)Nspandasutf8r|)jsonloadsdecode) keyvaluesrrrrysryc@seZdZdZeedddddfddZeeedddddfddZd d Z d d Z d dZ ddZ ddZ ddZdddZdS)ParquetDatasetPiecea DEPRECATED: A single chunk of a potentially larger Parquet dataset to read. The arguments will indicate to read either a single row group or all row groups, and whether to add partition keys to the resulting pyarrow.Table. .. deprecated:: 5.0 Directly constructing a ``ParquetDatasetPiece`` is deprecated, as well as accessing the pieces of a ``ParquetDataset`` object. Specify ``use_legacy_dataset=False`` when constructing the ``ParquetDataset`` and use the ``ParquetDataset.fragments`` attribute instead. Parameters ---------- path : str or pathlib.Path Path to file in the file system where this piece is located. open_file_func : callable Function to use for obtaining file handle to dataset piece. partition_keys : list of tuples Two-element tuples of ``(column name, ordinal index)``. row_group : int, default None Row group to load. By default, reads all row groups. file_options : dict Options rb)modeNcCs&tjdtdd|j|||||dS)Nz^ParquetDatasetPiece is deprecated as of pyarrow 5.0.0 and will be removed in a future version.) stacklevel)warningswarnDeprecationWarning_init)rXropen_file_func file_options row_grouppartition_keysrrrr[s  zParquetDatasetPiece.__init__cCs tjt}|j||||||S)N)r__new__r)rrrrrrXrrr_creates zParquetDatasetPiece._createcCs.t||_||_||_|pg|_|p&i|_dS)N)rrrrrr)rXrrrrrrrrrs   zParquetDatasetPiece._initcCs2t|tsdS|j|jko0|j|jko0|j|jkS)NF)r$rrrr)rXotherrrr__eq__s    zParquetDatasetPiece.__eq__cCsdjt|j|j|j|jS)Nz-{}({!r}, row_group={!r}, partition_keys={!r}))rArr}rrr)rXrrr__repr__s zParquetDatasetPiece.__repr__cCs^d}t|jdkr6djdd|jD}|dj|7}||j7}|jdk rZ|dj|j7}|S)Nrz, css|]\}}dj||VqdS)z{}={}N)rA)r,r{indexrrrr.sz.ParquetDatasetPiece.__str__..zpartition[{}] z | row_group={})r+rr_rArr)rXraZ partition_strrrr__str__s    zParquetDatasetPiece.__str__cCs|j}|jS)zn Return the file's metadata. Returns ------- metadata : FileMetaData )rTrQ)rXr-rrr get_metadata#sz ParquetDatasetPiece.get_metadatacCs(|j|j}t|ts$t|f|j}|S)z1 Return instance of ParquetFile. )rrr$rMr)rXrSrrrrT.s  zParquetDatasetPiece.openTFcCs|jdk r|j}n(|dk r,t|f|j}nt|jf|j}t|||d}|jdk rf|j|jf|}n |jf|}t |j dkr|dkrt dxTt |j D]F\} \} } t jt || dd} |j| j} tjj| | }|j| |}qW|S)a Read this piece as a pyarrow.Table. Parameters ---------- columns : list of column names, default None use_threads : bool, default True Perform multi-threaded column reads. partitions : ParquetPartitions, default None file : file-like object Passed to ParquetFile. use_pandas_metadata : bool If pandas metadata should be used or not. Returns ------- table : pyarrow.Table N)rmrjrhrzMust pass partition setsi4)Zdtype)rrTrMrrrvrrlrtr+rr1r^npfulllevels dictionaryrZDictionaryArrayrZ append_column)rXrmrj partitionsfilerhrSrrrbr{rrzrZarrrrrrt7s(      zParquetDatasetPiece.read)NTNNF)r}r~rrrrTr[ staticmethodrrrrrrrtrrrrrs    rc@s:eZdZdZd ddZddZeddZed d ZdS) PartitionSeta A data structure for cataloguing the observed Parquet partitions at a particular level. So if we have /foo=a/bar=0 /foo=a/bar=1 /foo=a/bar=2 /foo=b/bar=0 /foo=b/bar=1 /foo=b/bar=2 Then we have two partition sets, one for foo, another for bar. As we visit levels of the partition hierarchy, a PartitionSet tracks the distinct values and assigns categorical codes to use when reading the pieces Parameters ---------- name : str Name of the partition set. Under which key to collect all values. keys : list All possible values that have been collected for that partition set. NcCs0||_|p g|_ddt|jD|_d|_dS)NcSsi|]\}}||qSrr)r,rbkrrr sz)PartitionSet.__init__..)r{keysr^ key_indices _dictionary)rXr{rrrrr[s zPartitionSet.__init__cCs<||jkr|j|St|j}|jj|||j|<|SdS)z Get the index of the partition value if it is known, otherwise assign one Parameters ---------- key : The value for which we want to known the index. N)rr+rrH)rXrcrrrr get_indexs     zPartitionSet.get_indexc Csp|jdk r|jSt|jdkr&tdydd|jD}tj|}Wn tk rdtj|j}YnX||_|S)NrzNo known partition keyscSsg|] }t|qSr)int)r,xrrrrDsz+PartitionSet.dictionary..)rr+rr1libarray)rXZ integer_keysrrrrrs zPartitionSet.dictionarycCst|jt|jkS)N)r2rsorted)rXrrr is_sortedszPartitionSet.is_sorted)N) r}r~rrr[rrrrrrrrrys   rc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)ParquetPartitionscCsg|_t|_dS)N)rsetpartition_names)rXrrrr[szParquetPartitions.__init__cCs t|jS)N)r+r)rXrrr__len__szParquetPartitions.__len__cCs |j|S)N)r)rXrbrrr __getitem__szParquetPartitions.__getitem__cCs*t|tstd|j|jko(|j|jkS)Nz0`other` must be an instance of ParquetPartitions)r$r TypeErrorrr)rXrrrrrs  zParquetPartitions.equalsc Cs$y |j|Stk rtSXdS)N)rrNotImplemented)rXrrrrrs zParquetPartitions.__eq__cCsV|t|jkrF||jkr&tdj|t|}|jj||jj||j|j|S)aT Record a partition value at a particular level, returning the distinct code for that value at that level. Example: partitions.get_index(1, 'foo', 'a') returns 0 partitions.get_index(1, 'foo', 'b') returns 1 partitions.get_index(1, 'foo', 'c') returns 2 partitions.get_index(1, 'foo', 'a') returns 0 Parameters ---------- level : int The nesting level of the partition we are observing name : str The partition name key : str or int The partition value z1{} was the name of the partition in another level) r+rrr1rArrHaddr)rXlevelr{rcZpart_setrrrrs   zParquetPartitions.get_indexc Cs`|\}}|\}}}||krdSt|} |dkrt|tsDtd| j|sPtdtdd|Ddkrptd |ttt|} n t|t  rt|trtd || |j |j |j } |d ks|d kr| |kS|d kr| |kS|dkr| |kS|dkr| |kS|dkr| |kS|dkr*| |kS|dkr<| |kS|dkrN| |kStd|ddS)NTr>not inz'%s' object is not a collectionz+Cannot use empty collection as filter valuecSsh|] }t|qSr)r)r,itemrrr sz=ParquetPartitions.filter_accepts_partition..r\z8All elements of the collection '%s' must be of same typez-Op '%s' not supported with a collection valuer;z==z!=r<r=z<=z>=z+'%s' is not a valid operator in predicates.>rr>) rr$rrr}r1r+nextiterr'rrZas_py) rXpart_keyfilterrZp_columnZ p_value_indexZf_columnr9Zf_valueZf_typeZp_valuerrrfilter_accepts_partitionsL           z*ParquetPartitions.filter_accepts_partitionN) r}r~rr[rrrrrrrrrrrs rc@s>eZdZdddZddZd d Zd d Zd dZddZdS)ParquetManifestN/hiver\cCst||\}}||_||_||_t||_||_t|_g|_ ||_ t j |d|_ d|_d|_|jd|jg|j jddd|jdkr|j|_|j jdS)N) max_workersrcSs|jS)N)r)piecerrr>sz*ParquetManifest.__init__..)rc)r"rrpathseprdirpathpartition_schemerrpieces_metadata_nthreadsrThreadPoolExecutor _thread_poolcommon_metadata_path metadata_path _visit_levelsortshutdown)rXrrrrrmetadata_nthreadsrrrr[)s$   zParquetManifest.__init__c sj}t|j\}}}g}xX|D]P} jj| f} | jdrJ| _q$| jdr\| _q$j| rjq$q$|j | q$Wfdd|D} |j | j t |dkrt | dkrt dj n(t | dkrj|| |n j||dS)NZ_common_metadata _metadatacs$g|]}t|sjj|fqSr)_is_private_directoryrr_)r,r) base_pathrXrrrDXsz0ParquetManifest._visit_level..rz,Found files in an intermediate directory: {})rrwalkrr_endswithrr_should_silently_excluderHrr+r1rA_visit_directories _push_pieces) rXrr  part_keysfsr directoriesfilesZfiltered_filesr full_pathZfiltered_directoriesr)r rXrrFs,       zParquetManifest._visit_levelcCs0|jdp.|jdp.|jdp.|jdp.|tkS)Nz.crcz _$folder$r]r)r startswithEXCLUDED_PARQUET_PATHS)rX file_namerrrrgs     z(ParquetManifest._should_silently_excludec Csg}x|D]~}t||j\}}t|\}} |jj||| } ||| fg} ||jkrv|jj|j|d|| } |j | q |j|d|| q W|rt j |dS)Nr\) _path_splitr_parse_hive_partitionrrrrsubmitrrHrwait) rXrrrZ futures_listrheadtailr{rcrZ dir_part_keysfuturerrrrns     z"ParquetManifest._visit_directoriescCs&|jdkrt|Stdj|jdS)Nrzpartition schema: {})rrr4rA)rXdirnamerrr_parse_partitions z ParquetManifest._parse_partitioncs jjfdd|DdS)Ncsg|]}tj|jdqS))rr)rrr)r,r)rrXrrrDsz0ParquetManifest._push_pieces..)rrx)rXrrr)rrXrrs zParquetManifest._push_pieces)NNrrr\) r}r~rr[rrrr"rrrrrr's !rcCs"d|krtdj||jddS)Nr;z3Directory name did not appear to be a partition: {}r\)r1rAsplit)valuerrrrsrcCs,tjj|\}}|jds$|jdo*d|kS)Nrr]r;)osrr#r)rrrrrrr sr cCs:|j|d}|d|||d}}|j|}||fS)Nr\)rfindrstrip)rseprbrrrrrrs rZ_SUCCESSc@seZdZdZdS)_ParquetDatasetMetadatarrZrPrUrNN)rrZrPrUrN)r}r~r __slots__rrrrr)sr)cCsF|jdk r*t|jtj r*|jj|dd}t|||j|j|j|j dS)Nr)r)rQrZrPrUrN) rr$r rrTrMrZrPrUrN)rFrmetarrr_open_dataset_files r,z['{}' attribute is deprecated as of pyarrow 5.0.0 and will be removed in a future version.{}aread_dictionary : list, default None List of names or column paths (for nested types) to read directly as DictionaryArray. Only supported for BYTE_ARRAY storage. To read a flat column as dictionary-encoded pass the column name. For nested types, you must pass the full column "path", which could be something like level1.level2.list.item. Refer to the Parquet file's schema to obtain the paths. memory_map : bool, default False If the source is a file path, use a memory map to read file, which can improve performance in some environments. buffer_size : int, default 0 If positive, perform read buffering when deserializing individual column chunks. Otherwise IO calls are unbuffered. partitioning : Partitioning or str or list of str, default "hive" The partitioning scheme for a partitioned dataset. The default of "hive" assumes directory names with key=value pairs like "/year=2009/month=11". In addition, a scheme like "/2009/11" is also supported, in which case you need to specify the field names or a full schema. See the ``pyarrow.dataset.partitioning()`` function for more details.c@seZdZdjeeZd(dd Zd)d d Zd d Z ddZ ddZ d*ddZ ddZ ddZddZeddZeddZeddZed d!Zed"d#Zeejd$Zed%d&Zeejd'ZdS)+ParquetDataseta Encapsulates details of reading a complete Parquet dataset possibly consisting of multiple files and partitions in subdirectories. Parameters ---------- path_or_paths : str or List[str] A directory name, single file name, or list of file names. filesystem : FileSystem, default None If nothing passed, paths assumed to be found in the local on-disk filesystem. metadata : pyarrow.parquet.FileMetaData Use metadata obtained elsewhere to validate file schemas. schema : pyarrow.parquet.Schema Use schema obtained elsewhere to validate file schemas. Alternative to metadata parameter. split_row_groups : bool, default False Divide files into pieces for each row group in the file. validate_schema : bool, default True Check that individual file schemas are all the same / compatible. filters : List[Tuple] or List[List[Tuple]] or None (default) Rows which do not match the filter predicate will be removed from scanned data. Partition keys embedded in a nested directory structure will be exploited to avoid loading files at all if they contain no matching rows. If `use_legacy_dataset` is True, filters can only reference partition keys and only a hive-style directory structure is supported. When setting `use_legacy_dataset` to False, also within-file level filtering and different partitioning schemes are supported. {1} metadata_nthreads : int, default 1 How many threads to allow the thread pool which is used to read the dataset metadata. Increasing this is helpful to read partitioned datasets. {0} use_legacy_dataset : bool, default True Set to False to enable the new code path (experimental, using the new Arrow Dataset API). Among other things, this allows to pass `filters` for all columns and not only the partition keys, enables different partitioning schemes, etc. pre_buffer : bool, default True Coalesce and issue file reads in parallel to improve performance on high-latency filesystems (e.g. S3). If True, Arrow will use a background I/O thread pool. This option is only supported for use_legacy_dataset=False. If using a filesystem layer that itself performs readahead (e.g. fsspec's S3FS), disable readahead for best results. coerce_int96_timestamp_unit : str, default None. Cast timestamps that are stored in INT96 format to a particular resolution (e.g. 'ms'). Setting to None is equivalent to 'ns' and therefore INT96 timestamps will be infered as timestamps in nanoseconds. NFTr\rrcCsR| dkrt|trd} nd} | sDt|||| | | | |||||||dStj|}|S)NFT) rr5 partitioningrPrZrNrOrRrerQsplit_row_groupsvalidate_schemar )r$r_ParquetDatasetV2objectr)cls path_or_pathsrrerQr/r0r5r rPrZrNr.use_legacy_datasetrOrRrXrrrrs(  zParquetDataset.__new__cCsr| dkrtdt|_|}t|tr.|d}t||\|j_}t|tr\dd|D|_n t||_| |j_ | |j_ | |j_ t ||j |tt|jd\|_|_|_|_|jdk r|j j|j}t|| d|j_WdQRXnd|j_|dko|jdk r$|j j|j}t|| d|_WdQRXn||_||_||_|rDtd|dk r`t|}|j||rn|jdS) NrzVOnly "hive" for hive-like partitioning is supported when using use_legacy_dataset=TruercSsg|] }t|qSr)r)r,rrrrrD@sz+ParquetDataset.__init__..)r r)rZz$split_row_groups not yet implemented)r1r)r r$r2r"rr`rrPrZrN_make_manifest_fsrr,_pieces _partitionsrrrT read_metadatarUrQrer/r4r:_filtervalidate_schemas)rXr4rrerQr/r0r5r rPrZrNr.r5rOrRZa_pathrr-rrrr[/sH       zParquetDataset.__init__c Cszt|tstd|jj|jjkr&dSx$dD]}t||t||kr,dSq,Wx(dD] }t|j|t|j|krRdSqRWdS)Nz-`other` must be an instance of ParquetDatasetFr`r8r9rrrUrQrer/rZrNT) r`r8r9rrrUrQrer/)rZrN)r$r-rr7 __class__rr )rXrproprrrrms  zParquetDataset.equalsc Cs$y |j|Stk rtSXdS)N)rrr)rXrrrrrs zParquetDataset.__eq__cCs|jdkr>|jdkr>|jdk r*|jj|_qR|jdjj|_n|jdkrR|jj|_|jj}|jdk rx2|jjD]&}|j|dkrp|j|}|j |}qpWx@|jD]6}|j}|jj}|j |ddst dj |||qWdS)Nrr\F)rz-Schema in {!s} was different. {!s} vs {!s}) rQrerUr8rto_arrow_schemar9rget_field_indexremoverr1rA)rXZdataset_schemaZpartition_nameZ field_idxrZ file_metadataZ file_schemarrrr<s&         zParquetDataset.validate_schemasc Csrg}x,|jD]"}|j|||j|d}|j|q Wtj|}|rn|j}|jjpRi} |rnd| krn|j d|i}|S)a Read multiple Parquet files as a single pyarrow.Table. Parameters ---------- columns : List[str] Names of columns to read from the file. use_threads : bool, default True Perform multi-threaded column reads use_pandas_metadata : bool, default False Passed through to each dataset piece. Returns ------- pyarrow.Table Content of the file as a table (of columns). )rmrjrrhspandas) r8rtr9rHrZ concat_tables_get_common_pandas_metadatarerQreplace_schema_metadata) rXrmrjrhZtablesrrZall_datarUZcurrent_metadatarrrrts     zParquetDataset.readcKs|jfddi|S)a Read dataset including pandas metadata, if any. Other arguments passed through to ParquetDataset.read, see docstring for further details. Parameters ---------- **kwargs : optional All additional options to pass to the reader. Returns ------- pyarrow.Table Content of the file as a table (of columns). rhT)rt)rXrrrr read_pandasszParquetDataset.read_pandascCs"|jdkrdS|jj}|jddS)Nspandas)rUrQget)rXrrrrrCs z*ParquetDataset._get_common_pandas_metadatacs<|jjfddfddfdd|jD|_dS)Ncstfddt|jDS)Nc3s|]\}}||VqdS)Nr)r,rr)accepts_filterrrrr.szEParquetDataset._filter..one_filter_accepts..)r3r^r)rr)rG)rrone_filter_acceptssz2ParquetDataset._filter..one_filter_acceptscstfddDS)Nc3s&|]}tfdd|DVqdS)c3s|]}|VqdS)Nr)r,r-)rHrrrr.szOParquetDataset._filter..all_filters_accept...N)r3)r,r7)rHrrrr.szEParquetDataset._filter..all_filters_accept..)r0)r)r5rH)rrall_filters_acceptsz2ParquetDataset._filter..all_filters_acceptcsg|]}|r|qSrr)r,p)rIrrrDsz*ParquetDataset._filter..)r9rr8)rXr5r)rGrIr5rHrr;s zParquetDataset._filtercCstjtjddtdd|jS)NzParquetDataset.piecesz{ Specify 'use_legacy_dataset=False' while constructing the ParquetDataset, and then use the '.fragments' attribute instead.r)r)rr _DEPR_MSGrArr8)rXrrrrs  zParquetDataset.piecescCstjtjddtdd|jS)NzParquetDataset.partitionsz~ Specify 'use_legacy_dataset=False' while constructing the ParquetDataset, and then use the '.partitioning' attribute instead.r)r)rrrKrArr9)rXrrrrs  zParquetDataset.partitionscCs tjtjddtdd|jjS)NzParquetDataset.memory_maprr)r)rrrKrArr rZ)rXrrrrZs  zParquetDataset.memory_mapcCs tjtjddtdd|jjS)NzParquetDataset.read_dictionaryrr)r)rrrKrArr rP)rXrrrrP s  zParquetDataset.read_dictionarycCs tjtjddtdd|jjS)NzParquetDataset.buffer_sizerr)r)rrrKrArr rN)rXrrrrNs  zParquetDataset.buffer_sizez _metadata.fscCs tjtjddtdd|jjS)NzParquetDataset.fsz| Specify 'use_legacy_dataset=False' while constructing the ParquetDataset, and then use the '.filesystem' attribute instead.r)r)rrrKrArr r)rXrrrrs  zParquetDataset.fsz_metadata.common_metadata)NNNNFTNr\NFrrNTN)NNNFTNr\NFrrTTN)NTF)r}r~rrA_read_docstring_common_DNF_filter_docrrr[rrr<rtrErCr;rrrrZrPrNrI attrgetterr7rrUrrrrr-s<5   9 (     r-rr\c Csd}d}d}t|tr*t|dkr*|d}t|rp|j|rpt|||t|dd|d}|j}|j}|j } |j }nft|ts|g}t|dkrt dg} x<|D]4} |j | st dj| tj| |d} | j| qW| |||fS) Nr\rrr)rrrr z Must pass at least one file pathzPassed non-file path: {})r)r$r2r+risdirrrrrrrr1isfileOSErrorrArrrH) r4rrr rrrrmanifestrrrrrrr6-s6      r6cCst|tpt|tjS)N)r$rr )rrrr_is_local_file_systemTs rSc @steZdZdZdddZedd Zdd d Zd d ZeddZ eddZ eddZ eddZ eddZ dS)r1zC ParquetDataset shim using the Dataset API under the hood. NrFTc Ksddlj} x2dD]*\} }| | kr| | |k rtd j| qW| | d }|rZ|jd|d |dk rn|j|d ||_|o~t||_|dk rt||d}n|dkr|rt |d}t |dr|dk rt | rt dt |d}t|trt|d krl|d}nht|rht|}|dkrTytj|\}}Wn tk rRt |d}YnX|j|jrl|}n|}|dk rd|_|jdd| jf|}|j||}| j|g|j||jd|_dSd|_| jf|}|dkr| jjdd}| j|||||d|_dS)NrrerQr/Fr0Tr r\z;Keyword '{0}' is not yet supported with the new Dataset API)rOrR)Zuse_buffered_streamrN)Zdictionary_columns)Zuse_mmap __fspath__zQPath-like objects with __fspath__ must only be used with local file systems, not )Z!enable_parallel_column_conversion)rerArr)Zinfer_dictionary)rrAr.ignore_prefixesreNrQNr/Fr0Tr r\)rVrWrXrYrZ) rErFr1rAupdate_filtersrL_filter_expressionrrhasattrrSrrr$r2r+rrrZfrom_uriZ get_file_infois_file"_enable_parallel_column_conversionParquetFileFormatZ make_fragmentZFileSystemDatasetZphysical_schemar_datasetZHivePartitioningZdiscover)rXr4rr5r.rPrNrZrUrOrRrrBkeyworddefaultZ read_optionsZ single_fileparquet_formatfragmentrrrr[_s|                    z_ParquetDatasetV2.__init__cCs|jjS)N)rbre)rXrrrresz_ParquetDatasetV2.schemacCs|jj}|dk rN|rN|rNd|krNddt|D}t|tt|t|}|jr\|r\d}|jj||j|d}|r|rd|kr|jjpi}|j d|di|j |}|S)a Read (multiple) Parquet files as a single pyarrow.Table. Parameters ---------- columns : List[str] Names of columns to read from the dataset. The partition fields are not automatically included (in contrast to when setting ``use_legacy_dataset=True``). use_threads : bool, default True Perform multi-threaded column reads. use_pandas_metadata : bool, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded. Returns ------- pyarrow.Table Content of the file as a table (of columns). NspandascSsg|]}t|ts|qSr)r$rv)r,r8rrrrDsz*_ParquetDatasetV2.read..F)rmrrj) rerQryr2rr`rbZto_tabler]r[rD)rXrmrjrhrQr|rZ new_metadatarrrrts"     z_ParquetDatasetV2.readcKs|jfddi|S)z Read dataset including pandas metadata, if any. Other arguments passed through to ParquetDataset.read, see docstring for further details. rhT)rt)rXrrrrrEsz_ParquetDatasetV2.read_pandascCs&tjtjddtddt|jjS)NzParquetDataset.piecesz' Use the '.fragments' attribute insteadr)r)rrrKrArr2rb get_fragments)rXrrrrs  z_ParquetDatasetV2.piecescCst|jjS)N)r2rbrg)rXrrr fragmentssz_ParquetDatasetV2.fragmentscCs|jjS)N)rbr)rXrrrrsz_ParquetDatasetV2.filescCs|jjS)N)rbr)rXrrrrsz_ParquetDatasetV2.filesystemcCs|jjS)zH The partitioning of the Dataset source, if discovered. )rbr.)rXrrrr.sz_ParquetDatasetV2.partitioning) NNrNNFNTN)NTF)r}r~rrr[rrertrErrhrrr.rrrrr1Zs a  8    r1a {0} Parameters ---------- source : str, pyarrow.NativeFile, or file-like object If a string passed, can be a single file name or directory name. For file-like objects, only read a single file. Use pyarrow.BufferReader to read a file contained in a bytes or buffer-like object. columns : list If not None, only these columns will be read from the file. A column name may be a prefix of a nested field, e.g. 'a' will select 'a.b', 'a.c', and 'a.d.e'. If empty, no columns will be read. Note that the table will still have the correct num_rows set despite having no columns. use_threads : bool, default True Perform multi-threaded column reads. metadata : FileMetaData If separately computed {1} use_legacy_dataset : bool, default False By default, `read_table` uses the new Arrow Datasets API since pyarrow 1.0.0. Among other things, this allows to pass `filters` for all columns and not only the partition keys, enables different partitioning schemes, etc. Set to True to use the legacy behaviour. ignore_prefixes : list, optional Files matching any of these prefixes will be ignored by the discovery process if use_legacy_dataset=False. This is matched to the basename of a path. By default this is ['.', '_']. Note that discovery happens only if a directory is passed as source. filesystem : FileSystem, default None If nothing passed, paths assumed to be found in the local on-disk filesystem. filters : List[Tuple] or List[List[Tuple]] or None (default) Rows which do not match the filter predicate will be removed from scanned data. Partition keys embedded in a nested directory structure will be exploited to avoid loading files at all if they contain no matching rows. If `use_legacy_dataset` is True, filters can only reference partition keys and only a hive-style directory structure is supported. When setting `use_legacy_dataset` to False, also within-file level filtering and different partitioning schemes are supported. {3} pre_buffer : bool, default True Coalesce and issue file reads in parallel to improve performance on high-latency filesystems (e.g. S3). If True, Arrow will use a background I/O thread pool. This option is only supported for use_legacy_dataset=False. If using a filesystem layer that itself performs readahead (e.g. fsspec's S3FS), disable readahead for best results. coerce_int96_timestamp_unit : str, default None. Cast timestamps that are stored in INT96 format to a particular resolution (e.g. 'ms'). Setting to None is equivalent to 'ns' and therefore INT96 timestamps will be infered as timestamps in nanoseconds. Returns ------- {2} FrcCs| s|dk rtdy t||| ||| || | |d }Wnjtk r|dk rTtd| dkrdtdt||\}}|dk r|j|}t||||| | |d}YnX|j|||dS| dk rtdt|rt||||| ||| |d }nt||||| |d }|j|||dS) NzThe 'metadata' keyword is no longer supported with the new datasets-based implementation. Specify 'use_legacy_dataset=True' to temporarily recover the old behaviour.) rr.rZrPrNr5rUrOrRzWthe 'filters' keyword is not supported when the pyarrow.dataset module is not availablerz\the 'partitioning' keyword is not supported when the pyarrow.dataset module is not available)rQrPrZrNrOrR)rmrjrhzMThe 'ignore_prefixes' keyword is only supported when use_legacy_dataset=False)rQrZrPrNrr5r.rR)rQrPrZrNrR) r1r1 ImportErrorrZopen_input_filerMrtrr-)rYrmrjrQrhrZrPrr5rNr.r5rUrOrRrFrpfrrr read_tablebsh   rkz}Read a Table from Parquet format Note: starting with pyarrow 1.0, the default for `use_legacy_dataset` is switched to False. zuse_pandas_metadata : bool, default False If True and file has custom pandas schema metadata, ensure that index columns are also loaded.z=pyarrow.Table Content of the file as a table (of columns)cKst|f|dd|S)NT)rmrh)rk)rYrmrrrrrEsrEzcRead a Table from Parquet format, also reading DataFrame index values if known in the file metadataz4**kwargs : additional options for :func:`read_table`zgpyarrow.Table Content of the file as a Table of Columns, including DataFrame indexes as columns1.0rcKs|jd|}|}yPt||jf| || |||| | ||| |||d|}|j||dWdQRXWnHtk rt|rytjt|Wntj k rYnXYnXdS)N chunk_size)rrrrrcoerce_timestampsdata_page_sizeallow_truncated_timestampsrrrrrr)r) rrrer Exceptionrr%rBrerror)rrrrrrrrrorqrprrrrrrrZ use_int96rrrrrs8  rz Write a Table to Parquet format. Parameters ---------- table : pyarrow.Table where : string or pyarrow.NativeFile row_group_size : int The number of rows per rowgroup {} **kwargs : optional Additional options for ParquetWriter c CsJ|jrF|j| rFy|j|Wn"tk rD|j|s@tYnXdS)N)Z _isfilestoreexistsmkdirrQr)rrrrr_mkdir_if_not_exists s rvc s|dkrt|trd}nd}|sddlj}|jdd}|jdd} d} |jddd} dk rjfd d } |dk rt| jd |j} | jf|} |dk rt |}d}|r|j |j }|j |d d }|j |||| | ||| | d dStj||\}}t|||jdd|dk rt|dkr|jfdd|D}j|dd}jj|}t|dkrntd|j }x,|j jD] }||kr~|j|j|}q~Wx|j|D]\}}t|ts|f}djddt||D}tjj||dd}t|dj||g|r||}n td}dj||g}dj||g}|j |d}t!||fdi|WdQRXdk rdj"|qWnn|r|d}n td}dj||g}|j |d}t!||fdi|WdQRXdk rdj"|dS)a'Wrapper around parquet.write_table for writing a Table to Parquet format by partitions. For each combination of partition columns and values, a subdirectories are created in the following manner: root_dir/ group1=value1 group2=value1 .parquet group2=value2 .parquet group1=valueN group2=value1 .parquet group2=valueN .parquet Parameters ---------- table : pyarrow.Table root_path : str, pathlib.Path The root directory of the dataset filesystem : FileSystem, default None If nothing passed, paths assumed to be found in the local on-disk filesystem partition_cols : list, Column names by which to partition the dataset Columns are partitioned in the order they are given partition_filename_cb : callable, A callback function that takes the partition key(s) as an argument and allow you to override the partition filename. If nothing is passed, the filename will consist of a uuid. use_legacy_dataset : bool Default is True unless a ``pyarrow.fs`` filesystem is passed. Set to False to enable the new code path (experimental, using the new Arrow Dataset API). This is more efficient when using partition columns, but does not (yet) support `partition_filename_cb` and `metadata_collector` keywords. **kwargs : dict, Additional kwargs for write_table function. See docstring for `write_table` or `ParquetWriter` for more information. Using `metadata_collector` in kwargs allows one to collect the file metadata instances of dataset pieces. The file paths in the ColumnChunkMetaData will be set relative to `root_path`. NFTrrerjzGThe '{}' argument is not supported with the new dataset implementation.rcsj|jdS)N)rHrQ)Z written_file)rrr file_visitor[sz&write_to_dataset..file_visitorpartition_filename_cbr)r)rrArrer.rjrwcsg|] }|qSrr)r,r8)dfrrrD|sz$write_to_dataset..rm)Zaxisz.No data left to save outside partition columnsrcSsg|]\}}dj||dqS)z{colname}={value})Zcolnamer$)rA)r,r{r(rrrrDs)resafez.parquetrr\r?r?)#r$rrErFrr1rAraZmake_write_optionsrselectrer.Z write_datasetr r!rvr+Z to_pandasZdroprmnamesrBrAgroupbytupler_ziprrZ from_pandasrrTrZ set_file_path)r root_pathZpartition_colsrxrr5rrBrerjrrwreZ write_optionsr.Z part_schemarrZdata_dfZ data_colsZ subschemar8rZsubgroupsubdirZsubtableoutfileZ relative_pathrr-r)ryrrwrite_to_datasets1                    rcKsLt||f|}|j|dk rHt|}x|D]}|j|q,W|j|dS)aT Write metadata-only Parquet file from schema. This can be used with `write_to_dataset` to generate `_common_metadata` and `_metadata` sidecar files. Parameters ---------- schema : pyarrow.Schema where : string or pyarrow.NativeFile metadata_collector : list where to collect metadata information. **kwargs : dict, Additional kwargs for ParquetWriter class. See docstring for `ParquetWriter` for more information. Examples -------- Write a dataset and collect metadata information. >>> metadata_collector = [] >>> write_to_dataset( ... table, root_path, ... metadata_collector=metadata_collector, **writer_kwargs) Write the `_common_metadata` parquet file without row groups statistics. >>> write_metadata( ... table.schema, root_path / '_common_metadata', **writer_kwargs) Write the `_metadata` parquet file with row groups statistics. >>> write_metadata( ... table.schema, root_path / '_metadata', ... metadata_collector=metadata_collector, **writer_kwargs) N)rrr:Zappend_row_groupsZwrite_metadata_file)rerrrrrQmrrrwrite_metadatas% rcCst||djS)a# Read FileMetadata from footer of a single Parquet file. Parameters ---------- where : str (filepath) or file-like object memory_map : bool, default False Create memory map when the source is a file path. Returns ------- metadata : FileMetadata )rZ)rMrQ)rrZrrrr:sr:cCst||djjS)a# Read effective Arrow schema from Parquet file metadata. Parameters ---------- where : str (filepath) or file-like object memory_map : bool, default False Create memory map when the source is a file path. Returns ------- schema : pyarrow.Schema )rZ)rMrer@)rrZrrr read_schemasr)r)T)N)rr\N)NTNFFNNNrrFNTN)N)NrmTrTNNFNNNNFrmF)NNNN)N)F)F)V collectionsr concurrentr functoolsrrrcollections.abcrZnumpyrr%rerI urllib.parserrZpyarrowrZ pyarrow.librZpyarrow._parquetrrrr r r r r Z pyarrow.fsrrrrrr Z pyarrow.utilrrrrrr"r*r:rMrLrMcompilerrrrrrryrrrrrr rrr)r,rKrLr-r6rSr1Z_read_table_docstringrkrAr_rrErrvrrr:rrrrrs     $    66 ew 'Fhk X & K  ,   1