diff --git a/libtsuba/include/tsuba/ParquetReader.h b/libtsuba/include/tsuba/ParquetReader.h index 3fb47f67cb..f403f85995 100644 --- a/libtsuba/include/tsuba/ParquetReader.h +++ b/libtsuba/include/tsuba/ParquetReader.h @@ -68,6 +68,10 @@ class KATANA_EXPORT ParquetReader { /// \param uri an identifier for a parquet file katana::Result NumColumns(const katana::Uri& uri); + /// Get the number of rows for the table stored in a parquet file + /// \param uri an identifier for a parquet file + katana::Result NumRows(const katana::Uri& uri); + private: ParquetReader(std::optional slice, bool make_cannonical) : slice_(slice), make_cannonical_{make_cannonical} {} diff --git a/libtsuba/src/ParquetReader.cpp b/libtsuba/src/ParquetReader.cpp index db772b08b9..6d05180864 100644 --- a/libtsuba/src/ParquetReader.cpp +++ b/libtsuba/src/ParquetReader.cpp @@ -272,13 +272,19 @@ tsuba::ParquetReader::NumColumns(const katana::Uri& uri) { } std::unique_ptr reader( std::move(reader_res.value())); + return reader->parquet_reader()->metadata()->num_columns(); +} - std::shared_ptr schema; - auto status = reader->GetSchema(&schema); - if (!status.ok()) { - return KATANA_ERROR(ErrorCode::ArrowError, "reading schema: {}", status); +Result +tsuba::ParquetReader::NumRows(const katana::Uri& uri) { + auto reader_res = MakeFileReader(uri, 0, 0); + if (!reader_res) { + return reader_res.error(); } - return schema->num_fields(); + std::unique_ptr reader( + std::move(reader_res.value())); + + return reader->parquet_reader()->metadata()->num_rows(); } Result>