Skip to content

Commit 32d94f7

Browse files
committed
chore: parse BasicValueType::Date
| BasicValueType::LocalDateTime | BasicValueType::OffsetDateTime | BasicValueType::Time | BasicValueType::Uuid Signed-off-by: Anush008 <[email protected]>
1 parent d9c93d4 commit 32d94f7

File tree

1 file changed

+59
-16
lines changed

1 file changed

+59
-16
lines changed

src/ops/storages/qdrant.rs

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use qdrant_client::qdrant::{
1515
};
1616
use qdrant_client::qdrant::{Query, QueryPointsBuilder, ScoredPoint};
1717
use qdrant_client::Qdrant;
18-
use serde::Serialize;
1918
use serde_json::json;
2019

2120
#[derive(Debug, Deserialize, Clone)]
@@ -129,11 +128,11 @@ fn values_to_payload(
129128
BasicValue::Float32(v) => (*v as f64).into(),
130129
BasicValue::Float64(v) => (*v).into(),
131130
BasicValue::Range(v) => json!({ "start": v.start, "end": v.end }),
132-
BasicValue::Uuid(v) => v.to_string().into(),
133-
BasicValue::Date(v) => v.to_string().into(),
134-
BasicValue::LocalDateTime(v) => v.to_string().into(),
135-
BasicValue::Time(v) => v.to_string().into(),
136-
BasicValue::OffsetDateTime(v) => v.to_string().into(),
131+
BasicValue::Uuid(v) => json!({ "uuid": v.to_string() }),
132+
BasicValue::Date(v) => json!({ "date": v.to_string() }),
133+
BasicValue::LocalDateTime(v) => json!({ "local_datetime": v.to_string() }),
134+
BasicValue::Time(v) => json!({ "time": v.to_string() }),
135+
BasicValue::OffsetDateTime(v) => json!({ "offset_datetime": v.to_string() }),
137136
BasicValue::Json(v) => (**v).clone(),
138137
BasicValue::Vector(v) => {
139138
let vector = convert_to_vector(v.to_vec());
@@ -224,13 +223,59 @@ fn into_value(point: &ScoredPoint, schema: &FieldSchema) -> Result<Value> {
224223
}
225224
}),
226225

227-
BasicValueType::Date
228-
| BasicValueType::LocalDateTime
229-
| BasicValueType::OffsetDateTime
230-
| BasicValueType::Time
231-
| BasicValueType::Uuid => point.payload.get(field_name).and_then(|v| {
232-
v.as_str()
233-
.map(|s| BasicValue::Str(Arc::from(s.to_string())))
226+
BasicValueType::Uuid => point.payload.get(field_name).and_then(|v| {
227+
v.as_struct().and_then(|s| {
228+
s.fields
229+
.get("uuid")?
230+
.as_str()?
231+
.parse()
232+
.ok()
233+
.map(BasicValue::Uuid)
234+
})
235+
}),
236+
237+
BasicValueType::Date => point.payload.get(field_name).and_then(|v| {
238+
v.as_struct().and_then(|s| {
239+
s.fields
240+
.get("date")?
241+
.as_str()?
242+
.parse()
243+
.ok()
244+
.map(BasicValue::Date)
245+
})
246+
}),
247+
248+
BasicValueType::Time => point.payload.get(field_name).and_then(|v| {
249+
v.as_struct().and_then(|s| {
250+
s.fields
251+
.get("time")?
252+
.as_str()?
253+
.parse()
254+
.ok()
255+
.map(BasicValue::Time)
256+
})
257+
}),
258+
259+
BasicValueType::LocalDateTime => point.payload.get(field_name).and_then(|v| {
260+
v.as_struct().and_then(|s| {
261+
s.fields
262+
.get("local_datetime")?
263+
.as_str()?
264+
.parse()
265+
.ok()
266+
.map(BasicValue::LocalDateTime)
267+
})
268+
}),
269+
270+
BasicValueType::OffsetDateTime => point.payload.get(field_name).and_then(|v| {
271+
v.as_struct().and_then(|s| {
272+
s.fields
273+
.get("offset_datetime")?
274+
.as_str()?
275+
.parse()
276+
.ok()
277+
.map(BasicValue::OffsetDateTime)
278+
})
234279
}),
235280
BasicValueType::Range => point.payload.get(field_name).and_then(|v| {
236281
v.as_struct().and_then(|s| {
@@ -368,9 +413,7 @@ impl StorageFactoryBase for Arc<Factory> {
368413
_existing: setup::CombinedState<()>,
369414
_auth_registry: &Arc<AuthRegistry>,
370415
) -> Result<impl setup::ResourceSetupStatusCheck + 'static> {
371-
Err(anyhow!(
372-
"Set `setup_by_user` to `true` to use Qdrant storage"
373-
)) as Result<Infallible, _>
416+
Err(anyhow!("Set `setup_by_user` to `true` to export to Qdrant")) as Result<Infallible, _>
374417
}
375418

376419
fn check_state_compatibility(

0 commit comments

Comments
 (0)