def dataset_rows_count(self, dataset: DatasetRecord, version=None) -> int:
        """Returns total number of rows in a dataset"""
        dr = self.dataset_rows(dataset, version)
        table = dr.get_table()
        query = sa.select(sa.func.count(table.c.sys__id))
        (res,) = self.db.execute(query)
        return res[0]
Returns total number of rows in a dataset
src/datachain/data_storage/warehouse.py