Feature: Filter Pipeline Results with SQL Queries
Scenario: Create a new table from a raw SQL query
Given I am on the "Data Labeling" page
And the "Filter by SQL" option is selected
When I enter the following SQL query in the text field:
"""sql
select "descriptor",descriptor_to_sanitize_cleaned, channel, card_acceptor_id,amount,taxonomy_root,city,state_location, mcc,count(*) as trans_count
from pipeline_output.cc_pipeline_results_2024_h1_0721 cpr
where process = 'Sanitization'
group by "descriptor",descriptor_to_sanitize_cleaned, channel, card_acceptor_id,amount,taxonomy_root,city,state_location,mcc
order by trans_count desc
limit 50
"""
And I click the "Submit" button
Then a new table should be created based on the query results
And the table should contain the columns: "descriptor", "descriptor_to_sanitize_cleaned", "channel", "card_acceptor_id", "amount", "taxonomy_root", "city", "state_location", "mcc", "trans_count"
And the table should be sorted by "trans_count" in descending order
And the table should contain a maximum of 50 rows
Explanation:
- Feature: Describes the overall functionality being tested.
- Scenario: Outlines a specific test case within the feature.
- Given: Sets up the preconditions for the test.
- When: Describes the actions performed by the user.
- Then: Defines the expected outcomes of the actions.
- """sql ... """: This is a common way in Gherkin to represent multi-line strings, especially for code snippets.
Key Considerations:
- Verification of Table Creation: The step "Then a new table should be created based on the query results" will require implementation in your step definitions. This might involve checking for the existence of the table in the database or verifying its presence in the UI.
- Column Validation: Similarly, you will need to implement logic to verify the presence and correct order of columns in the resulting table.
- Data Validation: While this scenario focuses on the table structure, you might consider adding steps to validate the data within the table. This could involve checking specific rows or aggregations to ensure the query executed correctly.
- Error Handling: Consider adding scenarios to test invalid SQL queries and ensure the application handles them gracefully.
This feature file provides a starting point for testing the SQL filtering functionality. You can expand it further by adding more scenarios to cover different query types, error handling, and specific data validation requirements. Remember to implement the corresponding step definitions in your chosen programming language to automate these tests.