The EXPLAIN OUTPUT statement returns metadata about the output of a specified query. This topic describes the syntax, command format, and usage examples of EXPLAIN OUTPUT.
Overview
The EXPLAIN OUTPUT statement returns metadata about the output of a specified query. This allows you to quickly inspect the column names and data types of a query result before execution, facilitating data development, API integration, and result verification.
Syntax
EXPLAIN OUTPUT <dml query>;dml query: Required. A SELECT statement. For more information, see SELECT syntax.
Response
The statement returns metadata about the query output, including the column name (name) and the column data type (type).
You can also set SET odps.sql.select.output.format=json; to return the column names and data types in JSON format.
Examples
Example 1: Return metadata in default table format
Run the EXPLAIN OUTPUT statement to return metadata in the default table format.
EXPLAIN OUTPUT SELECT
TO_TIME(15, 30, 0) AS time,
GET_JSON_OBJECT(JSON '{"name": "Alice", "age": 30}', '$.name') AS user
;The following result is returned:
name type
------------
time BIGINT
user STRINGExample 2: Return metadata in JSON format
Set SET odps.sql.select.output.format=json; to return the column names and data types in JSON format.
SET odps.sql.select.output.format=json;
EXPLAIN OUTPUT SELECT
TO_TIME(15, 30, 0) AS time,
GET_JSON_OBJECT(JSON '{"name": "Alice", "age": 30}', '$.name') AS user
;The following result is returned:
{"columns":[{"name":"time","type":"BIGINT"},{"name":"user","type":"STRING"}]}