Skip to content

Commit

Permalink
add fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyxu committed Dec 31, 2024
1 parent f16f2fd commit f2bb5eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
6 changes: 3 additions & 3 deletions python/python/lance/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 5 additions & 16 deletions python/src/fragment.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -127,11 +116,11 @@ impl FileFragment {
PyLance(self.fragment.metadata().clone())
}

#[pyo3(signature=(_filter=None))]
fn count_rows(&self, _filter: Option<String>) -> PyResult<usize> {
#[pyo3(signature=(filter=None))]
fn count_rows(&self, filter: Option<String>) -> PyResult<usize> {
RT.runtime.block_on(async {
self.fragment
.count_rows()
.count_rows(filter)
.await
.map_err(|e| PyIOError::new_err(e.to_string()))
})
Expand Down

0 comments on commit f2bb5eb

Please sign in to comment.