manticoresoftware / manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
https://manticoresearch.com
GNU General Public License v3.0
8.93k stars 495 forks source link

joining by json_attr.string doesn't work #2559

Open sanikolaev opened 2 weeks ago

sanikolaev commented 2 weeks ago

Bug Description:

MRE:

snikolaev@dev2:~$ mysql -P9306 -h0 -e "drop table if exists t; drop table if exists t2; create table t(f text, s string, j json); create table t2(f text, s string, j json); insert into t values(1, 'abc', 'string', '{\"i\": 1, \"b\": true, \"f\": 1.23, \"s\": \"string\"}'); insert into t2 values(1, 'def', 'string', '{\"i\": 1, \"b\": true, \"f\": 1.23, \"s\": \"string\"}'); select * from t; select * from t2; select * from t inner join t2 on string(t.j.s) = t2.j.s"
curl -s 0:9308/search -d '{
  "index": "t",
  "join": [
    {
      "type": "inner",
      "table": "t2",
      "on": [
        {
          "left": {
            "table": "t",
            "field": "j.s",
            "type": "string"
          },
          "operator": "eq",
          "right": {
            "table": "t2",
            "field": "j.s"
          }
        }
      ]
    }
  ]
}'|jq .
+------+------+--------+--------------------------------------------+
| id   | f    | s      | j                                          |
+------+------+--------+--------------------------------------------+
|    1 | abc  | string | {"i":1,"b":true,"f":1.230000,"s":"string"} |
+------+------+--------+--------------------------------------------+
+------+------+--------+--------------------------------------------+
| id   | f    | s      | j                                          |
+------+------+--------+--------------------------------------------+
|    1 | def  | string | {"i":1,"b":true,"f":1.230000,"s":"string"} |
+------+------+--------+--------------------------------------------+
{
  "took": 0,
  "timed_out": false,
  "hits": {
    "total": 0,
    "total_relation": "eq",
    "hits": []
  }

Manticore Search Version:

Manticore 6.3.7 53ae190b8@24091306 dev (columnar 2.3.1 f9ef8b9@24090411) (secondary 2.3.1 f9ef8b9@24090411) (knn 2.3.1 f9ef8b9@24090411)

Operating System Version:

Ubuntu Jammy (dev2)

Have you tried the latest development version?

Yes

Internal Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

- [ ] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation reviewed - [ ] [Changelog](https://docs.google.com/spreadsheets/d/1mz_3dRWKs86FjRF7EIZUziUDK_2Hvhd97G0pLpxo05s/edit?pli=1&gid=1102439133) updated