Auto-Generate SQL with QI

Introduction

The AI-powered, QI Query Assistant allows users to generate custom SQL reports directly from Insight using Intelligence (QI). The Query Assistant streamlines the reporting process, allowing users to create, modify, or comprehend SQL queries without requiring extensive SQL knowledge. The Query Assistant supports the following three use cases:

  • Generate a New Query - The QI Query generator creates SQL queries based on user-defined reporting needs expressed in simple English, aligned with the QMetry reports schema available in QMetry Insight.

  • Updating an Existing Query - The QI Query generator can help users modify existing SQL queries by adding fields and filters or implementing new logic and operators. To do this, users provide the existing SQL and clear instructions for the desired modifications in English. The output will be an updated custom SQL query reflecting these changes.

  • Explaining Query - The Query Assistant empowers users to understand SQL queries by providing explanations of their logic, tables, and structure. This guidance enables users to comprehend the purpose and functionality of the query, aiding in debugging and troubleshooting.

Best Practices

All features operate according to the reports schema available in Insights. As a best practice, users must clearly describe their reporting needs in detail, specifying exact field names and any conditions or operations such as grouping, filtering, or sorting. The Query generator currently does not support user-defined fields and works only with system fields.

Permission, Configuration and Settings

To activate QI auto-generated SQL queries, the super administrator must enable the setting at the instance level. They can do this from the AI Configuration tab within General Settings and Audit in the Customization module.

Permissions:

  • Only a super admin can access and configure Intelligence Configuration.

  • The default setting for the QI feature is disabled.

QMetry AI Configurations screen highlighting the Generate SQL reports option. This setting allows users to create custom SQL queries using Query Intelligence (QI) from the Advanced Query Report Menu for advanced reporting and data insights.

Auto-Generate SQL with QI

Once the super admin enables the Generate SQL Reports toggle (as shown in the image above), users will see the Classic View and QI View buttons on the advanced query reports screen.

How it works

Upon activating the feature, users will see a new QI View under the Advanced Query Reports menu in Insights, alongside the existing Classic View. The QI View provides instructions and best practices for generating queries. Users can switch between the Classic SQL generation view and the QI View as needed.

Auto-Generate SQL with QI

To auto-generate SQL with QI, perform the following steps:

  1. Go to the Advance Query Reports screen.

  2. Click QI View to access the Generate SQL Using QI.

    QMetry Advance Query Reports screen showing the Query Assistant interface. The highlighted QI View option is active, allowing users to automatically generate SQL for reports using natural language input. The interface includes a sidebar with database fields, example use cases for Requirements, Test Cases, Test Executions, and Issues, as well as best practices for writing effective queries.
  3. Provide a concise description of the reports you want to generate in plain English.

  4. Add the needed filters as prompted. A list of predefined filters can be found in the Filters section on the left side of the screen.

    QMetry Query Assistant interface showing the list of predefined filters such as Project, Release, Cycle, User, and Issue Priority in the sidebar. The “project” filter is applied in the Input section, allowing users to refine SQL query generation results for specific project-related data.
  5. After adding the filters, click Generate Query.

  6. Once the query is generated, click Fetch Filters and Verify to confirm.

    QMetry Query Assistant screen displaying a generated SQL query with highlighted “Fetch Filters & Verify” button. The query includes project and release filters, and a note prompts users to verify that field names and filters match the tables before running the query.
  7. Select the appropriate project and click Run Query.

  8. Review and validate the results.

Generic Prompts Examples

Simple Prompts

  • List all the requirements with the releasename Production 1.0 and cyclename Alpha 1.0.

    • Fetch all the requirements that are linked with test cases.

  • List out all the test cases with releasename = Production 1.0 and cyclename = Alpha 1.0.

  • Fetch all the test cases that are linked with test suites.

  • Fetch all test executions with an approved status.

  • List out all the failed or blocked test executions having releasename = Production 1.0 and cyclename = Alpha 1.0 that have open bugs of critical priority.

  • Fetch all issues with a blocker priority and open status.

  • List all the Issues that are linked with test cases.

  • Fetch details like user alias and last login time for all the active users.

