soda-core icon indicating copy to clipboard operation
soda-core copied to clipboard

Duplicate count check: on Oracle datasource wrong query to select failed rows

Open stelapo opened this issue 1 year ago • 2 comments

``Hello, I found a bug relative to selection of failed rows when executing checks on Oracle datasource.

Soda builds the query using LIMIT keyword, but it doesn't exist in Oracle.

Query error: oracle_beneficiario_with_connstring_dev.MYTABLE.duplicate_count[MYCOLUMN].failed_rows.aggregated: ORA-00933: SQL command not properly ended

WITH frequencies AS (
    SELECT MYCOLUMN, COUNT(*) AS frequency
    FROM MYTABLE
    WHERE MYCOLUMN IS NOT NULL
    GROUP BY MYCOLUMN)
SELECT *
FROM frequencies
WHERE frequency > 1
ORDER BY frequency DESC
LIMIT 10

The correct query should use the ROWNUM keyword:

WITH frequencies AS (
    SELECT MYCOLUMN, COUNT(*) AS frequency
    FROM MYTABLE
    WHERE MYCOLUMN IS NOT NULL
    GROUP BY MYCOLUMN)
SELECT *
FROM frequencies
WHERE frequency > 1
  AND ROWNUM <= 10
ORDER BY frequency DESC

stelapo avatar Apr 18 '24 10:04 stelapo

SAS-3269

tools-soda avatar Apr 18 '24 10:04 tools-soda

Hi @stelapo! Thanks for letting us know. We're happy to accept any contribution to the project, so if you're already aware of the solution, feel free to open up a PR and we'll help you through getting it merged.

If not we'll of course try to fix it at some point. :)

dirkgroenen avatar Apr 19 '24 08:04 dirkgroenen

Fixed in #2101

m1n0 avatar Jun 20 '24 04:06 m1n0

Hi, this issue has been closed, but the problem is still present. I tried with the last version 3.3.9

Soda builds the query to select failed rows samples using LIMIT keyword, but it doesn't exist in Oracle.

Thank you

stelapo avatar Jul 04 '24 14:07 stelapo