Click Query in the top navigation menu to access several data management tools.
The SQL Tool allows you to perform SQL queries against the data in Kinetica from Kinetica Administration Application (GAdmin). The SQL Tool works similarly to the SQL Lab in Reveal but has fewer restrictions. To read more about using the SQL Tool from the command line (also known as KiSQL), review Kinetica SQL (KiSQL).
Several actions are available from this tool:
Note
The WMS and Explain functionality can act on everything in the SQL Statements area or highlighted text, but they cannot be executed if there are multiple statements in the text area with nothing highlighted.
SQL snippets and autocomplete are also available to help expedite writing queries.
The explain plan visualizer is a graphical complement to using the EXPLAIN
keyword in a given query, providing visual detail to the
SQL query's execution plan, execution time, and native API translation(s).
Note
The explain plan visualizer cannot be used in conjunction with
the EXPLAIN
keyword.
Clicking Explain will not execute the query (initially); the database will walk through the native actions necessary to execute the query and show the plan. Once the query plan is output, the query can be executed and analyzed using the Run & Analyze button (with Verbose optionally providing more execution detail).
For example, the executing the following:
EXPLAIN /* KI_HINT_COMPARABLE_EXPLAIN */
SELECT
n_begin.ntaname AS boro_begin,
boro_end,
COUNT(*) AS total_trips
FROM
(
SELECT pickup_latitude, pickup_longitude, n_end.ntaname AS boro_end
FROM nyctaxi t
JOIN nyct2010 n_end ON STXY_INTERSECTS(dropoff_longitude, dropoff_latitude, geom)
)
JOIN nyct2010 n_begin ON STXY_INTERSECTS(pickup_longitude, pickup_latitude, geom)
GROUP BY 1, 2
Yields a text-only explain output:
+------+-------------------------+------------------------------------------------------+----------------+----------------+
| ID | ENDPOINT | INPUT_TABLES | OUTPUT_TABLE | DEPENDENCIES |
+------+-------------------------+------------------------------------------------------+----------------+----------------+
| 0 | /create/jointable | nyctaxi AS TableAlias_0_,nyct2010 AS TableAlias_1_ | Join_3 | -1 |
| 1 | /create/jointable | Join_3 AS TableAlias_0_,nyct2010 AS TableAlias_1_ | Join_6 | 0 |
| 2 | /aggregate/groupby | Join_6 | Aggregate_8 | 1 |
| 3 | /get/records/bycolumn | Aggregate_8 | | 2 |
+------+-------------------------+------------------------------------------------------+----------------+----------------+
Running the same query (without the EXPLAIN
keyword included) but this time
clicking Explain would yield the graphical query plan:
Tip
Hover over steps in the query plan to view the API call that would occur in the background when executing the original query. Hover over table names to view the table's schema. Click Export JSON to export the text-based explain output to a JSON file.
Subsequently, click Run & Analyze to execute the query and see the execution time for each step in the plan.
The steps are color-coded based on how fast they were in relation to the other steps in the query.
If an error occurs in the query, it will be displayed in the plan at the point it occurred. Mousing over the error will show the details of the call and the error message.
The SQL Procedures page displays all existing SQL procedures. Review SQL Procedures for more information on SQL procedures.
The SQL procedure creation process is simplified when using the interface; all that's required to get started is some SQL code.
From the SQL Procedures page, click Create.
Provide a Name for the procedure.
Optionally, provide an Execution Interval. Units can one of the following:
SECOND[S]
MINUTE[S]
HOUR[S]
DAY[S]
Optionally, provide a Start Timestamp. The provided value should be in the following format:
YYYY-MM-DD [HH:MM[:SS]]
Provide one or more semi-colon-separated SQL statements in the Statements text field. Review the supported statements.
Click Create.
While all SQL procedures are able to be viewed by any user, they can only be executed by certain users. To adjust the execute permissions for a particular SQL procedure:
sql_proc_execute
permission on the selected SQL procedure.sql_proc_execute
permission on the selected procedure.sql_proc_execute
permission on the selected SQL procedure.sql_proc_execute
permission on the selected procedure.The API Tool allows you to call any Kinetica REST endpoint with a given set of parameters.
Request Mode allows the choice of two methods for passing parameters in endpoint calls:
The result of the request is output to the Logs panel. Click Clear at the bottom to clear the output.
The History tab lists previously executed commands and their results. Click Reload to load the selected endpoint and associated parameters into the Builder for subsequent re-execution. Click Clear Saved Queries in the top right-hand corner to delete the query history.
Clicking the API Docs button will print the corresponding documentation entry for the endpoint in the Logs panel to the right.
The Builder mode of the API Tool displays a user entry control for each of the selected endpoint's parameters. Each control will show the parameter name & type and the option to enter the parameter as Text or to use a parameter from the previous request's Response or Request object. The last set of parameters used in an endpoint call will be saved until the next time the endpoint is queried.
Each request will log the request parameters in JSON format at the top of the Logs panel to the right. This request block can then be fed back into the API Tool in JSON mode, which may facilitate repeated querying, as the entire request can be seen and modified at one time.
Here is an example of a request to the /aggregate/groupby endpoint in Builder mode:
The JSON mode of the API Tool provides a user entry control to enter the request parameters as a single block of JSON. The last JSON request will be saved until the next time the endpoint is queried.
Here is an example of a request to the /aggregate/groupby endpoint in JSON mode:
The DDL Tool provides the ability to generate DDL for a given table, collection, or all database entities at once. To read more about using the DDL Tool from the command line (also known as KiDDL), review Kinetica Data Definition Language (KiDDL).
Enter a table name, collection name, or *
, and click
Generate DDL to output the DDL to DDL Output. Click
Export DDL to save the generated DDL as a SQL script.
The output from this utility can be copied into the SQL Statements area on the SQL Tool page and run in order to regenerate the database entities whose DDL has been generated.