Skip to content
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

The complete Tarantool DB data types list is missing #928

Open
msiomkin opened this issue Sep 24, 2019 · 8 comments
Open

The complete Tarantool DB data types list is missing #928

msiomkin opened this issue Sep 24, 2019 · 8 comments
Assignees
Labels
reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality

Comments

@msiomkin
Copy link
Contributor

msiomkin commented Sep 24, 2019

It looks like we don't have a single table where all Tarantool database types are enumerated. I think it's a basic must have thing.

We have this table:
https://www.tarantool.io/en/doc/2.2/book/box/data_model/#lua-vs-msgpack

But it lacks at least unsigned, any and number. (And by the way what's the difference between bin and varbinary?)

I also think there should be a column with verbal description of data types. E.g.:

double - a double precision floating point number (IEEE 64-bit floating point on most compilers?)
unsigned - an integer number in range from 0 to ... (depending on compiler?)
any - ...
...

Here is the hopefully full (?) list of types from Tarantool source:

/*
 * Possible field data types. Can't use STRS/ENUM macros for them,
 * since there is a mismatch between enum name (STRING) and type
 * name literal ("STR"). STR is already used as Objective C type.
 */
enum field_type {
	FIELD_TYPE_ANY = 0,
	FIELD_TYPE_UNSIGNED,
	FIELD_TYPE_STRING,
	FIELD_TYPE_NUMBER,
	FIELD_TYPE_INTEGER,
	FIELD_TYPE_BOOLEAN,
	FIELD_TYPE_VARBINARY,
	FIELD_TYPE_SCALAR,
	FIELD_TYPE_DECIMAL,
	FIELD_TYPE_ARRAY,
	FIELD_TYPE_MAP,
	field_type_MAX
};
@pgulutzan
Copy link
Contributor

Re "But it lacks at least unsigned, any and number. (And by the way what's the difference between bin and varbinary?)": Actually number is not lacking, it is in the chart, and bin / varbinary explanation is immediately below that chart.
As for "unsigned", it is not in a chart about Lua types because it is not a Lua type, but it is a Tarantool type and so documented multiple times, e.g. in https://www.tarantool.io/en/doc/2.2/book/box/box_space/ ... "unsigned: unsigned integers between 0 and 18446744073709551615, about 18 quintillion. May also be called ‘uint’ or ‘num’, but ‘num’ is deprecated. Legal in memtx TREE or HASH indexes, and in vinyl TREE indexes." etc.
Also the list with FIELD_TYPE_ANY FIELD_TYPE_UNSIGNED etc. is in the manual, in a different section for more advanced users.
@lenkis: It is our fault if somebody cannot find where the documentation is, so we should be sorry. But this feature request is not suggesting anything that is not already there, so I suggest closing it.

@lenkis lenkis added the need feedback [special status] On hold, awaiting feedback label Sep 27, 2019
@lenkis
Copy link
Contributor

lenkis commented Sep 27, 2019

@kyukhin let's discuss

@msiomkin
Copy link
Contributor Author

msiomkin commented Sep 27, 2019

I still think we need a single complete list of types, not just a paragraph where all types are mentioned one way or another. The following table is most close to what I'm talking about: https://www.tarantool.io/en/doc/2.2/book/box/data_model/#indexed-field-types

But it lacks at least 'map' (obviously because indices on maps are not supported ant the table is called 'Indexed field types'). And please, do make a single column with all possible values of 'type' field of box.space.format's parameter (don't split the list into two columns as in the example above) - it's crucial for intuitive comprehension.

@ImeevMA
Copy link

ImeevMA commented Dec 19, 2019

I think it makes sense to add more information about the NUMBER type in Lua. In essence, this type works like a DOUBLE in C. But, since we convert an integer of this type to INTEGER / UNSIGNED, we can encounter precision loss if the number is more than 2 ^ 52. For example:

tarantool> 2^60
---
- 1152921504606846976
...

tarantool> 1152921504606846976 == 1152921504606846976 + 10
---
- true
...

tarantool> 1152921504606846976 == 1152921504606846976LL
---
- true
...

tarantool> 1152921504606846976 == 1152921504606846976LL + 10
---
- false
...

@Totktonada
Copy link
Member

AFAIS, 'number' type in space formats also accepts decimals.

@ImeevMA
Copy link

ImeevMA commented Dec 19, 2019

In my comment, I mean NUMBER in Lua, not NUMBER in Tarantool. NUMBER in Tarantool contains all numeric types.

@lenkis lenkis assigned veod32 and unassigned lenkis Dec 25, 2019
@kyukhin
Copy link
Contributor

kyukhin commented May 29, 2020

I agree w/ Peter here. I think we need to somehow re-group descriptions.
And close this issue.

@msiomkin
Copy link
Contributor Author

Let me try to explain once more. User writes:

box.space.test:format({{ name = "my_column", type =

Please, let us give him a single list in the documentation to choose from.

I suggest something like this (obviously, we don't have anything close to it now):

field type | MsgPack type(s) | Lua type(s)
-----------+-----------------+------------
any        |                 |
unsigned   |                 |
string     |                 |
number     |                 |
integer    |                 |
boolean    |                 |
varbinary  |                 |
scalar     |                 |
decimal    |                 |
array      |                 |
map        |                 |
max(?)     |                 |
...(?)     |                 |

@patiencedaur patiencedaur added server [area] Task relates to Tarantool's server (core) functionality and removed need feedback [special status] On hold, awaiting feedback labels Feb 28, 2022
@veod32 veod32 added the reference [location] Tarantool manual, Reference part label Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality
Projects
None yet
Development

No branches or pull requests

8 participants