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.66k stars 483 forks source link

Nullable value for numeric related fields #2236

Open scruel opened 1 month ago

scruel commented 1 month ago

Proposal:

Support syntax like:

CREATE TABLE testx(num bigint default NULL);
INSERT INTO testx(num) VALUES (NULL);

Currently, the default value of number fields is 0, but it will only be applied when field's value been omitted:

indexApi.insert({"index": "testx", "doc": {}}) {'created': True, 'found': None, 'id': 7784907359997919256, 'index': 'testx', 'result': 'created'} print(utilsApi.sql('SELECT * from testx')) [{'columns': [{'id': {'type': 'long long'}}, {'num': {'type': 'long long'}}], 'data': [{'id': 7784907359997919256, 'num': 0}], 'total': 1, 'error': '', 'warning': ''}]

And BTW, having 0 as a special value is not cool IMO, it may cause some inconsistent behaviors: https://github.com/manticoresoftware/manticoresearch/issues/1976

Checklist:

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

- [ ] Task estimated - [ ] Specification created, reviewed and approved - [ ] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation proofread - [ ] Changelog updated - [x] OpenAPI YAML updated and issue created to rebuild clients
sanikolaev commented 2 weeks ago

Not a big deal to add NULLs support for the columnar storage. Harder for the row-wise storage, especially because we support in-place updates. We'd also need to integrate it with all the functions, which is very time-consuming.