Data API Data Type Conversion
On this page
SingleStore’s Data API returns JSON objects as responses.
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.
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.
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.
|
Varbinary |
|
Base64-encoded string |
SingleStore
To return binary column values as string, you can cast it.
|
Time and Date |
|
String |
Date and time values are converted to JSON strings, and they are no longer parsed through the Golang time module.
|
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.
|
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.
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.
|
Varbinary |
|
Base64-encoded string |
SingleStore
To return binary column values as string, you can cast it.
|
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 maximum SIGNED
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, the YEAR
data type is converted to a JSON string in/api/v2
and a JSON number in/api/v1
.
Last modified: June 10, 2022