Skip to content

Commit

Permalink
support register_csv and sql (lint)
Browse files Browse the repository at this point in the history
  • Loading branch information
jychen7 committed Jul 6, 2022
1 parent 299e8b5 commit 976262e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions ext/datafusion_ruby/src/record_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use datafusion::arrow::{
datatypes::DataType,
record_batch::RecordBatch,
};
use magnus::{Value, Error};
use magnus::{Error, Value};

use crate::errors::DataFusionError;
use std::collections::HashMap;
Expand Down Expand Up @@ -31,20 +31,16 @@ impl RbRecordBatch {
}
DataType::Float64 => {
let array = column.as_any().downcast_ref::<Float64Array>().unwrap();
array
.values()
.iter()
.map(|v| (*v as f64).into())
.collect()
},
array.values().iter().map(|v| (*v as f64).into()).collect()
}
DataType::Utf8 => {
let array = column.as_any().downcast_ref::<StringArray>().unwrap();
let mut values: Vec<Value> = vec![];
for i in 0..(column.len()) {
values.push(std::string::String::from(array.value(i)).into())
}
values
},
}
unknown => {
return Err(DataFusionError::CommonError(format!(
"unhandle data type: {}",
Expand Down

0 comments on commit 976262e

Please sign in to comment.