vector_dims()

函数说明

vector_dims 函数用于确定向量的维度。

函数语法

  1. > SELECT vector_dims(vector) AS dimension_count FROM table_name;

示例

  1. drop table if exists vec_table;
  2. create table vec_table(a int, b vecf32(3), c vecf64(3));
  3. insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
  4. insert into vec_table values(2, "[7,8,9]", "[1,2,3]");
  5. mysql> select * from vec_table;
  6. +------+-----------+-----------+
  7. | a | b | c |
  8. +------+-----------+-----------+
  9. | 1 | [1, 2, 3] | [4, 5, 6] |
  10. | 2 | [7, 8, 9] | [1, 2, 3] |
  11. +------+-----------+-----------+
  12. 2 row in set (0.00 sec)
  13. mysql> select vector_dims(b) from vec_table;
  14. +----------------+
  15. | vector_dims(b) |
  16. +----------------+
  17. | 3 |
  18. | 3 |
  19. +----------------+
  20. 2 row in set (0.01 sec)