Complex Prompts

  • Need a report of testexecutions of releasename = xyz and cyclename = abc. Also include issue details like status, the count of impacted test cases, and a list of the impacted test cases per issue for the test executions.

  • Provide entity key and summary of defects found during the execution of test cases, categorized by their status, priority. Issues should have a requirement linked.

  • A report that shows the total count of executions executed grouped by execution status.

  • Generate a report having cumulative totals for executions executed daily and grouped by execution status.

Update QI Generated Query

Users can request further modifications and provide specific instructions for the desired changes to the query.

QMetry Query Assistant interface displaying an executed SQL query with results in a table format. The highlighted “Update Query” section allows users to describe and apply changes to the generated query for refining output or adjusting report parameters.

Examples:

  • Modify the query to showcase "Blocker" issues as "Blocker, Critical, and Medium."

  • Change a query displaying the Test Case Key and Summary to include Test Case Labels, Priority, and Status.

  • Update a query to show test cases linked to test executions having issue linked.

  • Add a filter for Execution Status and Platform alongside existing filters for Project, Release, and Cycle.

  • Group results by Execution Status or Platform.

  • Sort issues by created date in descending order.

Provide Feedback

To provide feedback on the QI-generated SQL query, click the Thumbs Up or Thumbs Down button. A pop-up will appear with predefined options, allowing you to choose or submit custom feedback. This helps improve the model's accuracy and performance.

QMetry Query Assistant screen highlighting thumbs up and thumbs down icons for user feedback. The feedback options let users specify details such as “Accurate Query,” “Incorrect Syntax,” or “Need Optimization” to help improve the accuracy and performance of AI-generated SQL queries.

To submit feedback beyond the predefined options, select Other and enter your feedback in the pop-up that appears.

Reset session

Users can reset the SQL query generation page by clicking the Reset Session button.

QMetry Query Assistant screen showing an SQL query with the “Reset Session” button highlighted. This option allows users to clear the current session, remove applied filters, and start a new query-building process from scratch.

Prompt History

Users can access the last three prompts for quick reference by clicking the Prompt History button.

QMetry Query Assistant interface showing the Prompt History panel, which lists the three most recent prompts used to generate SQL queries. The highlighted history icon allows users to reopen and reuse previous prompts for faster query generation.

Explain Query

The QI Explain Query feature empowers users to understand SQL queries by providing explanations of their logic, tables, and structure. This guidance enables users to comprehend the purpose and functionality of the query, aiding in debugging and troubleshooting.

The Explain Query output includes:

  • Purpose of Query: A clear description of the query’s objective and functionality.

  • Original Tables Involved: A list of all tables referenced or used in the query.

  • Columns Affected: A list of all columns affected or used within the query.

  • Filters Applied: Details of any system filters included as part of the query logic.

QMetry Query Assistant interface displaying the “Explain Query” option and corresponding “Explanation” section. The explanation provides details such as the purpose of the query, tables involved, affected columns, and applied filters, helping users understand the logic behind the generated SQL statement.

QI Statistics

System administrators can monitor the usage of the SQL generator feature for all users.

  • Statistics for creating and updating reports using SQL queries generated by QI are accessible in General Settings > AI Configurations.

  • Users can hover over the QI Statistics button to view detailed information on the usage of the QI query generator.

QMetry Insight interface displaying the QI assistant message, “QI has helped you create/update 2 queries,” indicating the total number of SQL queries generated or modified using the Query Intelligence (QI) feature.

Identify QI-Generated Reports

Reports created using SQL queries generated using QI will display the QI logo when added to dashboards. The Custom Gadget list view includes a QI-generated column to identify reports generated with SQL queries from QI.

QMetry Custom Gadget list showing a column labeled “QI Generated,” which indicates whether a report or gadget was created using the QI (Query Intelligence) feature. The column displays “Yes” or “No” to differentiate QI-generated reports from manually created ones.
Publication date: