dbt Tests

expect_column_value_lengths_to_equal

dbt-expectations

·

Column

·

Values format

How it Works

The expect_column_value_lengths_to_equal test from the dbt-expectations package verifies that every value in a column has exactly a specified character length. This is ideal for fixed-format identifiers like national ID numbers, ISO country codes, or product SKUs that always require a precise length.

Steps and Conditions

  1. Column Selection: Identify the column to evaluate.

  2. Set Expected Length: Provide the required character length using value.

  3. Optional Row Condition: Filter rows with row_condition if needed.

  4. Execution: The length of each value is measured and compared to the expected value.

  5. Outcome: Pass if all values have the correct length; fail if any deviate.

Example Usage: Banking

A banking platform stores IBAN codes that are always 22 characters for a specific country. The team wants to enforce this constraint at the data layer.

models:
  - name: bank_accounts
    columns:
      - name: iban_code
        tests:
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 22
models:
  - name: bank_accounts
    columns:
      - name: iban_code
        tests:
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 22
models:
  - name: bank_accounts
    columns:
      - name: iban_code
        tests:
          - dbt_expectations.expect_column_value_lengths_to_equal:
              value: 22

Any IBAN code that is shorter or longer than 22 characters will fail the test, alerting the team to a data entry or ingestion error.

Interested to Learn More?
Try Out the Free 14-Days Trial

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Stop Managing Pipelines. Start Shipping Them.

Join the teams that replaced manual dbt™ workflows with agentic AI. Free to start, no credit card required.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.

Copyright © 2026 Paradime Labs, Inc. Made with ❤️ in San Francisco ・ London

*dbt® and dbt Core® are federally registered trademarks of dbt Labs, Inc. in the United States and various jurisdictions around the world. Paradime is not a partner of dbt Labs. All rights therein are reserved to dbt Labs. Paradime is not a product or service of or endorsed by dbt Labs, Inc.