feat(vector): add conversion between vector and string (#5029)

* feat(vector): add conversion between vector and string

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

* fix sqlness

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

* address comments

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>

---------

Signed-off-by: Zhenchi <zhongzc_arch@outlook.com>
This commit is contained in:
Zhenchi
2024-11-20 08:42:00 +00:00
committed by GitHub
parent 027284ed1b
commit 0aab68c23b
17 changed files with 655 additions and 169 deletions
+8 -2
View File
@@ -215,7 +215,7 @@ pub async fn test_mysql_crud(store_type: StorageType) {
let dt: DateTime<Utc> = row.get("dt");
let bytes: Vec<u8> = row.get("b");
let json: serde_json::Value = row.get("j");
let vector: String = row.get("v");
let vector: Vec<u8> = row.get("v");
assert_eq!(ret, i as i64);
let expected_d = NaiveDate::from_yo_opt(2015, 100).unwrap();
assert_eq!(expected_d, d);
@@ -242,7 +242,13 @@ pub async fn test_mysql_crud(store_type: StorageType) {
}
});
assert_eq!(json, expected_j);
assert_eq!(vector, "[1,2,3]");
assert_eq!(
vector,
[1.0f32, 2.0, 3.0]
.iter()
.flat_map(|x| x.to_le_bytes())
.collect::<Vec<u8>>()
);
}
let rows = sqlx::query("select i from demo where i=?")