Skip to content

Conversation

@ntrinquier
Copy link

No description provided.

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good so far ... I've left some feedback that should help you out


let input_schema = input_rel.as_ref().borrow().schema().clone();

let compiled_expr = compile_scalar_expr(&self, expr, &input_schema)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LIMIT expression will be a literal e.g. LIMIT 10 so I don't think we need to compile and evaluate the expression but just use pattern matching to extract the number.

match expr {
        &Expr::Literal(ref value) => /* extract value */,
        _ => /* error - only literals are supported */
}

``

input: Rc<RefCell<Relation>>,
expr: RuntimeExpr,
schema: Arc<Schema>,
num_consumed_rows: i64,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add limit: usize

input: Rc<RefCell<Relation>>,
expr: RuntimeExpr,
schema: Arc<Schema>,
num_consumed_rows: i64,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_consumed_rows should be usize

fn next(&mut self) -> Result<Option<RecordBatch>> {
match self.input.borrow_mut().next()? {
Some(batch) => {
match self.expr.get_func()(&batch)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to evaluate the expression, use limit field from struct

}

//TODO: move into Arrow array_ops
fn filter(a: &Array, num_rows_to_read: i64) -> Result<ArrayRef> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename filter to limit

@ntrinquier
Copy link
Author

Thanks a lot @andygrove

I extracted the limit and cast it with as, I don't know if there is a safer alternative though.

@codecov-io
Copy link

Codecov Report

Merging #3669 into master will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3669      +/-   ##
==========================================
- Coverage   87.85%   87.76%   -0.09%     
==========================================
  Files         689      689              
  Lines       84012    84023      +11     
  Branches     1081     1081              
==========================================
- Hits        73805    73745      -60     
- Misses      10094    10163      +69     
- Partials      113      115       +2
Impacted Files Coverage Δ
go/arrow/math/int64_avx2_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/memory/memory_avx2_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/float64_avx2_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/uint64_avx2_amd64.go 0% <0%> (-100%) ⬇️
go/arrow/math/float64_amd64.go 33.33% <0%> (-33.34%) ⬇️
go/arrow/math/int64_amd64.go 33.33% <0%> (-33.34%) ⬇️
go/arrow/math/uint64_amd64.go 33.33% <0%> (-33.34%) ⬇️
go/arrow/math/math_amd64.go 31.57% <0%> (-31.58%) ⬇️
go/arrow/memory/memory_amd64.go 28.57% <0%> (-28.58%) ⬇️
js/src/ipc/metadata/json.ts 92.39% <0%> (-4.35%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a374c3c...e93df93. Read the comment docs.

.collect();

let limited_batch: RecordBatch =
RecordBatch::new(Arc::new(Schema::empty()), limited_columns?);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new batch needs the same schema as the original, not an empty schema

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is fixed, I'm ready to approve. Thanks @ntrinquier !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed that makes more sense. filter is also creating the new batch with an empty schema, so I guess this would have to be changed there too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, good catch, yes I'll file a bug for that

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants