Hi, I'am looking for which query is run to populat...
# ask-elementary-ai
c
Hi, I'am looking for which query is run to populate Unique tests executions graph un elementary report ?
k
A message from kapa.ai
To populate the "Unique test executions" graph in the Elementary report, Elementary Data queries the
elementary_test_results
table, which stores all test execution results. Based on the knowledge sources, when you run
edr report
or
edr send-report
, Elementary executes several dbt operations to collect data for the report. Specifically, it runs the
elementary_cli.get_test_results
macro which retrieves test execution data from the Elementary schema in your data warehouse. The test results data comes from the
elementary_test_results
table, which is populated whenever you run dbt tests. This table contains information about each test execution, including the test unique ID, status, and when it was detected. To get the unique test executions for the graph, Elementary likely uses a query similar to:
Copy code
sql WITH elementary_test_results AS (     SELECT          *,         ROW_NUMBER() OVER (             PARTITION BY test_unique_id ORDER BY detected_at DESC         ) AS row_num     FROM elementary_test_results )  SELECT * FROM elementary_test_results WHERE row_num = 1 ORDER BY detected_at DESC
This query would retrieve the most recent execution of each unique test, which is what the "Latest unique test results by status" description suggests. If you want to explore this data yourself, you can query the
elementary_test_results
table in your data warehouse, which contains all the test execution data that Elementary uses to generate the report. I hope this helps! Let me know if you have any other questions about Elementary Data.