Skip to content

UtilsApi will return MVA type list value as string #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scruel opened this issue Apr 26, 2024 · 5 comments
Open

UtilsApi will return MVA type list value as string #14

scruel opened this issue Apr 26, 2024 · 5 comments
Assignees

Comments

@scruel
Copy link

scruel commented Apr 26, 2024

According to your document:
https://manual.manticoresearch.com/Creating_a_table/Data_types#Multi-value-integer-(MVA)
We will be able to obtain a list for MVA type value.

However, by using UtilsApi to query the index, it won't act as the same:

>>> utilsApi.sql('CREATE TABLE products(title text, product_codes multi)')
[{'total': 0, 'error': '', 'warning': ''}]
>>> utilsApi.sql('select * from products')[0]['columns']
[{'id': {...}}, {'product_codes': {...}}, {'title': {...}}]
>>> utilsApi.sql('select * from products')[0]['columns'][1]
{'product_codes': {'type': 'string'}}
@sanikolaev
Copy link
Collaborator

@Nick-S-2018 pls check why the client returns {'product_codes': {'type': 'string'}} in this case. I can't reproduce via JSON:

➜  ~ mysql -P9306 -h0 -e "drop table if exists products; CREATE TABLE products(title text, product_codes multi); insert into products values(1, 'abc', (1, 2, 3));"
➜  ~ curl -s 0:9308/sql -d 'query=select%20*%20from%20products'|jq .
{
  "took": 0,
  "timed_out": false,
  "hits": {
    "total": 1,
    "total_relation": "eq",
    "hits": [
      {
        "_id": "1",
        "_score": 1,
        "_source": {
          "title": "abc",
          "product_codes": [
            1,
            2,
            3
          ]
        }
      }
    ]
  }
}

@Nick-S-2018
Copy link
Collaborator

@sanikolaev The issue can be reproduced by calling the /sql?mode=raw endpoint which is what the client does internally.
However, the multi type (as well as multi64g or json) is actually returned as string in sql queries, so we need to discuss this case further.

@scruel If you need info about column data types, the best way to get it is to use the desc command instead:
utilsApi.sql('desc products')

@scruel
Copy link
Author

scruel commented May 4, 2024

@Nick-S-2018 Such auto-conversion already implemented in searchApi, why not let utilsApi also utilize it?

@sanikolaev
Copy link
Collaborator

Blocked by manticoresoftware/manticoresearch#2143

@Nick-S-2018
Copy link
Collaborator

@scruel
searchApi and utilsApi use different API endpoints on the server side so they operate with different response formats

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants