PUT Hadoop SQL operation of QueryIO server will add given Hadoop SQL query to the database or perform and update operation if it already exists.
PUT/queryio/hadoopsql/
HTTP/1.1 Host: QueryIO.com authorization:<Token>
The PUT Hadoop SQL operation in QueryIO Server uses following request header:
Header Name | Description | Type | Default | Required |
---|---|---|---|---|
hadoopsql-properties
|
String | None | Yes |
Key | Value | Type | Required |
---|---|---|---|
namenode | ID of the NameNode on which data will be queried. Example: "namenode": "NameNode1", |
String | Yes |
queryId | Unique identifier for the Hadoop SQL. Example: "queryId": "New Query 7" |
String | Yes |
queryDesc | (Optional)Brief description for the query. Value can be empty or null. Example: "queryDesc": "Query to get all sales list", |
String | Yes |
sqlQuery | Standard SQL query. Example: "sqlQuery": "SELECT * FROM HDFS_METADATA ", |
String | Yes |
chartDetail | (Optional) JSON object of the all the charts to be generated. | JSONObject | Yes |
colHeaderDetail | (Optional) Column header Formatting details. JSONObject for each coloumn header. | JSONObject | Yes |
colDetail | (Optional) Formatting for each selected columns. JSONObject for each coloumn. | JSONObject | Yes |
dbName | Database name in which queried table is present. | String | Yes |
queryHeader | (Optional) Header details for query result. JSONObject which contains header title and formatting details. | JSONObject | Yes |
queryFooter | (Optional) Footer details for query result. JSONObject which contains footer title and formatting details. | JSONObject | Yes |
groupHeader | (Optional) Header description for each group. | JSONObject | Yes |
groupFooter | (Optional) Footer description for each group. | JSONObject | Yes |
selectedTable | List of tables to be queried. Example: ["HDFS_METADATA", "METADATA_PDF"] |
JSONArray | Yes |
selectedWhere | (Optional) Condition to be specified in query. | JSONObject | Yes |
setHighFidelityOutput | To get high or low quality output. | Boolean | Yes |
setLimitResultRows | Limit the number of rows to be included in result. | Boolean | Yes |
limitResultRowsValue | Specify number of rows to be included in result. | String | Yes |
executionId | Specifies the current execution ID. | String | Yes |
username | Current logged in user. | String | Yes |
resultTableName | Name of the result table which gets created while running an adhoc query. | String | Yes |
persistResults | Specifies whether user wants to create result table while running an adhoc query. | Boolean | Yes |
selectedColumn | (Optional)List of selected columns. | JSONOBject | Yes |
selectedGroupBy | Group columns with aggregate functions. Example: [ "USERGROUP", "FILEPATH" ] |
JSONArray | Yes |
selectedHaving | (Optional)Condition to be specified on GROUP BY clause. | JSONObject | Yes |
selectedOrderBy | Sort the result-set by a specified column. | JSONOBject | Yes |
Format for chartDetail JSON:
chartPreferences : "<JSONObject>"
Key | Value | Type | Required | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
titleJson | Properties of the title of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
outLineJson | Properties of the outline of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
xAxisJson | Properties of the x axis of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
leaderLineJson | Properties of the leader lines of the chart (Applicable only for Pie charts).
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
commonJson | Common properties of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
lineChartJson | Properties exclusively for the line chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
legendJson | Properties of the legend of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
labelJson | Properties of the labels of the chart which forms the part of the actual data.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
yAxisJson | Properties of the y axis of the chart.
|
JSONObject | Yes | ||||||||||||||||||||||||||||||||
insetsJson | Properties of the insets of the chart.
|
JSONObject | Yes |
"<ChartId>" : "<JSONObject>"
Key | Value | Type | Required |
---|---|---|---|
position | Position of chart. Valid Values: "queryHeader", "groupHeader", "groupFooter" |
String | Yes |
yseriesArray | List of Y-axis columns.It can be more than one selected column. Example: [ "COUNT(USERGROUP)", "FILEPATH", "LEN" ] |
JSONArray | Yes |
yseries | Aggregate function on "yseriesArray" columns.
Key: Value = <ColumnName>:<Function>
|
JSONObject | |
ylegend | Y axis description | String | Yes |
align | center | String | |
width | Width of chart in pixels. Example: "300" |
String | Yes |
type | Type of chart. Valid Values: "line", "bar", "pie" |
String | Yes |
chartPreferences | Chart formatting details defined for each chart similar to the common chartPreferences explained above. | JSONObject | Yes |
title | Title of chart | String | Yes |
dimension | Dimensional representation of chart. 0 represents 2D, 1 represents 2D with depth, 2 represents 3D. Valid Values: "0", "1", "2". |
String | Yes |
height | Height of chart in pixels. Example: "300" |
String | Yes |
colSpan | Set position of chart according to column. | String | Yes |
rowPosition | Set position of chart according to row. | String | Yes |
xlegend | X-axis descritpion. | String | Yes |
xseries | X-axis column. It can be only one selected column. | String | Yes |
Specify formatting for all column headers. Format for colHeaderDetail JSON:
"<ColumnName>" : "<JSONObject>"
Key | Value | Type |
---|---|---|
title | Title of the column header to be displayed. | String |
color | Font color in RGB format. Example: #000000 |
String |
text-align | Position of text. Valid Values: "left", "center", "right", "justify" |
String |
font-size | Font size in "pt" or "px". Example: "12px" |
String |
width | Width for the column in "pt" or "px" Example: "100px". |
String |
font-style | Font Styles. Valid Values: "normal", "italic", "oblique" |
String |
background-color | Specify background color in RGB format. Example: "#cccccc" |
String |
font-family | The font-family property specifies the font for an element. Valid Values: "Times New Roman", "Verdana", "Courier" |
String |
font-weight | The font-weight CSS property specifies the weight or boldness of the font. Valid Values: "normal", "bold", "bolder", "lighter" |
String |
Specify formatting for all column data. Format for colDetail JSON:
"<ColumnName>" : "<JSONObject>"
"checkBookFlag" : "true" or "false"
Key | Value | Type |
---|---|---|
color | Font color in RGB format. Example: #000000 |
String |
text-align | Position of text. Valid Values: "left", "center", "right", "justify" |
String |
font-size | Font size in "pt" or "px". Example: "12px" |
String |
width | Width for the column in "pt" or "px" Example: "100px". |
String |
font-style | Font Styles. Valid Values: "normal", "italic", "oblique" |
String |
background-color | Specify background color in RGB format. Example: "#cccccc" |
String |
font-family | The font-family property specifies the font for an element. Valid Values: "Times New Roman", "Verdana", "Courier" |
String |
font-weight | The font-weight CSS property specifies the weight or boldness of the font. Valid Values: "normal", "bold", "bolder", "lighter" |
String |
format | JSON object with extra formatting details. | JSONOBject |
Specify extra formatting for all column data.
Key | Value | Type |
---|---|---|
category | Valid Values for column type
|
String |
pattern | Details according to column type. | JSONObject |
type | Column data type. Only for column data type as "string". Valid Value: String |
String |
sample | A sample data to show current formatting preview. | String |
Specify extra formatting according to column data type.
Key | Value | String Column Type | Numeric Column Type |
---|---|---|---|
decimalPlace | Number of decimal places to be displayed. | -1 | Any number greater that 0(zero). |
commaSeparator | Comma separator for larger numbers. | "false" | "true" or "false" |
roundingMode | Rules for round up number. | "-" | "Half_Up" , "Half_Down", "Half_Even", "Up", "Down", "Ceiling", "Floor", "Unnecessary" |
symbolNumber | Symbol to be displayed along with number. | "-" | "No Symbol", "$", "DKK" |
negativeNumber | define how to display negative numbers. | "-" | "useHyphen", "useBracket" |
symbolPosition | Specify to place symbol before or after number. | "-" | "before", "after" |
useSymbolSpace | To provide space between symbol and number or not. | "false" | "true" or "false" |
Specify formatting for query header. Format for queryHeader JSON:
"header" : <JSONObject>
Key | Value | Type |
---|---|---|
title | Title to be displayed in report or query header. | String |
color | Font color in RGB format. Example: #000000 |
String |
text-align | Position of text. Valid Values: "left", "center", "right", "justify" |
String |
font-size | Font size in "pt" or "px". Example: "12px" |
String |
width | Width for the column in "pt" or "px" Example: "100px". |
String |
font-style | Font Styles. Valid Values: "normal", "italic", "oblique" |
String |
background-color | Specify background color in RGB format. Example: "#cccccc" |
String |
font-family | The font-family property specifies the font for an element. Valid Values: "Times New Roman", "Verdana", "Courier" |
String |
font-weight | The font-weight CSS property specifies the weight or boldness of the font. Valid Values: "normal", "bold", "bolder", "lighter" |
String |
Specify formatting for query footer. Format for queryFooter JSON:
"footer" : <JSONObject>
Key | Value | Type |
---|---|---|
title | Title to be displayed at end of report or query. | String |
color | Font color in RGB format. Example: #000000 |
String |
text-align | Position of text. Valid Values: "left", "center", "right", "justify" |
String |
font-size | Font size in "pt" or "px". Example: "12px" |
String |
width | Width for the column in "pt" or "px" Example: "100px". |
String |
font-style | Font Styles. Valid Values: "normal", "italic", "oblique" |
String |
background-color | Specify background color in RGB format. Example: "#cccccc" |
String |
font-family | The font-family property specifies the font for an element. Valid Values: "Times New Roman", "Verdana", "Courier" |
String |
font-weight | The font-weight CSS property specifies the weight or boldness of the font. Valid Values: "normal", "bold", "bolder", "lighter" |
String |
Specify formatting for all group headers. Format for groupHeader JSON:
"<ColumnName>" : <JSONObject>
Key | Value | Type |
---|---|---|
style | Formatting for group header. | JSONObject |
prefix | Text to be displayed before column name | String |
suffix | Text to be displayed after column name | String |
Key | Value | Type |
---|---|---|
color | Font color in RGB format. Example: #000000 |
String |
text-align | Position of text. Valid Values: "left", "center", "right", "justify" |
String |
font-size | Font size in "pt" or "px". Example: "12px" |
String |
width | Width for the column in "pt" or "px" Example: "100px". |
String |
font-style | Font Styles. Valid Values: "normal", "italic", "oblique" |
String |
background-color | Specify background color in RGB format. Example: "#cccccc" |
String |
font-family | The font-family property specifies the font for an element. Valid Values: "Times New Roman", "Verdana", "Courier" |
String |
font-weight | The font-weight CSS property specifies the weight or boldness of the font. Valid Values: "normal", "bold", "bolder", "lighter" |
String |
format | JSON object with extra formatting details. | JSONOBject |
Specify formatting for all group footer. Format for groupFooter JSON:
"<ColumnName>" : <JSONObject>
Key | Value | Type |
---|---|---|
style | Formatting for group header. | JSONObject |
prefix | Text to be displayed before column name | String |
suffix | Text to be displayed after column name | String |
function | Aggregate function to be applied on column Valid Values: "COUNT", "DistinctCount" |
String |
Specify "where" condition for the columns provided in "sqlQuery".
"<ColumnName>" : <JSONObject>
Key | Value | Type |
---|---|---|
roperator | Relational operator used in the condition Valid Values: "=", "!=", ">", "<", "<=", ">=", IN , NOT IN, IS NULL , NOT IS NULL, LIKE, NOT LIKE, BETWEEN, NOT BETWEEN |
String |
value | Value to be provided in condition | String |
loperator | Logical operator to join several conditions. | String |
"selectedWhere": { "USERGROUP": { "roperator": " = ", "value": "queryio", "loperator": "AND" }, "LEN": { "roperator": " > ", "value": "10", "loperator": "" } }, |
Specify selected columns which are included in sql query (if query is not in the format : SELECT * FROM <table>).
Format for JSONObject is
"<ColumnName>" : <JSONObject>
Key | Value | Type |
---|---|---|
function | Aggregate function to be applied on column. Valid Values: "COUNT", "DistinctCount" |
String |
Specify condition for the columns provided in "GROUP BY" clause.
"<ColumnName>" : <JSONObject>
Key | Value | Type |
---|---|---|
roperator | Relational operator used in the condition Valid Values: "=", "!=", ">", "<", "<=", ">=", IN , NOT IN, IS NULL , NOT IS NULL, LIKE, NOT LIKE, BETWEEN, NOT BETWEEN |
String |
value | Value to be provided in condition | String |
loperator | Logical operator to join several conditions. | String |
"selectedHaving": { "USERGROUP": { "roperator": " LIKE ", "value": "query%", "loperator": "AND" }, "LEN": { "roperator": " > ", "value": "10", "loperator": "" } }, |
Key | Value | Type |
---|---|---|
<columnName> | Specify sorting of Selected column name. Valid Values: "ASC", "DESC" Example: "selectedOrderBy": { "USERGROUP": "ASC" }, |
String |
{ "resultTableName": "RESULT_8_HDFS_METADATA", "namenode": "NameNode1", "sqlQuery": "SELECT USERGROUP, FILEPATH, COUNT(LEN) FROM HDFS_METADATA WHERE USERGROUP = 'queryio' AND LEN > 10 GROUP BY USERGROUP,FILEPATH ORDER BY USERGROUP ASC ", "dbName": "QueryDB", "chartDetail": { "chart0": { "position": "groupHeader", "yseriesArray": [ "FILEPATH" ], "yseries": { "FILEPATH": "#" }, "ylegend": "vcb", "align": "center", "width": "300", "type": "line", "chartPreferences": {}, "title": "chart", "dimension": "0", "height": "300", "colSpan": "1", "rowPosition": "1", "xlegend": "cvb", "xseries": "USERGROUP" }, "chart1": { "position": "queryHeader", "yseriesArray": [ "Count(FILEPATH)" ], "yseries": { "FILEPATH": "Count" }, "ylegend": "aa", "align": "center", "width": "300", "type": "pie", "chartPreferences": {}, "title": "2", "dimension": "0", "height": "300", "colSpan": "1", "rowPosition": "1", "xlegend": "aa", "xseries": "USERGROUP" }, "chartPreferences": { "titleJson": {}, "outLineJson": {}, "xAxisJson": {}, "leaderLineJson": {}, "commonJson": {}, "lineChartJson": {}, "legendJson": {}, "labelJson": {}, "yAxisJson": {}, "insetsJson": {} } }, "selectedOrderBy": { "USERGROUP": "ASC" }, "selectedTable": [ "HDFS_METADATA" ], "queryHeader": { "header": { "title": "header", "color": "ffffff", "text-align": "center", "font-size": "16px", "width": "100%", "font-style": "italic", "background-color": "005fbf", "font-family": "Arial", "font-weight": "bold", "format": { } } }, "selectedWhere": { "USERGROUP": { "roperator": " = ", "value": "queryio", "loperator": "AND" }, "LEN": { "roperator": " > ", "value": "10", "loperator": "" } }, "selectedHaving": { "USERGROUP": { "roperator": " LIKE ", "value": "query%", "loperator": "AND" }, "LEN": { "roperator": " > ", "value": "10", "loperator": "" } }, "username": "admin", "executionId": 12, "limitResultRowsValue": "5", "setHighFidelityOutput": true, "queryFooter": { "footer": { "title": "footer", "color": "#7c7c7c", "text-align": "left", "font-size": "16px", "width": "100%", "font-style": "normal", "background-color": "", "font-family": "Arial", "font-weight": "normal", "format": { } } }, "groupHeader": { "USERGROUP": { "style": { "color": "ffffff", "text-align": "center", "font-size": "10px", "width": "pt", "font-style": "italic", "background-color": "00bf5f", "font-family": "Times New Roman", "font-weight": "bold", "format": { "category": "uppercase", "pattern": { "decimalPlace": "-1", "commaSeparator": false, "roundingMode": "-", "symbolNumber": "-", "negativeNumber": "-", "symbolPosition": "-", "useSymbolSpace": false }, "type": "string", "sample": "USERGROUP" } }, "prefix": "prefix", "suffix": "suffix", "function": "" } }, "setLimitResultRows": true, "groupFooter": { "FILEPATH": { "style": { "color": "", "text-align": "left", "font-size": "10pt", "width": "pt", "font-style": "normal", "background-color": "", "font-family": "Times New Roman", "font-weight": "normal", "format": { "category": "Unformatted", "pattern": { "decimalPlace": "-1", "commaSeparator": false, "roundingMode": "-", "symbolNumber": "-", "negativeNumber": "-", "symbolPosition": "-", "useSymbolSpace": false }, "type": "string", "sample": "FILEPATH" } }, "prefix": "", "suffix": "", "function": "" } }, "queryDesc": "aasassxz", "colDetail": { "USERGROUP": { "color": "#000000", "text-align": "left", "font-size": "10px", "width": "180px", "font-style": "normal", "background-color": "", "font-family": "Arial", "font-weight": "normal", "format": { "category": "uppercase", "pattern": { "decimalPlace": "-1", "commaSeparator": false, "roundingMode": "-", "symbolNumber": "-", "negativeNumber": "-", "symbolPosition": "-", "useSymbolSpace": false }, "type": "string", "sample": "USERGROUP" } }, "FILEPATH": { "color": "#000000", "text-align": "center", "font-size": "12px", "width": "180px", "font-style": "italic", "background-color": "aaffaa", "font-family": "Times New Roman", "font-weight": "bolder", "format": { "category": "Unformatted", "pattern": { "decimalPlace": "-1", "commaSeparator": false, "roundingMode": "-", "symbolNumber": "-", "negativeNumber": "-", "symbolPosition": "-", "useSymbolSpace": false }, "type": "string", "sample": "FILEPATH" } }, "COUNT(LEN)": { "format": { "category": "Currency", "pattern": { "decimalPlace": "3", "commaSeparator": false, "roundingMode": "Half_Up", "symbolNumber": "$", "negativeNumber": "useBracket", "symbolPosition": "before", "useSymbolSpace": false }, "sample": "$123456123456.000" } }, "checkBookFlag": true }, "colHeaderDetail": { "USERGROUP": { "title": "USERGROUP", "color": "#000000", "text-align": "center", "font-size": "12px", "width": "100px", "font-style": "normal", "background-color": "#cccccc", "font-family": "Verdana", "font-weight": "normal", "format": { } }, "FILEPATH": { "title": "FILEPATH", "color": "#000000", "text-align": "center", "font-size": "12px", "width": "180px", "font-style": "normal", "background-color": "#cccccc", "font-family": "Arial", "font-weight": "normal", "format": { } } }, "selectedGroupBy": [ "USERGROUP", "FILEPATH" ], "selectedColumn": { "USERGROUP": { "function": "" }, "FILEPATH": { "function": "" }, "LEN": { "function": "COUNT" } }, "queryId": "New Query 7" "persistResults": true, "colspanDetail": { "groupFooter": 1, "queryHeader": 1, "groupHeader": 1, "queryFooter": 1 }, }
The following request will add a new Hadoop SQL query.
PUT /queryio/hadoopsql/ HTTP/1.1 Host: QueryIO authorization: iffo6l9hel2hfmbj2384joljgh9mqga58gb9if9593ucli9ke5s2e3854shhcmmm hadoopsql-properties : {"sqlQuery":"SELECT * FROM TAGS_NAMENODE1","chartDetail":{},"selectedOrderBy":[],"selectedTable":["TAGS_NAMENODE1"],"queryHeader":{"header":{"title":""}},"selectedWhere":{},"queryFooter":{"footer":{"title":""}},"groupHeader":{},"queryDesc":"","groupFooter":{},"colDetail":{},"colHeaderDetail":{},"selectedGroupBy":[],"selectedColumn":{"*":{}},"queryId":"Query1"}
<xml version="1.0" encoding="UTF-8"> <SaveHadoopSQL> <Status><true></Status> </SaveHadoopSQL>