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

Validator is not handling BigQuery CAST function properly #46

Open
alexandregirbal-loxsolution opened this issue Jun 7, 2022 · 3 comments

Comments

@alexandregirbal-loxsolution

Using Python3.8 in a virtual environment, this query is showing an error even though it's working properly for Google BigQuery:

query = """
SELECT
    CAST(
        DATE_ADD(invoice_date, INTERVAL payment_term DAY) 
    AS STRING) AS invoice_due_date,
    
FROM Invoicing
"""
parsed_query = sqlvalidator.parse(query)
parsed_query.is_valid() # crashes here

Here is the error:

  File "home/alexandre/TestSqlValidator/venv/lib/python3.8/site-packages/sqlvalidator/sql_validator.py", line 25, in is_valid
    self._validate()
  File "home/alexandre/TestSqlValidator/venv/lib/python3.8/site-packages/sqlvalidator/sql_validator.py", line 31, in _validate
    self.errors = self.sql_query.validate()
  File "home/alexandre/TestSqlValidator/venv/lib/python3.8/site-packages/sqlvalidator/grammar/sql.py", line 133, in validate
    errors += e.validate(known_fields)
  File "home/alexandre/TestSqlValidator/venv/lib/python3.8/site-packages/sqlvalidator/grammar/sql.py", line 1064, in validate
    errors += self.expression.validate(known_fields)
  File "home/alexandre/TestSqlValidator/venv/lib/python3.8/site-packages/sqlvalidator/grammar/sql.py", line 557, in validate
    errors += a.validate(known_fields)
AttributeError: 'str' object has no attribute 'validate'
@mozart-segfy
Copy link

@alexandregirbal-loxsolution this pull request also solves your issue: #52 (comment)

@walshbm15
Copy link

Is this able to be merged? I am also running into the same issue where validating with cast is not working

@frg100
Copy link

frg100 commented Mar 24, 2024

Also seeing this issue

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

4 participants