Skip to main content

Query History

The Spice runtime stores information about completed queries in the spice.runtime.query_history table. Each query executed has a row in this table, and the data is retained for one day. Use a SELECT query to return information about each query as shown in this example:

SELECT
*
FROM
spice.runtime.query_history
LIMIT
100;

Columns in spice.runtime.query_history​

Column NameData TypeDescription
query_idUtf8The unique identifier of the SQL query.
schemaUtf8The schema of the query result.
sqlUtf8The query text of the SQL statement.
nsqlUtf8Optional. If the query was generated through the natural language to SQL API, the natural language text of the query.
start_timeTimestamp(Nanosecond, None)The query execution start time (UTC).
end_timeTimestamp(Nanosecond, None)The query execution end time (UTC).
execution_timeFloat32The total execution time in seconds.
execution_statusInt8The status code returned from query execution.
rows_producedUInt64The total number of rows returned from the query.
results_cache_hitBooleanTrue if the result of the query was returned from the results cache, otherwise, false.
error_messageUtf8The error message that was returned.

Execution Status Codes​

ValueStatusDescription
0SuccessThe query completed with no errors.
-10Syntax ErrorThe SQL query text provided has a syntax error. For instance, a misspelled SQL statement was in the query.
-20Query Planning ErrorAn error occurred while mapping the SQL query to a query plan. For instance, attempting to call a function that does not exist, or providing a query with unsupported types.
-30Query Execution ErrorAn error occurred during execution due to a malformed input. For instance, passing malformed arguments to a SQL method.
-120Internal ErrorAn internal error occurred within Spice.