parquet.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
9 #include <cudf/io/detail/parquet.hpp>
10 #include <cudf/io/types.hpp>
12 #include <cudf/types.hpp>
13 #include <cudf/utilities/export.hpp>
15 
16 #include <iostream>
17 #include <memory>
18 #include <optional>
19 #include <string>
20 #include <utility>
21 #include <vector>
22 
23 namespace CUDF_EXPORT cudf {
24 namespace io {
31 constexpr size_t default_row_group_size_bytes =
32  std::numeric_limits<size_t>::max();
33 constexpr size_type default_row_group_size_rows = 1'000'000;
34 constexpr size_t default_max_page_size_bytes = 512 * 1024;
36 constexpr int32_t default_column_index_truncate_length = 64;
37 constexpr size_t default_max_dictionary_size = 1024 * 1024;
39 
49 [[nodiscard]] bool is_supported_read_parquet(compression_type compression);
50 
60 [[nodiscard]] bool is_supported_write_parquet(compression_type compression);
61 
63 
68  source_info _source;
69 
70  // Path in schema of column to read; `nullopt` is all
71  std::optional<std::vector<std::string>> _columns;
72 
73  // List of individual row groups to read (ignored if empty)
74  std::vector<std::vector<size_type>> _row_groups;
75  // Number of rows to skip from the start; Parquet stores the number of rows as int64_t
76  int64_t _skip_rows = 0;
77  // Number of rows to read; `nullopt` is all
78  std::optional<int64_t> _num_rows;
79 
80  // Read row groups that start at or after this byte offset into the source
81  size_t _skip_bytes = 0;
82  // Read row groups that start before _num_bytes bytes after _skip_bytes into the source
83  std::optional<size_t> _num_bytes;
84 
85  // Predicate filter as AST to filter output rows.
86  std::optional<std::reference_wrapper<ast::expression const>> _filter;
87 
88  // Whether to store string data as categorical type
89  bool _convert_strings_to_categories = false;
90  // Whether to use PANDAS metadata to load columns
91  bool _use_pandas_metadata = true;
92  // Whether to read and use ARROW schema
93  bool _use_arrow_schema = true;
94  // Whether to allow reading matching select columns from mismatched Parquet files.
95  bool _allow_mismatched_pq_schemas = false;
96  // Cast timestamp columns to a specific type
97  data_type _timestamp_type{type_id::EMPTY};
98  // Whether to use JIT compilation for filtering
99  bool _use_jit_filter = false;
100 
101  std::optional<std::vector<reader_column_schema>> _reader_column_schema;
102 
108  explicit parquet_reader_options(source_info src) : _source{std::move(src)} {}
109 
111 
112  public:
119  explicit parquet_reader_options() = default;
120 
129 
135  [[nodiscard]] source_info const& get_source() const { return _source; }
136 
142  [[nodiscard]] bool is_enabled_convert_strings_to_categories() const
143  {
144  return _convert_strings_to_categories;
145  }
146 
152  [[nodiscard]] bool is_enabled_use_pandas_metadata() const { return _use_pandas_metadata; }
153 
159  [[nodiscard]] bool is_enabled_use_arrow_schema() const { return _use_arrow_schema; }
160 
168  [[nodiscard]] bool is_enabled_allow_mismatched_pq_schemas() const
169  {
170  return _allow_mismatched_pq_schemas;
171  }
172 
178  [[nodiscard]] std::optional<std::vector<reader_column_schema>> get_column_schema() const
179  {
180  return _reader_column_schema;
181  }
182 
188  [[nodiscard]] int64_t get_skip_rows() const { return _skip_rows; }
189 
196  [[nodiscard]] std::optional<int64_t> const& get_num_rows() const { return _num_rows; }
197 
204  [[nodiscard]] size_t get_skip_bytes() const { return _skip_bytes; }
205 
212  [[nodiscard]] std::optional<size_t> const& get_num_bytes() const { return _num_bytes; }
213 
219  [[nodiscard]] auto const& get_columns() const { return _columns; }
220 
226  [[nodiscard]] auto const& get_row_groups() const { return _row_groups; }
227 
233  [[nodiscard]] auto const& get_filter() const { return _filter; }
234 
240  [[nodiscard]] data_type get_timestamp_type() const { return _timestamp_type; }
241 
247  [[nodiscard]] bool is_enabled_use_jit_filter() const { return _use_jit_filter; }
248 
254  void set_source(source_info src) { _source = std::move(src); }
255 
275  void set_columns(std::vector<std::string> col_names) { _columns = std::move(col_names); }
276 
294  void set_row_groups(std::vector<std::vector<size_type>> row_groups);
295 
326  void set_filter(ast::expression const& filter) { _filter = filter; }
327 
333  void enable_convert_strings_to_categories(bool val) { _convert_strings_to_categories = val; }
334 
340  void enable_use_pandas_metadata(bool val) { _use_pandas_metadata = val; }
341 
347  void enable_use_arrow_schema(bool val) { _use_arrow_schema = val; }
348 
356  void enable_allow_mismatched_pq_schemas(bool val) { _allow_mismatched_pq_schemas = val; }
357 
364  void set_column_schema(std::vector<reader_column_schema> val)
365  {
366  _reader_column_schema = std::move(val);
367  }
368 
374  void set_skip_rows(int64_t val);
375 
384  void set_num_rows(int64_t val);
385 
391  void set_skip_bytes(size_t val);
392 
398  void set_num_bytes(size_t val);
399 
405  void set_timestamp_type(data_type type) { _timestamp_type = type; }
406 };
407 
412  parquet_reader_options options;
413 
414  public:
422 
428  explicit parquet_reader_options_builder(source_info src) : options{std::move(src)} {}
429 
436  parquet_reader_options_builder& columns(std::vector<std::string> col_names)
437  {
438  options._columns = std::move(col_names);
439  return *this;
440  }
441 
448  parquet_reader_options_builder& row_groups(std::vector<std::vector<size_type>> row_groups)
449  {
450  options.set_row_groups(std::move(row_groups));
451  return *this;
452  }
453 
459  {
460  options.set_filter(filter);
461  return *this;
462  }
463 
471  {
472  options._convert_strings_to_categories = val;
473  return *this;
474  }
475 
483  {
484  options._use_pandas_metadata = val;
485  return *this;
486  }
487 
495  {
496  options._use_arrow_schema = val;
497  return *this;
498  }
499 
510  {
511  options._allow_mismatched_pq_schemas = val;
512  return *this;
513  }
514 
521  parquet_reader_options_builder& set_column_schema(std::vector<reader_column_schema> val)
522  {
523  options._reader_column_schema = std::move(val);
524  return *this;
525  }
526 
534  {
535  options.set_skip_rows(val);
536  return *this;
537  }
538 
549  {
550  options.set_num_rows(val);
551  return *this;
552  }
553 
561  {
562  options.set_skip_bytes(val);
563  return *this;
564  }
565 
573  {
574  options.set_num_bytes(val);
575  return *this;
576  }
577 
585  {
586  options._timestamp_type = type;
587  return *this;
588  }
589 
597  {
598  options._use_jit_filter = use_jit_filter;
599  return *this;
600  }
601 
605  operator parquet_reader_options&&() { return std::move(options); }
606 
614  parquet_reader_options&& build() { return std::move(options); }
615 };
616 
635  parquet_reader_options const& options,
638 
649  public:
657 
672  std::size_t chunk_read_limit,
673  parquet_reader_options const& options,
676 
697  std::size_t chunk_read_limit,
698  std::size_t pass_read_limit,
699  parquet_reader_options const& options,
702 
711 
717  [[nodiscard]] bool has_next() const;
718 
730  [[nodiscard]] table_with_metadata read_chunk() const;
731 
732  private:
733  std::unique_ptr<cudf::io::parquet::detail::chunked_reader> reader;
734 };
735  // end of group
747  int column_idx{};
748  bool is_descending{false};
749  bool is_nulls_first{true};
750 };
751 
756  // Specify the sink to use for writer output
757  sink_info _sink;
758  // Specify the compression format to use
759  compression_type _compression = compression_type::SNAPPY;
760  // Specify the level of statistics in the output file
762  // Optional associated metadata
763  std::optional<table_input_metadata> _metadata;
764  // Optional footer key_value_metadata
765  std::vector<std::map<std::string, std::string>> _user_data;
766  // Parquet writer can write INT96 or TIMESTAMP_MICROS. Defaults to TIMESTAMP_MICROS.
767  // If true then overrides any per-column setting in _metadata.
768  bool _write_timestamps_as_int96 = false;
769  // Parquet writer can write timestamps as UTC
770  // Defaults to true because libcudf timestamps are implicitly UTC
771  bool _write_timestamps_as_UTC = true;
772  // Whether to write ARROW schema
773  bool _write_arrow_schema = false;
774  // Maximum size of each row group (unless smaller than a single page)
775  size_t _row_group_size_bytes = default_row_group_size_bytes;
776  // Maximum number of rows in row group (unless smaller than a single page)
777  size_type _row_group_size_rows = default_row_group_size_rows;
778  // Maximum size of each page (uncompressed)
779  size_t _max_page_size_bytes = default_max_page_size_bytes;
780  // Maximum number of rows in a page
781  size_type _max_page_size_rows = default_max_page_size_rows;
782  // Maximum size of min or max values in column index
783  int32_t _column_index_truncate_length = default_column_index_truncate_length;
784  // When to use dictionary encoding for data
785  dictionary_policy _dictionary_policy = dictionary_policy::ADAPTIVE;
786  // Maximum size of column chunk dictionary (in bytes)
787  size_t _max_dictionary_size = default_max_dictionary_size;
788  // Maximum number of rows in a page fragment
789  std::optional<size_type> _max_page_fragment_size;
790  // Optional compression statistics
791  std::shared_ptr<writer_compression_statistics> _compression_stats;
792  // write V2 page headers?
793  bool _v2_page_headers = false;
794  // Which columns in _table are used for sorting
795  std::optional<std::vector<sorting_column>> _sorting_columns;
796 
797  protected:
803  explicit parquet_writer_options_base(sink_info sink) : _sink(std::move(sink)) {}
804 
805  public:
812 
818  [[nodiscard]] sink_info const& get_sink() const { return _sink; }
819 
825  [[nodiscard]] compression_type get_compression() const { return _compression; }
826 
832  [[nodiscard]] statistics_freq get_stats_level() const { return _stats_level; }
833 
839  [[nodiscard]] auto const& get_metadata() const { return _metadata; }
840 
846  [[nodiscard]] std::vector<std::map<std::string, std::string>> const& get_key_value_metadata()
847  const
848  {
849  return _user_data;
850  }
851 
857  [[nodiscard]] bool is_enabled_int96_timestamps() const { return _write_timestamps_as_int96; }
858 
864  [[nodiscard]] auto is_enabled_utc_timestamps() const { return _write_timestamps_as_UTC; }
865 
871  [[nodiscard]] auto is_enabled_write_arrow_schema() const { return _write_arrow_schema; }
872 
878  [[nodiscard]] auto get_row_group_size_bytes() const { return _row_group_size_bytes; }
879 
885  [[nodiscard]] auto get_row_group_size_rows() const { return _row_group_size_rows; }
886 
894  [[nodiscard]] auto get_max_page_size_bytes() const
895  {
896  return std::min(_max_page_size_bytes, get_row_group_size_bytes());
897  }
898 
906  [[nodiscard]] auto get_max_page_size_rows() const
907  {
908  return std::min(_max_page_size_rows, get_row_group_size_rows());
909  }
910 
916  [[nodiscard]] auto get_column_index_truncate_length() const
917  {
918  return _column_index_truncate_length;
919  }
920 
926  [[nodiscard]] dictionary_policy get_dictionary_policy() const { return _dictionary_policy; }
927 
933  [[nodiscard]] auto get_max_dictionary_size() const { return _max_dictionary_size; }
934 
940  [[nodiscard]] auto get_max_page_fragment_size() const { return _max_page_fragment_size; }
941 
947  [[nodiscard]] std::shared_ptr<writer_compression_statistics> get_compression_statistics() const
948  {
949  return _compression_stats;
950  }
951 
957  [[nodiscard]] auto is_enabled_write_v2_headers() const { return _v2_page_headers; }
958 
964  [[nodiscard]] auto const& get_sorting_columns() const { return _sorting_columns; }
965 
972 
978  void set_key_value_metadata(std::vector<std::map<std::string, std::string>> metadata);
979 
992 
999  void enable_int96_timestamps(bool req);
1000 
1006  void enable_utc_timestamps(bool val);
1007 
1014 
1020  void set_row_group_size_bytes(size_t size_bytes);
1021 
1028 
1034  void set_max_page_size_bytes(size_t size_bytes);
1035 
1042 
1048  void set_column_index_truncate_length(int32_t size_bytes);
1049 
1056 
1062  void set_max_dictionary_size(size_t size_bytes);
1063 
1070 
1076  void set_compression_statistics(std::shared_ptr<writer_compression_statistics> comp_stats);
1077 
1083  void enable_write_v2_headers(bool val);
1084 
1090  void set_sorting_columns(std::vector<sorting_column> sorting_columns);
1091 };
1092 
1096 template <class BuilderT, class OptionsT>
1098  OptionsT _options;
1099 
1100  protected:
1106  inline OptionsT& get_options() { return _options; }
1107 
1113  explicit parquet_writer_options_builder_base(OptionsT options);
1114 
1115  public:
1122 
1129  BuilderT& metadata(table_input_metadata metadata);
1130 
1137  BuilderT& key_value_metadata(std::vector<std::map<std::string, std::string>> metadata);
1138 
1146 
1153  BuilderT& compression(compression_type compression);
1154 
1161  BuilderT& row_group_size_bytes(size_t val);
1162 
1170 
1181  BuilderT& max_page_size_bytes(size_t val);
1182 
1191 
1205  BuilderT& column_index_truncate_length(int32_t val);
1206 
1225 
1237  BuilderT& max_dictionary_size(size_t val);
1238 
1250 
1258  std::shared_ptr<writer_compression_statistics> const& comp_stats);
1259 
1266  BuilderT& int96_timestamps(bool enabled);
1267 
1274  BuilderT& utc_timestamps(bool enabled);
1275 
1282  BuilderT& write_arrow_schema(bool enabled);
1283 
1290  BuilderT& write_v2_headers(bool enabled);
1291 
1298  BuilderT& sorting_columns(std::vector<sorting_column> sorting_columns);
1299 
1303  operator OptionsT&&();
1304 
1312  OptionsT&& build();
1313 };
1314 
1316 
1321  // Sets of columns to output
1322  table_view _table;
1323  // Partitions described as {start_row, num_rows} pairs
1324  std::vector<partition_info> _partitions;
1325  // Column chunks file paths to be set in the raw output metadata. One per output file
1326  std::vector<std::string> _column_chunks_file_paths;
1327 
1329 
1336  explicit parquet_writer_options(sink_info const& sink, table_view table);
1337 
1338  public:
1345 
1355 
1362 
1368  [[nodiscard]] table_view get_table() const { return _table; }
1369 
1375  [[nodiscard]] std::vector<partition_info> const& get_partitions() const { return _partitions; }
1376 
1382  [[nodiscard]] std::vector<std::string> const& get_column_chunks_file_paths() const
1383  {
1384  return _column_chunks_file_paths;
1385  }
1386 
1393  void set_partitions(std::vector<partition_info> partitions);
1394 
1401  void set_column_chunks_file_paths(std::vector<std::string> file_paths);
1402 };
1403 
1408  : public parquet_writer_options_builder_base<parquet_writer_options_builder,
1409  parquet_writer_options> {
1410  public:
1416  explicit parquet_writer_options_builder() = default;
1417 
1425 
1433  parquet_writer_options_builder& partitions(std::vector<partition_info> partitions);
1434 
1442  parquet_writer_options_builder& column_chunks_file_paths(std::vector<std::string> file_paths);
1443 };
1444 
1461 std::unique_ptr<std::vector<uint8_t>> write_parquet(
1463 
1473 std::unique_ptr<std::vector<uint8_t>> merge_row_group_metadata(
1474  std::vector<std::unique_ptr<std::vector<uint8_t>>> const& metadata_list);
1475 
1477 
1488 
1490 
1491  public:
1498 
1507 };
1508 
1513  : public parquet_writer_options_builder_base<chunked_parquet_writer_options_builder,
1514  chunked_parquet_writer_options> {
1515  public:
1522 
1529 };
1530 
1551  public:
1558 
1572 
1585  std::vector<partition_info> const& partitions = {});
1586 
1595  std::unique_ptr<std::vector<uint8_t>> close(
1596  std::vector<std::string> const& column_chunks_file_paths = {});
1597 
1599  std::unique_ptr<parquet::detail::writer> writer;
1600 };
1601 
1607 using parquet_chunked_writer [[deprecated("Use chunked_parquet_writer instead")]] =
1609  // end of group
1611 
1612 } // namespace io
1613 } // namespace CUDF_EXPORT cudf
Indicator for the logical data type of an element in a column.
Definition: types.hpp:238
The chunked parquet reader class to read Parquet file iteratively in to a series of tables,...
Definition: parquet.hpp:648
table_with_metadata read_chunk() const
Read a chunk of rows in the given Parquet file.
bool has_next() const
Check if there is any data in the given file has not yet read.
chunked_parquet_reader(std::size_t chunk_read_limit, std::size_t pass_read_limit, parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Constructor for chunked reader.
chunked_parquet_reader(std::size_t chunk_read_limit, parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Constructor for chunked reader.
~chunked_parquet_reader()
Destructor, destroying the internal reader instance.
chunked_parquet_reader()
Default constructor, this should never be used.
Class to build chunked_parquet_writer_options.
Definition: parquet.hpp:1514
chunked_parquet_writer_options_builder()=default
Default constructor.
chunked_parquet_writer_options_builder(sink_info const &sink)
Constructor from sink.
Settings for chunked_parquet_writer.
Definition: parquet.hpp:1481
static chunked_parquet_writer_options_builder builder(sink_info const &sink)
creates builder to build chunked_parquet_writer_options.
chunked_parquet_writer_options()=default
Default constructor.
chunked parquet writer class to handle options and write tables in chunks.
Definition: parquet.hpp:1550
~chunked_parquet_writer()
Default destructor. This is added to not leak detail API.
std::unique_ptr< std::vector< uint8_t > > close(std::vector< std::string > const &column_chunks_file_paths={})
Finishes the chunked/streamed write process.
chunked_parquet_writer(chunked_parquet_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
Constructor with chunked writer options.
std::unique_ptr< parquet::detail::writer > writer
Unique pointer to impl writer class.
Definition: parquet.hpp:1599
chunked_parquet_writer & write(table_view const &table, std::vector< partition_info > const &partitions={})
Writes table to output.
chunked_parquet_writer()
Default constructor, this should never be used. This is added just to satisfy cython....
Builds parquet_reader_options to use for read_parquet().
Definition: parquet.hpp:411
parquet_reader_options_builder & num_bytes(size_t val)
Sets number of bytes after skipping to end reading row groups at.
Definition: parquet.hpp:572
parquet_reader_options_builder & use_arrow_schema(bool val)
Sets to enable/disable use of arrow schema to read.
Definition: parquet.hpp:494
parquet_reader_options_builder(source_info src)
Constructor from source info.
Definition: parquet.hpp:428
parquet_reader_options_builder & skip_rows(int64_t val)
Sets number of rows to skip.
Definition: parquet.hpp:533
parquet_reader_options_builder & allow_mismatched_pq_schemas(bool val)
Sets to enable/disable reading of matching projected and filter columns from mismatched Parquet sourc...
Definition: parquet.hpp:509
parquet_reader_options_builder & columns(std::vector< std::string > col_names)
Sets names of the columns to be read.
Definition: parquet.hpp:436
parquet_reader_options_builder & skip_bytes(size_t val)
Sets bytes to skip before starting reading row groups.
Definition: parquet.hpp:560
parquet_reader_options_builder & timestamp_type(data_type type)
timestamp_type used to cast timestamp columns.
Definition: parquet.hpp:584
parquet_reader_options_builder & use_pandas_metadata(bool val)
Sets to enable/disable use of pandas metadata to read.
Definition: parquet.hpp:482
parquet_reader_options_builder()=default
Default constructor.
parquet_reader_options_builder & num_rows(int64_t val)
Sets number of rows to read.
Definition: parquet.hpp:548
parquet_reader_options_builder & row_groups(std::vector< std::vector< size_type >> row_groups)
Sets vector of individual row groups to read.
Definition: parquet.hpp:448
parquet_reader_options_builder & set_column_schema(std::vector< reader_column_schema > val)
Sets reader metadata.
Definition: parquet.hpp:521
parquet_reader_options && build()
move parquet_reader_options member once it's built.
Definition: parquet.hpp:614
parquet_reader_options_builder & filter(ast::expression const &filter)
Sets AST based filter for predicate pushdown.
Definition: parquet.hpp:458
parquet_reader_options_builder & use_jit_filter(bool use_jit_filter)
Enable/disable use of JIT for filter step.
Definition: parquet.hpp:596
parquet_reader_options_builder & convert_strings_to_categories(bool val)
Sets enable/disable conversion of strings to categories.
Definition: parquet.hpp:470
Settings for read_parquet().
Definition: parquet.hpp:67
data_type get_timestamp_type() const
Returns timestamp type used to cast timestamp columns.
Definition: parquet.hpp:240
parquet_reader_options()=default
Default constructor.
void enable_allow_mismatched_pq_schemas(bool val)
Sets to enable/disable reading of matching projected and filter columns from mismatched Parquet sourc...
Definition: parquet.hpp:356
void set_skip_rows(int64_t val)
Sets number of rows to skip.
bool is_enabled_use_jit_filter() const
Returns whether to use JIT compilation for filtering.
Definition: parquet.hpp:247
size_t get_skip_bytes() const
Returns bytes to skip before starting reading row groups.
Definition: parquet.hpp:204
void set_columns(std::vector< std::string > col_names)
Sets the names of columns to be read from all input sources.
Definition: parquet.hpp:275
static parquet_reader_options_builder builder(source_info src=source_info{})
Creates a parquet_reader_options_builder to build parquet_reader_options. By default,...
void enable_convert_strings_to_categories(bool val)
Sets to enable/disable conversion of strings to categories.
Definition: parquet.hpp:333
std::optional< std::vector< reader_column_schema > > get_column_schema() const
Returns optional tree of metadata.
Definition: parquet.hpp:178
void set_skip_bytes(size_t val)
Sets bytes to skip before starting reading row groups.
source_info const & get_source() const
Returns source info.
Definition: parquet.hpp:135
auto const & get_row_groups() const
Returns list of individual row groups to be read.
Definition: parquet.hpp:226
void set_row_groups(std::vector< std::vector< size_type >> row_groups)
Specifies which row groups to read from each input source.
void set_source(source_info src)
Set a new source location.
Definition: parquet.hpp:254
auto const & get_columns() const
Returns names of column to be read, if set.
Definition: parquet.hpp:219
void set_timestamp_type(data_type type)
Sets timestamp_type used to cast timestamp columns.
Definition: parquet.hpp:405
std::optional< int64_t > const & get_num_rows() const
Returns number of rows to read.
Definition: parquet.hpp:196
bool is_enabled_convert_strings_to_categories() const
Returns boolean depending on whether strings should be converted to categories.
Definition: parquet.hpp:142
void set_num_rows(int64_t val)
Sets number of rows to read.
void set_num_bytes(size_t val)
Sets number of bytes after skipping to end reading row groups at.
void enable_use_pandas_metadata(bool val)
Sets to enable/disable use of pandas metadata to read.
Definition: parquet.hpp:340
void enable_use_arrow_schema(bool val)
Sets to enable/disable use of arrow schema to read.
Definition: parquet.hpp:347
bool is_enabled_use_pandas_metadata() const
Returns boolean depending on whether to use pandas metadata while reading.
Definition: parquet.hpp:152
bool is_enabled_allow_mismatched_pq_schemas() const
Returns boolean depending on whether to read matching projected and filter columns from mismatched Pa...
Definition: parquet.hpp:168
void set_column_schema(std::vector< reader_column_schema > val)
Sets reader column schema.
Definition: parquet.hpp:364
bool is_enabled_use_arrow_schema() const
Returns boolean depending on whether to use arrow schema while reading.
Definition: parquet.hpp:159
void set_filter(ast::expression const &filter)
Sets AST based filter for predicate pushdown.
Definition: parquet.hpp:326
auto const & get_filter() const
Returns AST based filter for predicate pushdown.
Definition: parquet.hpp:233
std::optional< size_t > const & get_num_bytes() const
Returns number of bytes after skipping to end reading row groups at.
Definition: parquet.hpp:212
int64_t get_skip_rows() const
Returns number of rows to skip from the start.
Definition: parquet.hpp:188
Base settings for write_parquet() and chunked_parquet_writer.
Definition: parquet.hpp:755
void enable_utc_timestamps(bool val)
Sets preference for writing timestamps as UTC. Write timestamps as UTC if set to true.
void enable_write_v2_headers(bool val)
Sets preference for V2 page headers. Write V2 page headers if set to true.
auto const & get_sorting_columns() const
Returns the sorting_columns.
Definition: parquet.hpp:964
auto get_row_group_size_bytes() const
Returns maximum row group size, in bytes.
Definition: parquet.hpp:878
bool is_enabled_int96_timestamps() const
Returns true if timestamps will be written as INT96.
Definition: parquet.hpp:857
void set_metadata(table_input_metadata metadata)
Sets metadata.
void set_row_group_size_rows(size_type size_rows)
Sets the maximum row group size, in rows.
parquet_writer_options_base(sink_info sink)
Constructor from sink.
Definition: parquet.hpp:803
void set_stats_level(statistics_freq sf)
Sets the level of statistics.
auto get_row_group_size_rows() const
Returns maximum row group size, in rows.
Definition: parquet.hpp:885
parquet_writer_options_base()=default
Default constructor.
void set_max_page_size_bytes(size_t size_bytes)
Sets the maximum uncompressed page size, in bytes.
void set_sorting_columns(std::vector< sorting_column > sorting_columns)
Sets sorting columns.
auto is_enabled_write_arrow_schema() const
Returns true if arrow schema will be written.
Definition: parquet.hpp:871
auto is_enabled_write_v2_headers() const
Returns true if V2 page headers should be written.
Definition: parquet.hpp:957
void set_dictionary_policy(dictionary_policy policy)
Sets the policy for dictionary use.
auto get_max_page_size_bytes() const
Returns the maximum uncompressed page size, in bytes.
Definition: parquet.hpp:894
void set_max_dictionary_size(size_t size_bytes)
Sets the maximum dictionary size, in bytes.
compression_type get_compression() const
Returns compression format used.
Definition: parquet.hpp:825
auto get_max_dictionary_size() const
Returns maximum dictionary size, in bytes.
Definition: parquet.hpp:933
void set_compression(compression_type compression)
Sets compression type.
dictionary_policy get_dictionary_policy() const
Returns policy for dictionary use.
Definition: parquet.hpp:926
void set_compression_statistics(std::shared_ptr< writer_compression_statistics > comp_stats)
Sets the pointer to the output compression statistics.
std::shared_ptr< writer_compression_statistics > get_compression_statistics() const
Returns a shared pointer to the user-provided compression statistics.
Definition: parquet.hpp:947
void set_max_page_size_rows(size_type size_rows)
Sets the maximum page size, in rows.
auto get_max_page_fragment_size() const
Returns maximum page fragment size, in rows.
Definition: parquet.hpp:940
void set_key_value_metadata(std::vector< std::map< std::string, std::string >> metadata)
Sets metadata.
void set_max_page_fragment_size(size_type size_rows)
Sets the maximum page fragment size, in rows.
void enable_write_arrow_schema(bool val)
Sets preference for writing arrow schema. Write arrow schema if set to true.
auto is_enabled_utc_timestamps() const
Returns true if timestamps will be written as UTC.
Definition: parquet.hpp:864
void set_row_group_size_bytes(size_t size_bytes)
Sets the maximum row group size, in bytes.
void enable_int96_timestamps(bool req)
Sets timestamp writing preferences. INT96 timestamps will be written if true and TIMESTAMP_MICROS wil...
statistics_freq get_stats_level() const
Returns level of statistics requested in output file.
Definition: parquet.hpp:832
std::vector< std::map< std::string, std::string > > const & get_key_value_metadata() const
Returns Key-Value footer metadata information.
Definition: parquet.hpp:846
auto const & get_metadata() const
Returns associated metadata.
Definition: parquet.hpp:839
auto get_max_page_size_rows() const
Returns maximum page size, in rows.
Definition: parquet.hpp:906
auto get_column_index_truncate_length() const
Returns maximum length of min or max values in column index, in bytes.
Definition: parquet.hpp:916
void set_column_index_truncate_length(int32_t size_bytes)
Sets the maximum length of min or max values in column index, in bytes.
sink_info const & get_sink() const
Returns sink info.
Definition: parquet.hpp:818
Base class for Parquet options builders.
Definition: parquet.hpp:1097
BuilderT & compression(compression_type compression)
Sets compression type.
BuilderT & key_value_metadata(std::vector< std::map< std::string, std::string >> metadata)
Sets Key-Value footer metadata.
OptionsT & get_options()
Return reference to the options object being built.
Definition: parquet.hpp:1106
BuilderT & utc_timestamps(bool enabled)
Set to true if timestamps are to be written as UTC.
BuilderT & max_dictionary_size(size_t val)
Sets the maximum dictionary size, in bytes.
BuilderT & max_page_size_bytes(size_t val)
Sets the maximum uncompressed page size, in bytes.
OptionsT && build()
move options member once it's built.
BuilderT & stats_level(statistics_freq sf)
Sets the level of statistics.
BuilderT & column_index_truncate_length(int32_t val)
Sets the desired maximum size in bytes for min and max values in the column index.
BuilderT & compression_statistics(std::shared_ptr< writer_compression_statistics > const &comp_stats)
Sets the pointer to the output compression statistics.
BuilderT & metadata(table_input_metadata metadata)
Sets metadata.
BuilderT & dictionary_policy(enum dictionary_policy val)
Sets the policy for dictionary use.
parquet_writer_options_builder_base(OptionsT options)
Constructor from options.
BuilderT & int96_timestamps(bool enabled)
Sets whether int96 timestamps are written or not.
BuilderT & row_group_size_bytes(size_t val)
Sets the maximum row group size, in bytes.
BuilderT & sorting_columns(std::vector< sorting_column > sorting_columns)
Sets column sorting metadata.
BuilderT & write_arrow_schema(bool enabled)
Set to true if arrow schema is to be written.
parquet_writer_options_builder_base()=default
Default constructor.
BuilderT & write_v2_headers(bool enabled)
Set to true if V2 page headers are to be written.
BuilderT & max_page_fragment_size(size_type val)
Sets the maximum page fragment size, in rows.
BuilderT & row_group_size_rows(size_type val)
Sets the maximum number of rows in output row groups.
BuilderT & max_page_size_rows(size_type val)
Sets the maximum page size, in rows. Counts only top-level rows, ignoring any nesting....
Class to build parquet_writer_options.
Definition: parquet.hpp:1409
parquet_writer_options_builder(sink_info const &sink, table_view const &table)
Constructor from sink and table.
parquet_writer_options_builder()=default
Default constructor.
parquet_writer_options_builder & partitions(std::vector< partition_info > partitions)
Sets partitions in parquet_writer_options.
parquet_writer_options_builder & column_chunks_file_paths(std::vector< std::string > file_paths)
Sets column chunks file path to be set in the raw output metadata.
Settings for write_parquet().
Definition: parquet.hpp:1320
void set_partitions(std::vector< partition_info > partitions)
Sets partitions.
static parquet_writer_options_builder builder(sink_info const &sink, table_view const &table)
Create builder to create parquet_writer_options.
parquet_writer_options()=default
Default constructor.
std::vector< std::string > const & get_column_chunks_file_paths() const
Returns Column chunks file paths to be set in the raw output metadata.
Definition: parquet.hpp:1382
table_view get_table() const
Returns table_view.
Definition: parquet.hpp:1368
void set_column_chunks_file_paths(std::vector< std::string > file_paths)
Sets column chunks file path to be set in the raw output metadata.
static parquet_writer_options_builder builder()
Create builder to create parquet_writer_options.
std::vector< partition_info > const & get_partitions() const
Returns partitions.
Definition: parquet.hpp:1375
Metadata for a table.
Definition: io/types.hpp:893
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:189
A set of cudf::column's of the same size.
Definition: table.hpp:29
rmm::cuda_stream_view const get_default_stream()
Get the current default stream.
constexpr size_type default_row_group_size_rows
1 million rows per row group
Definition: parquet.hpp:33
constexpr int32_t default_column_index_truncate_length
truncate to 64 bytes
Definition: parquet.hpp:36
constexpr size_t default_row_group_size_bytes
Infinite bytes per row group.
Definition: parquet.hpp:31
bool is_supported_write_parquet(compression_type compression)
Check if the compression type is supported for writing Parquet files.
constexpr size_type default_max_page_fragment_size
5000 rows per page fragment
Definition: parquet.hpp:38
constexpr size_t default_max_dictionary_size
1MB dictionary size
Definition: parquet.hpp:37
bool is_supported_read_parquet(compression_type compression)
Check if the compression type is supported for reading Parquet files.
table_with_metadata read_parquet(parquet_reader_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Reads a Parquet dataset into a set of columns.
constexpr size_t default_max_page_size_bytes
512KB per page
Definition: parquet.hpp:34
constexpr size_type default_max_page_size_rows
20k rows per page
Definition: parquet.hpp:35
statistics_freq
Column statistics granularity type for parquet/orc writers.
Definition: io/types.hpp:85
dictionary_policy
Control use of dictionary encoding for parquet writer.
Definition: io/types.hpp:214
compression_type
Compression algorithms.
Definition: io/types.hpp:46
@ STATISTICS_ROWGROUP
Per-Rowgroup column statistics.
Definition: io/types.hpp:87
@ ADAPTIVE
Use dictionary when it will not impact compression.
Definition: io/types.hpp:216
std::unique_ptr< std::vector< uint8_t > > merge_row_group_metadata(std::vector< std::unique_ptr< std::vector< uint8_t >>> const &metadata_list)
Merges multiple raw metadata blobs that were previously created by write_parquet into a single metada...
std::unique_ptr< std::vector< uint8_t > > write_parquet(parquet_writer_options const &options, rmm::cuda_stream_view stream=cudf::get_default_stream())
Writes a set of columns to parquet format.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
detail::cccl_async_resource_ref< cuda::mr::resource_ref< cuda::mr::device_accessible > > device_async_resource_ref
std::vector< std::unique_ptr< column > > filter(std::vector< column_view > const &predicate_columns, std::string const &predicate_udf, std::vector< column_view > const &filter_columns, bool is_ptx, std::optional< void * > user_data=std::nullopt, null_aware is_null_aware=null_aware::NO, rmm::cuda_stream_view stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a new column by applying a filter function against every element of the input columns.
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
cuDF-IO API type definitions
cuDF interfaces
Definition: host_udf.hpp:26
A generic expression that can be evaluated to return a value.
Definition: expressions.hpp:61
Destination information for write interfaces.
Definition: io/types.hpp:471
Struct used to describe column sorting metadata.
Definition: parquet.hpp:746
Source information for read interfaces.
Definition: io/types.hpp:316
Table with table metadata used by io readers to return the metadata by value.
Definition: io/types.hpp:292
Class definitions for (mutable)_table_view
Type declarations for libcudf.