EqualExperts/dbt-unit-testing

Add float precision tolerance within dbt_unit_testing.expect()

nik-sigtech opened this issue · 0 comments

Hello,

I am running into float precision mismatches between my expected output and the test output.

Test output diff:

TRADING_DATETIME ITEM VALUE
2019-05-10 ROE -269.09999999999997
2013-12-31 ROE -138.4
2013-12-31 ROE -138.39999999999998
2019-05-10 ROE -269.1

Note the value column.

It would be great to specify a tolerance for floats where mismatches beyond the tolerance are not flagged as test errors.

Here is my test definition, where I've made use of seeds to mock the input and provide the expectation

{% call dbt_unit_testing.test('timeseries__fundamentals__clean', 'Test external source table ingestion') %}

  {% call dbt_unit_testing.mock_source ('single_stock', 'timeseries__fundamentals') %}
    select * from {{ ref('data_platform', 'test_data_in__fundamentals') }}
  {% endcall %}

  {% call dbt_unit_testing.expect() %}
    select * from {{ ref('data_platform', 'test_data_out__fundamentals__clean') }}
  {% endcall %}

{% endcall %}