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

On Oracle, checks involving regular expressions are generated incorrectly. #2125

Open
stelapo opened this issue Jul 4, 2024 · 2 comments
Open

Comments

@stelapo
Copy link

stelapo commented Jul 4, 2024

Hi,
I report a recent bug introduced after version 3.3.6; it is not there in that version.

With the Oracle datasource, checks via regex are resolved by Soda generating a query that misuses the NVL function by applying it to the REGEX_LIKE function.

I explain better with an example.

The check is:

checks for BENEFICIARIO_LIGHT:
  - invalid_percent(TELEFONO) = 0:
      name: Invalid beneficiary telephone number
      valid format: phone number

Wrong query generated by Soda (version 3.3.9):

SELECT
  COUNT(*),
  COUNT(CASE WHEN NOT (TELEFONO IS NULL) AND NOT (NVL(REGEXP_LIKE(TELEFONO, '^((\+[0-9]{1,2}\s)?\(?[0-9]{3}\)?[\s.-])?[0-9]{3}[\s.-][0-9]{4}$'), 0)) THEN 1 END)
FROM BENEFICIARIO_LIGHT

Corrected query generated by Soda (version 3.3.6):

SELECT
  COUNT(*),
  COUNT(CASE WHEN NOT (TELEFONO IS NULL) AND NOT (REGEXP_LIKE(TELEFONO, '^((\+[0-9]{1,2}\s)?\(?[0-9]{3}\)?[\s.-])?[0-9]{3}[\s.-][0-9]{4}$')) THEN 1 END) 
FROM BENEFICIARIO_LIGHT

As can be seen, the use of the NVL function was mistakenly introduced in the first query.

All forms of checks involving regular expressions are generated incorrectly; another example:

checks for BENEFICIARIO_LIGHT:
  - invalid_percent(EMAIL) = 0:
      name: Invalid beneficiary email
      valid regex: ${EMAIL_REGEX}

Thank you

@tools-soda
Copy link

CLOUD-8028

@stelapo
Copy link
Author

stelapo commented Jul 12, 2024

Update: today I tried version 3.3.10 and the problem persists.

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

2 participants