MCPcopy Create free account
hub / github.com/apache/arrow / _visit_level

Function _visit_level

python/pyarrow/tests/parquet/test_dataset.py:562–592  ·  view source on GitHub ↗
(base_dir, level, part_keys)

Source from the content-addressed store, hash-verified

560 pathsep = getattr(fs, "pathsep", getattr(fs, "sep", "/"))
561
562 def _visit_level(base_dir, level, part_keys):
563 name, values = partition_spec[level]
564 for value in values:
565 this_part_keys = part_keys + [(name, value)]
566
567 level_dir = pathsep.join([
568 str(base_dir),
569 f'{name}={value}'
570 ])
571 fs.create_dir(level_dir)
572
573 if level == DEPTH - 1:
574 # Generate example data
575 from pyarrow.fs import FileType
576
577 file_path = pathsep.join([level_dir, guid()])
578 filtered_df = _filter_partition(df, this_part_keys)
579 part_table = pa.Table.from_pandas(filtered_df)
580 with fs.open_output_stream(file_path) as f:
581 _write_table(part_table, f)
582 assert fs.get_file_info(file_path).type != FileType.NotFound
583 assert fs.get_file_info(file_path).type == FileType.File
584
585 file_success = pathsep.join([level_dir, '_SUCCESS'])
586 with fs.open_output_stream(file_success) as f:
587 pass
588 else:
589 _visit_level(level_dir, level + 1, this_part_keys)
590 file_success = pathsep.join([level_dir, '_SUCCESS'])
591 with fs.open_output_stream(file_success) as f:
592 pass
593
594 _visit_level(base_dir, 0, [])
595

Callers 1

Calls 7

guidFunction · 0.90
_write_tableFunction · 0.90
_filter_partitionFunction · 0.85
joinMethod · 0.45
create_dirMethod · 0.45
open_output_streamMethod · 0.45
get_file_infoMethod · 0.45

Tested by

no test coverage detected