fewer_rows_than sql error
See original GitHub issueDescribe the bug
There seems to be a SQL error with fewer_rows_than
Steps to reproduce
Use fewer_rows_than on an Oracle database
Expected results
Test Pass or Fail
Actual results
Error 2
Screenshots and log output

System information
The contents of your packages.yml file:
packages:
- package: dbt-labs/dbt_utils version: 0.9.5
Which database are you using dbt with? Oracle
The output of dbt --version:
dbt-oracle = "^1.2.1"
Additional context
SOLUTION: I suggest you remove * from the final CTE, it is not used anyway. Removing “*,” fixes the problem for me
Are you interested in contributing the fix?
This works 😃
{% test fewer_rows_than(model, compare_model) %} {{ return(adapter.dispatch(‘test_fewer_rows_than’, ‘dbt_utils’)(model, compare_model)) }} {% endtest %}
{% macro default__test_fewer_rows_than(model, compare_model) %}
{#-- Needs to be set at parse time, before we return ‘’ below --#} {{ config(fail_calc = ‘coalesce(row_count_delta, 0)’) }}
{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} with a as (
select count(*) as count_a from {{ model }}
), b as (
select count(*) as count_b from {{ compare_model }}
),
final as (
select
case
-- fail the test if we have more rows than the reference model and return the row count delta
when count_a > count_b then (count_a - count_b)
-- fail the test if they are the same number
when count_a = count_b then 1
-- pass the test if the delta is positive (i.e. return the number 0)
else 0
end as row_count_delta
from a
cross join b
)
select * from final
{% endmacro %}
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
I just upgraded to the latest version 1.0.0, and the addition of the “group by” to fewer_rows_than.sql induced some new PL/Sql errors. I’ve made a bunch of changes to my local clone of the repo, and I’m afraid I must admit that it might become too big of a compromise to make it compatible with Oracle. I much appreciate your effort, and dbt-utils is definitely still very helpful 😃
OK! I’ll leave this open in case anyone else wants to take a stab at it.