Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion R/functions-lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ pl__collect_all <- function(
# TODO: add support for argument `optimizations`
optflags <- QueryOptFlags()
check_is_S7(optflags, QueryOptFlags)
validate(optflags)

lfs <- lapply(lazy_frames, \(x) x$`_ldf`)

Expand Down
8 changes: 7 additions & 1 deletion src/rust/src/conversion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use categorical::PlRCategories;
use polars::series::ops::NullBehavior;
use savvy::{
ListSexp, NotAvailableValue, NumericScalar, NumericSexp, NumericTypedSexp, Sexp, StringSexp,
TypedSexp,
TypedSexp, savvy_err,
};
use search_sorted::SearchSortedSide;
use std::{num::NonZeroUsize, str::FromStr};
Expand Down Expand Up @@ -40,6 +40,12 @@ impl<T> From<T> for Wrap<T> {
}
}

// TODO: Move this to upstream?
pub(crate) fn try_extract_attribute(obj: &Sexp, attr_name: &str) -> savvy::Result<Sexp> {
obj.get_attrib(attr_name)?
.ok_or(savvy_err!("Attribute '{attr_name}' does not exist."))
}

impl TryFrom<&str> for PlRDataType {
type Error = String;

Expand Down
16 changes: 7 additions & 9 deletions src/rust/src/conversion/s7.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::try_extract_attribute;
use crate::lazyframe::PlROptFlags;
use savvy::{Sexp, TypedSexp};
use savvy::Sexp;

impl TryFrom<Sexp> for PlROptFlags {
type Error = savvy::Error;
Expand All @@ -23,13 +24,10 @@ impl TryFrom<Sexp> for PlROptFlags {
"streaming",
];

ATTR_NAMES.iter().for_each(|attr_name| {
// Safety: validated on the R side
let attr_value = match obj.get_attrib(attr_name).unwrap().unwrap().into_typed() {
TypedSexp::Logical(l) => l.iter().next().unwrap(),
_ => unreachable!(),
};
match *attr_name {
for &attr_name in ATTR_NAMES {
let attr_value: bool = try_extract_attribute(&obj, attr_name)?.try_into()?;

match attr_name {
"type_coercion" => opts.set_type_coercion(attr_value),
"type_check" => opts.set_type_check(attr_value),
"predicate_pushdown" => opts.set_predicate_pushdown(attr_value),
Expand All @@ -45,7 +43,7 @@ impl TryFrom<Sexp> for PlROptFlags {
"streaming" => opts.set_streaming(attr_value),
_ => unreachable!(),
}
});
}
Ok(opts)
}
}