sdk

No menu items for this category
OpenMetadata Documentation

Table-level test definitions for DQ as Code API.

Classes:

Bases: TableTest

Validates that the number of columns in a table falls within a specified range.

This test checks if the column count is between the minimum and maximum values. Useful for schema validation and detecting unexpected column additions or removals.

Parameters:

  • min_count (Optional[int]) – Minimum acceptable number of columns (inclusive)
  • max_count (Optional[int]) – Maximum acceptable number of columns (inclusive)
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that the table has an exact number of columns.

This test ensures the column count matches a specific expected value. Useful for strict schema validation.

Parameters:

  • column_count (int) – Expected number of columns in the table
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that a specific column exists in the table schema.

This test checks for the presence of a required column by name. Useful for ensuring critical columns are not dropped from the schema.

Parameters:

  • column_name (str) – Name of the column that must exist
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that table columns match an expected set of column names.

This test ensures the table schema contains exactly the specified columns. Optionally can enforce column order matching.

Parameters:

  • column_names (List[str]) – List of expected column names
  • ordered (bool) – If True, column order must match exactly
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates data using a custom SQL query expression.

This test allows you to define custom data quality logic using SQL. The query should return rows that fail the validation criteria.

Parameters:

  • sql_expression (str) – SQL query to execute (returns failing rows)
  • strategy (str) – Validation strategy - "ROWS" counts failing rows, "COUNT" expects a count
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Compares two tables and identifies differences in their data.

This test performs a row-by-row comparison between two tables to detect discrepancies. Useful for validating data migrations, replication, or transformations.

Parameters:

  • table2 (str) – Fully qualified name of the table to compare against
  • key_columns (Optional[str]) – Columns to use as join keys for comparison
  • table2_key_columns (Optional[str]) – Columns from table 2 to use as join keys for comparison
  • use_columns (Optional[str]) – Specific columns to compare (compares all if not specified)
  • extra_columns (Optional[str]) – Additional columns to include in diff output
  • table2_extra_columns (Optional[str]) – Additional columns from table 2 to include in diff output
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that the number of rows in a table falls within a specified range.

This test checks if the row count is between the minimum and maximum values. Useful for monitoring data volume and detecting data loss or unexpected growth.

Parameters:

  • min_count (Optional[int]) – Minimum acceptable number of rows (inclusive)
  • max_count (Optional[int]) – Maximum acceptable number of rows (inclusive)
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that the table has an exact number of rows.

This test ensures the row count matches a specific expected value. Useful for validating fixed-size reference tables or dimension tables.

Parameters:

  • row_count (int) – Expected number of rows in the table
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining

Bases: TableTest

Validates that the number of rows inserted within a time range is within bounds.

This test monitors data ingestion rates by checking if newly inserted rows fall within expected thresholds over a specified time period. Requires a timestamp column to track insertions.

Parameters:

  • min_count (Optional[int]) – Minimum acceptable number of inserted rows (inclusive)
  • max_count (Optional[int]) – Maximum acceptable number of inserted rows (inclusive)
  • range_type (str) – Time unit for the range ("HOUR", "DAY", "WEEK", "MONTH")
  • range_interval (int) – Number of time units to look back
  • name (Optional[str]) – Custom test case name
  • display_name (Optional[str]) – Custom display name for UI
  • description (Optional[str]) – Custom test description

Examples:

Functions:

Attributes:

Create a test case definition from this test definition. Returns: TestCaseDefinition instance

Enable or disable passed/failed row count computation.

When enabled, the test will compute and report the number and percentage of rows that passed or failed the test validation.

Parameters:

  • compute (bool) – Whether to compute row-level pass/fail statistics

Returns:

  • Self – Self for method chaining

Set a custom description.

Parameters:

  • description (str) – Detailed description of what this test validates

Returns:

  • Self – Self for method chaining

Set a custom display name.

Parameters:

  • display_name (str) – Human-readable name for UI display

Returns:

  • Self – Self for method chaining

Set a custom test case name.

Parameters:

  • name (str) – Unique identifier for this test case

Returns:

  • Self – Self for method chaining