---
title: SQL Pattern Matching
description: Validates that column values conform to specific SQL `LIKE` patterns using wildcards.
group: Validity
---

# SQL Pattern Matching

The **SQL Pattern Matching** rule ensures values in a dataset match specified text patterns using SQL `LIKE` syntax.  
This rule is commonly used to:

- Identify and validate values like email domains, phone number formats, or prefixes.
- Enforce standardized value formats within columns for consistency.

**Example Usage**:  
Check if email addresses belong to Gmail (`%@gmail.com`) or verify if customer names start with 'A'.

---

## Configuration Fields  

### Rule-Specific Configuration  

| Field Name          | Description                                                     | Required | Data Type / Options |
|:-------------------|:----------------------------------------------------------------|:-----------|:--------------------|
| **SQL Like Pattern** | SQL `LIKE` pattern to apply for value matching (use `%` and `_`) | Yes       | String               |

---

### Success Criteria Configuration  

This section defines how the rule’s outcome is measured against expected thresholds.

| Field Name        | Description                                                  | Required | Options / Format |
|:------------------|:-------------------------------------------------------------|:-----------|:-----------------|
| **Operator**        | Comparison operation for the result count                    | Yes       | `GreaterThan`, `LessThan`, `EqualTo`, `Between` |
| **Threshold Value** | Value for comparison (for `GreaterThan`, `LessThan`, `EqualTo`) | Conditional| Number |
| **Threshold Min**   | Minimum value (for `Between` operator)                        | Conditional| Number |
| **Threshold Max**   | Maximum value (for `Between` operator)                        | Conditional| Number |
| **Is Percentage**   | Whether the threshold represents a percentage or an absolute count | No        | `true` / `false` (default: `false`) |
| **Allow Nulls**     | Whether null values are considered valid                     | No        | `true` / `false` (default: `false`) |
| **Check For Match** | When `false`, validates for negation of the condition         | No        | `true` / `false` (default: `true`) |

---

## Sample Input Data  

| ID | Email               | Name   |
|:----|:--------------------|:--------|
| 1  | alice@gmail.com     | Alice   |
| 2  | bob@yahoo.com       | Bob     |
| 3  | charlie@gmail.com   | Charlie |
| 4  | dave@hotmail.com    | Dave    |
| 5  | eve@gmail.com       | Eve     |

---

## Sample Configurations  

### Example 1: Email Domain Check  



| Configuration Field | Value         |
|:---------------------|:---------------|
| Column                | Email          |
| SQL Like Pattern       | `%@gmail.com`  |
| Operator              | GreaterThan    |
| Threshold Value       | 50             |
| Is Percentage         | true           |
| Allow Nulls           | false          |
| Check For Match       | true           |

**Explanation**:  
Validates that more than 50% of emails belong to Gmail.

---

### Example 2: Name Prefix Check  



| Configuration Field | Value      |
|:---------------------|:------------|
| Column                | Name       |
| SQL Like Pattern       | `A%`        |
| Operator              | GreaterThan|
| Threshold Value       | 0          |
| Is Percentage         | false      |
| Allow Nulls           | false      |
| Check For Match       | true       |

**Explanation**:  
Validates that at least one name starts with 'A'.

---

## Sample Output  

| Column Name | Rule Name            | Success Count | Failure Count | Null Count | Within Threshold |
|:------------|:---------------------|:---------------|:---------------|:------------|:------------------|
| Email        | SQL Pattern Matching  | 3             | 2             | 0          | Yes               |
| Name         | SQL Pattern Matching  | 1             | 4             | 0          | Yes               |

---
