question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fewer_rows_than sql error

See original GitHub issue

Describe 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

image

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:open
  • Created 10 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nc-rsjocommented, Dec 12, 2022

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 😃

0reactions
joellabescommented, Dec 13, 2022

OK! I’ll leave this open in case anyone else wants to take a stab at it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The SQL command sp_MSget_new_xact_seqno had returned ...
2008-01-07 04:11:24.82 Exception Message: The SQL command 'sp_MSget_new_xact_seqno' had returned fewer rows than expected by the replication ...
Read more >
SQL Server Error Msg 9926 - Informational: MS Search stop ...
SQL Server Error Msg 9926 – Informational: MS Search stop limit reached. The full-text query may have returned fewer rows than it should....
Read more >
PDO SQL Query returning fewer rows than expected
PDO SQL Query returning fewer rows than expected ... I am attempting to build an API to return data from mySQL. I am...
Read more >
PM62259: INCORROUT (FEWER ROWS THAN EXPECTED ...
Error description. Incorrect output may occur when a query contains a subquery predicate and olap specifications and no sort is needed for olap...
Read more >
How to fix a messed up replication on MS SQL Server
The SQL command 'sp_MSactivate_auto_sub' had returned fewer rows than expected by the replication agent. So I tried an alternative method of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found