URL: http://GPUDB_IP_ADDRESS:GPUDB_PORT/create/type
Creates a new type describing the layout or schema of a table. The type definition is a JSON string describing the fields (i.e. columns) of the type. Each field consists of a name and a data type. Supported data types are: double, float, int, long, string, and bytes. In addition one or more properties can be specified for each column which customize the memory usage and query availability of that column. Note that some properties are mutually exclusive--i.e. they cannot be specified for any given column simultaneously. One example of mutually exclusive properties are data and store_only.
A single primary key and/or single shard key can be set across one or more columns. If a primary key is specified, then a uniqueness constraint is enforced, in that only a single object can exist with a given primary key. When inserting data into a table with a primary key, depending on the parameters in the request, incoming objects with primary key values that match existing objects will either overwrite (i.e. update) the existing object or will be skipped and not added into the set.
Example of a type definition with some of the parameters:
{"type":"record",
"name":"point",
"fields":[{"name":"msg_id","type":"string"},
{"name":"x","type":"double"},
{"name":"y","type":"double"},
{"name":"TIMESTAMP","type":"double"},
{"name":"source","type":"string"},
{"name":"group_id","type":"string"},
{"name":"OBJECT_ID","type":"string"}]
}
Properties:
{"group_id":["store_only"],
"msg_id":["store_only","text_search"]
}
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type_definition | string | a JSON string describing the columns of the type to be registered. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label | string | A user-defined description string which can be used to differentiate between tables and types with otherwise identical schemas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
properties | map of string to arrays of strings | Each key-value pair specifies the properties to use for a given column where the key is the column name. All keys used must be relevant column names for the given table. Specifying any property overrides the default properties for that column (which is based on the column's data type).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options | map of string to strings | Optional parameters. The default value is an empty map ( {} ). |
The GPUdb server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query. Here is a description of the various fields of the wrapper:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
status | String | 'OK' or 'ERROR' | |||||||||||||||
message | String | Empty if success or an error message | |||||||||||||||
data_type | String | 'create_type_request' or 'none' in case of an error | |||||||||||||||
data | String | Empty string | |||||||||||||||
data_str | JSON or String | This embedded JSON represents the result of the /create/type endpoint:
Empty string in case of an error. |