Copy Testcase Statements

The COPY TESTCASE statement allows users to export table or view metadata involved in a query, allowing developers to replay the metadata in a local cluster for testing and debugging purposes.

Exporting Metadata to a File

Use the following syntax to dump metadata:
COPY TESTCASE TO <hdfs/s3 dirpath> <query stmt>
Example:
COPY TESTCASE TO '/tmp' SELECT * FROM functional_parquet.alltypes;
Output:

+--------------------------------------------------------------------------------------+
| Test case data output path                                                           |
+--------------------------------------------------------------------------------------+
| hdfs://localhost:20500/tmp/impala-testcase-data-f41f7b14-dfc8-408b-ac3b-ef49fc3e0a83 |
+--------------------------------------------------------------------------------------+

Loading Metadata into a Target Cluster

To load the previously exported metadata, use the following syntax:
COPY TESTCASE FROM <hdfs/s3 testcase file path>
Example:
COPY TESTCASE FROM '/tmp/impala-testcase-data-f41f7b14-dfc8-408b-ac3b-ef49fc3e0a83';
Output:

+----------------------------------------------------------------------------------------------------------------+
| summary                                                                                                        |
+----------------------------------------------------------------------------------------------------------------+
| Testcase generated using Impala version 4.5.0-SNAPSHOT. 1 db(s), 1 table(s) and 0 view(s) imported for query:  |
|                                                                                                                |
| SELECT * FROM functional_parquet.alltypes                                                                      |
+----------------------------------------------------------------------------------------------------------------+

Using the Imported Metadata

To use the imported metadata in query planning, enable the planner testcase mode:
SET PLANNER_TESTCASE_MODE=true;
You can now interact with the metadata using commands like:
SHOW COLUMN STATS functional_parquet.alltypes;