Note
This documentation is for a prior release of Kinetica. For the latest documentation, click here.
URL: http://<db.host>:<db.port>/aggregate/unpivot
Rotate the column values into rows values.
For unpivot details and examples, see Unpivot. For limitations, see Unpivot Limitations.
Unpivot is used to normalize tables that are built for cross tabular reporting purposes. The unpivot operator rotates the column values for all the pivoted columns. A variable column, value column and all columns from the source table except the unpivot columns are projected into the result table. The variable column and value columns in the result table indicate the pivoted column name and values respectively.
The response is returned as a dynamic schema. For details see: dynamic schemas documentation.
Input Parameter Description
Name | Type | Description | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
table_name | string | Name of the table on which the operation will be performed. Must be an existing table/view, in [schema_name.]table_name format, using standard name resolution rules. | ||||||||||||||||||||||||||
column_names | array of strings | List of column names or expressions. A wildcard '*' can be used to include all the non-pivoted columns from the source table. | ||||||||||||||||||||||||||
variable_column_name | string | Specifies the variable/parameter column name. The default value is ''. | ||||||||||||||||||||||||||
value_column_name | string | Specifies the value column name. The default value is ''. | ||||||||||||||||||||||||||
pivoted_columns | array of strings | List of one or more values typically the column names of the input table. All the columns in the source table must have the same data type. | ||||||||||||||||||||||||||
encoding | string | Specifies the encoding for returned records. The default value is binary.
| ||||||||||||||||||||||||||
options | map of string to strings | Optional parameters. The default value is an empty map ( {} ).
|
Output Parameter Description
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 | 'aggregate_unpivot_response' or 'none' in case of an error | ||||||||||||||||||||||||||||
data | String | Empty string | ||||||||||||||||||||||||||||
data_str | JSON or String | This embedded JSON represents the result of the /aggregate/unpivot endpoint:
Empty string in case of an error. |