Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
stelapo opened this issue Apr 18, 2024 · 2 comments

Comments

@stelapo
Copy link

stelapo commented Apr 18, 2024

``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
@tools-soda
Copy link

SAS-3269

@stelapo stelapo changed the title On Oracle datasource wrong query to select failed rows Duplicate count check: on Oracle datasource wrong query to select failed rows Apr 18, 2024
@dirkgroenen
Copy link
Contributor

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants