Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rust): Change fn schema to fn collect_schema #18261

Merged
merged 1 commit into from
Aug 19, 2024
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
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/frame/cached_arenas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl LazyFrame {
///
/// Returns an `Err` if the logical plan has already encountered an error (i.e., if
/// `self.collect()` would fail), `Ok` otherwise.
pub fn schema(&mut self) -> PolarsResult<SchemaRef> {
pub fn collect_schema(&mut self) -> PolarsResult<SchemaRef> {
let mut cached_arenas = self.cached_arena.lock().unwrap();

match &mut *cached_arenas {
Expand Down
4 changes: 2 additions & 2 deletions crates/polars-lazy/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ impl LazyFrame {
options.index_column = name.as_ref().into();
} else {
let output_field = index_column
.to_field(&self.schema().unwrap(), Context::Default)
.to_field(&self.collect_schema().unwrap(), Context::Default)
.unwrap();
return self.with_column(index_column).rolling(
Expr::Column(Arc::from(output_field.name().as_str())),
Expand Down Expand Up @@ -1090,7 +1090,7 @@ impl LazyFrame {
options.index_column = name.as_ref().into();
} else {
let output_field = index_column
.to_field(&self.schema().unwrap(), Context::Default)
.to_field(&self.collect_schema().unwrap(), Context::Default)
.unwrap();
return self.with_column(index_column).group_by_dynamic(
Expr::Column(Arc::from(output_field.name().as_str())),
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/tests/optimization_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ fn test_with_column_prune() -> PolarsResult<()> {
matches!(lp, SimpleProjection { .. } | DataFrameScan { .. })
}));
assert_eq!(
q.schema().unwrap().as_ref(),
q.collect_schema().unwrap().as_ref(),
&Schema::from_iter([Field::new("c1", DataType::Int32)])
);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/tests/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ fn test_when_then_schema() -> PolarsResult<()> {
.select([when(col("A").gt(lit(1)))
.then(Null {}.lit())
.otherwise(col("A"))])
.schema();
.collect_schema();
assert_ne!(schema?.get_at_index(0).unwrap().1, &DataType::Null);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-python/src/lazyframe/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ impl PyLazyFrame {

fn collect_schema(&mut self, py: Python) -> PyResult<PyObject> {
let schema = py
.allow_threads(|| self.ldf.schema())
.allow_threads(|| self.ldf.collect_schema())
.map_err(PyPolarsErr::from)?;

let schema_dict = PyDict::new_bound(py);
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-python/src/lazygroupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PyLazyGroupBy {
let schema = match schema {
Some(schema) => Arc::new(schema.0),
None => LazyFrame::from(lgb.logical_plan.clone())
.schema()
.collect_schema()
.map_err(PyPolarsErr::from)?,
};

Expand Down
Loading