diff --git a/python/python/lance/fragment.py b/python/python/lance/fragment.py index ce9334c682..49f0573007 100644 --- a/python/python/lance/fragment.py +++ b/python/python/lance/fragment.py @@ -366,9 +366,9 @@ def fragment_id(self): def count_rows( self, filter: Optional[Union[pa.compute.Expression, str]] = None ) -> int: - if filter is not None: - raise ValueError("Does not support filter at the moment") - return self._fragment.count_rows() + if isinstance(filter, pa.compute.Expression): + raise ValueError("Does not support pyarrow Expression at the moment") + return self._fragment.count_rows(filter) @property def num_deletions(self) -> int: diff --git a/python/src/fragment.rs b/python/src/fragment.rs index b5cb75fc3a..d29783921c 100644 --- a/python/src/fragment.rs +++ b/python/src/fragment.rs @@ -1,16 +1,5 @@ -// Copyright 2024 Lance Developers. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright The Lance Authors use std::fmt::Write as _; use std::sync::Arc; @@ -127,11 +116,11 @@ impl FileFragment { PyLance(self.fragment.metadata().clone()) } - #[pyo3(signature=(_filter=None))] - fn count_rows(&self, _filter: Option) -> PyResult { + #[pyo3(signature=(filter=None))] + fn count_rows(&self, filter: Option) -> PyResult { RT.runtime.block_on(async { self.fragment - .count_rows() + .count_rows(filter) .await .map_err(|e| PyIOError::new_err(e.to_string())) })