Clippy stuff
This commit is contained in:
Родитель
77ac721d3a
Коммит
7358f88162
|
@ -1,5 +1,5 @@
|
|||
use std::convert::TryInto;
|
||||
use std::ops::Deref;
|
||||
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -8,15 +8,14 @@ use arrow::{
|
|||
ArrayRef, BooleanArray, DurationNanosecondArray, Float64Array, Int32Array, Int64Array,
|
||||
StringArray,
|
||||
},
|
||||
compute::cast,
|
||||
datatypes::{DataType, Field, Schema, TimeUnit},
|
||||
record_batch::RecordBatch,
|
||||
};
|
||||
use arrow::array::{Date32Array, Date64Array, TimestampNanosecondArray};
|
||||
use arrow::array::{TimestampNanosecondArray};
|
||||
use azure_core::error::{ErrorKind, ResultExt};
|
||||
use lazy_static::lazy_static;
|
||||
use time::format_description::well_known::Rfc3339;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
|
||||
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::operations::query::*;
|
||||
|
@ -55,11 +54,10 @@ fn convert_array_float(values: Vec<serde_json::Value>) -> Result<ArrayRef> {
|
|||
}
|
||||
|
||||
fn convert_array_timespan(values: Vec<serde_json::Value>) -> Result<ArrayRef> {
|
||||
let strings: Vec<KustoDuration> =
|
||||
serde_json::from_value(serde_json::Value::Array(values))?;
|
||||
let strings: Vec<String> = serde_json::from_value(serde_json::Value::Array(values))?;
|
||||
let durations: Vec<Option<i64>> = strings
|
||||
.iter()
|
||||
.map((|s| i64::try_from(s.whole_nanoseconds()).ok()))
|
||||
.map(|s| KustoDuration::from_str(s).ok().and_then(|d| i64::try_from(d.whole_nanoseconds()).ok()))
|
||||
.collect();
|
||||
Ok(Arc::new(DurationNanosecondArray::from(durations)))
|
||||
}
|
||||
|
@ -136,14 +134,12 @@ pub fn convert_table(table: DataTable) -> Result<RecordBatch> {
|
|||
.for_each(|(idx, value)| buffer[idx].push(value))
|
||||
});
|
||||
|
||||
// TODO with capacity
|
||||
let iter = buffer
|
||||
.into_iter()
|
||||
.zip(table.columns.into_iter())
|
||||
.map(|(data, column)| convert_column(data, column));
|
||||
|
||||
for result in iter {
|
||||
dbg!(&result);
|
||||
let (field, data) = result?;
|
||||
fields.push(field);
|
||||
columns.push(data);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::fmt::{Debug, Display, Formatter};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::ops::{Deref};
|
||||
use std::str::FromStr;
|
||||
use azure_core::error::{ErrorKind, ResultExt};
|
||||
use lazy_static::lazy_static;
|
||||
use regex::{Captures, Regex};
|
||||
use time::{Duration, OffsetDateTime};
|
||||
use serde_with::{DeserializeFromStr, SerializeDisplay};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use time::format_description::well_known::Rfc3339;
|
||||
use crate::error::Error;
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl FromStr for KustoDateTime {
|
|||
|
||||
impl Display for KustoDateTime {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0.format(&Rfc3339).unwrap_or("".into()))?;
|
||||
write!(f, "{}", self.0.format(&Rfc3339).unwrap_or_else(|_| "".into()))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
[
|
||||
"now",
|
||||
"2021-12-22T11:43:00Z",
|
||||
"1.01:01:01.0",
|
||||
"1.00:00:00.0000000",
|
||||
true,
|
||||
5678,
|
||||
3.14159
|
||||
|
@ -74,7 +74,7 @@
|
|||
[
|
||||
"earliest datetime",
|
||||
"1677-09-21T00:12:44Z",
|
||||
"1.01:01:01.0",
|
||||
"01:00:00.0000000",
|
||||
true,
|
||||
5678,
|
||||
"NaN"
|
||||
|
@ -82,7 +82,7 @@
|
|||
[
|
||||
"latest datetime",
|
||||
"2021-12-31T23:59:59Z",
|
||||
"1.01:01:01.0",
|
||||
"01:00:00",
|
||||
true,
|
||||
5678,
|
||||
"Infinity"
|
||||
|
@ -90,7 +90,7 @@
|
|||
[
|
||||
"earliest arrow datetime",
|
||||
"1677-09-21T00:12:44Z",
|
||||
"1.01:01:01.0",
|
||||
"00:05:00.0000000",
|
||||
true,
|
||||
5678,
|
||||
"-Infinity"
|
||||
|
@ -98,7 +98,7 @@
|
|||
[
|
||||
"latest pandas datetime",
|
||||
"2262-04-11T23:47:16Z",
|
||||
"1.01:01:01.0",
|
||||
"00:00:00.0000001",
|
||||
true,
|
||||
5678,
|
||||
3.14159
|
||||
|
@ -106,7 +106,7 @@
|
|||
[
|
||||
"timedelta ticks",
|
||||
"2021-12-22T11:43:00Z",
|
||||
"1.01:01:01.0",
|
||||
"-01:00:00",
|
||||
true,
|
||||
5678,
|
||||
3.14159
|
||||
|
@ -114,7 +114,7 @@
|
|||
[
|
||||
"timedelta string",
|
||||
"2021-12-22T11:43:00Z",
|
||||
"1.01:01:01.0",
|
||||
"-1.00:00:00.0000000",
|
||||
true,
|
||||
5678,
|
||||
3.14159
|
||||
|
|
Загрузка…
Ссылка в новой задаче