Skip to content

Commit

Permalink
fix issue reading memo files with leading spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
casperhart authored and tmontaigu committed Sep 27, 2023
1 parent 0ceffe6 commit ad311b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/datafusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use datafusion::arrow::datatypes::{DataType, Field, Schema, SchemaRef};
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::datasource::provider::TableProviderFactory;
use datafusion::datasource::{TableProvider, TableType};
use datafusion::error::Result;
use datafusion::error::{DataFusionError, Result};
use datafusion::execution::context::{SessionState, TaskContext};
use datafusion::physical_plan::expressions::PhysicalSortExpr;
use datafusion::physical_plan::memory::MemoryStream;
Expand Down Expand Up @@ -257,9 +257,8 @@ impl ExecutionPlan for DbaseExec {
if l >= self.limit {
break;
}
let Some(r) = record.ok() else {
continue;
};

let r = record.map_err(|e| DataFusionError::Execution(e.to_string()))?;

for i in 0..self.projections.len() {
match r.get(&dbase_field_names[self.projections[i]]).unwrap() {
Expand Down
3 changes: 1 addition & 2 deletions src/field/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,11 @@ impl FieldValue {
FieldType::Memo => {
let index_in_memo = if field_info.field_length > 4 {
// let string = read_string_of_len(&mut source, field_info.field_length)?;
let trimmed_value = trim_field_data(field_bytes, TrimOption::End);
let trimmed_value = trim_field_data(field_bytes, TrimOption::BeginEnd);
if trimmed_value.is_empty() {
return Ok(FieldValue::Memo(String::from("")));
} else {
encoding.decode(trimmed_value)?.parse::<u32>()?
// string.parse::<u32>()?
}
} else {
let mut le_bytes = [0u8; std::mem::size_of::<u32>()];
Expand Down

0 comments on commit ad311b6

Please sign in to comment.