Data API Data Type Conversion
SingleStore’s Data API returns JSON objects as responses. The following tables map the SingleStore data types to the corresponding JSON data types.
Data Type Mapping for /api/v2/
Category | SingleStore Data Type | JSON Data Type | Notes |
---|---|---|---|
Boolean |
| Number | A |
Numeric |
| Number | JSON number data type supports both integers and floating point values, and they are returned as-is from SingleStore. For example,
The API supports 64-bit unsigned integer data type. |
JSON |
| JSON | JSON type values are directly added to the row tuple without any type conversion, which eliminates the need for additional parsing in later steps. For example,
JSON null values and SQL null values cannot be differentiated when using the Data API. |
String and Geospatial |
| String | JSON strings are enclosed within double quotes. For example,
|
Varbinary |
| Base64-encoded string | SingleStore
To return binary column values as string, you can cast it. For example, SELECT CAST(binary_col_name AS CHAR)... |
Time and Date |
| String | Date and time values are converted to JSON strings, and they are no longer parsed through the Golang time module. For example,
|
Important
If a column is nullable, make sure to prepare to handle null values.
Data Type Mapping for /api/v1/
Category | SingleStore Data Type | JSON Data Type | Notes |
---|---|---|---|
Boolean |
| Number | A |
Numeric |
| Number | JSON number data type supports both integers and floating point values. For example,
|
JSON |
| JSON | JSON type values are directly added to the row tuple without any type conversion, which eliminates the need for additional parsing in later steps. For example,
JSON null values and SQL null values cannot be differentiated when using the Data API. |
String and Geospatial |
| String | JSON strings are enclosed within double quotes. For example,
|
Varbinary |
| Base64-encoded string | SingleStore
To return binary column values as string, you can cast it. For example, SELECT CAST(binary_col_name AS CHAR)... |
Time and Date |
| Number |
|
| String | Date and time values (except for
|
Important
If a column is nullable, make sure to prepare to handle null values.
Invalid
DATETIME
andTIMESTAMP
values cannot be used over the Data API, although SingleStore allows them without the HTTP proxy.UNSIGNED
numbers must be specified asNOT NULL
. The Data API returns an error if it receives a value larger than the maximumSIGNED
value and if the result type isNOT NULL
.
Prerequisite to Upgrade from Data API v1 to v2
To upgrade from Data API v1 to v2:
Change
/api/v1/
in the API request URL to/api/v2/
.Note the data type conversion differences between
/api/v1
and/api/v2
. For example, theYEAR
data type is converted to a JSON string in/api/v2
and a JSON number in/api/v1
.