OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

OpenMetadata Profiler Crashes on MSSQL VARCHAR Columns During Data Profiling – Invalid Cast to SMALLINT

Open filipimr opened this issue 1 year ago • 3 comments

Profiler fails entire table when applying numeric metrics to varchar columns with valid string data

Affected module

Ingestion Framework – Profiler Agent (data profiling execution)


Describe the bug

When executing the Profiler Agent on a MSSQL view, the profiling fails entirely if a column defined as varchar contains normal string values (e.g., 'SSN') and the profiler attempts to apply numeric-based metrics.

The view and column are correctly typed as varchar(255), and the value 'SSN' is valid and expected. There is no inconsistency in the database schema.

Yet, the profiler raises the following error repeatedly:

(pytds.tds_base.OperationalError) Conversion failed when converting the varchar value 'SSN' to data type smallint.

This indicates the profiler is improperly casting varchar to numeric types internally, which results in aborting the profiling of the entire table — even when other columns are fully valid.


To Reproduce

Steps:

  1. Create a view in MSSQL that includes a varchar(255) column containing text values like 'SSN'.
  2. Configure a profiler ingestion pipeline in OpenMetadata.
  3. Set includeViews: true and allow default metric inference.
  4. Run the profiler and observe the failure.

Log snippet:

(pytds.tds_base.OperationalError) Conversion failed when converting the varchar value 'SSN' to data type smallint.

Screenshots: (attached)


Expected behavior

We expect OpenMetadata Profiler to:

  • Automatically skip numeric metrics (min, max, stddev, quantile, etc.) for non-numeric columns like varchar.
  • Not apply casts that violate the column's declared SQL type.
  • Profile the rest of the table even if one column fails.

This behavior is critical for environments that use views with mixed data types.


Technical Context

This is not a database issue. The view was verified by the DBA. All columns involved are explicitly defined as varchar(255), and no implicit casting exists.

Therefore, this profiling error should not happen. The system should recognize the column's data type and skip incompatible metrics instead of applying numeric profiling logic to a varchar.

This is a blocker for using the profiler safely on real-world datasets.


Version Information

  • OS: Ubuntu 22.04 (Dockerized environment)
  • Python version: 3.10
  • OpenMetadata version: 1.7.0
  • OpenMetadata Ingestion package: openmetadata-ingestion[docker]==1.7.0.0

Additional context

A temporary workaround is to manually exclude the problematic column using excludeColumns or restrict the metrics to safe ones like:

metrics:
  - count
  - nullCount
  - nonNullCount
  - distinctCount

However, that approach doesn't scale for large environments. The system should be robust enough to handle column type inference without crashing the entire profiling process.

This needs to be fixed in the ingestion framework's handling of metric-type inference and application logic.

filipimr avatar Jul 22 '25 12:07 filipimr

@filipimr thank you for your research on this, would you be interested in contributing the fix? Also if you can share evidence of the entire profiler failing and not computing the rest of the metrics we would appreciate it.

TeddyCr avatar Jul 22 '25 14:07 TeddyCr

@filipimr I am unable to reproduce this error in 1.9.x -- see attached. Can you confirm you are using MSSQL and not AzureSQL. Can you confirm if you are still seeing the issue in the latest version?

Image Image Image Image

TeddyCr avatar Aug 18 '25 13:08 TeddyCr

Closing this as not answer in the last 30 days

TeddyCr avatar Sep 16 '25 06:09 TeddyCr