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

AttributeError: 'str' object has no attribute 'is_type' #2600

Closed
anentropic opened this issue May 13, 2024 · 3 comments · Fixed by #2694
Closed

AttributeError: 'str' object has no attribute 'is_type' #2600

anentropic opened this issue May 13, 2024 · 3 comments · Fixed by #2694
Assignees
Labels
Bug Something isn't working

Comments

@anentropic
Copy link
Contributor

when running sqlmesh plan I got this error:

AttributeError: 'str' object has no attribute 'is_type'
Error: Failed to resolve macro for expression. Error trying to eval macro.

if I stick a breakpoint in I find:

sqlmesh/utils/__init__.py(330)type_is_known()
-> raise
(Pdb++) l
325  	    try:
326  	        if d_type.is_type(exp.DataType.Type.UNKNOWN, exp.DataType.Type.NULL):
327  	            return False
328  	    except:
329  	        breakpoint()
330  ->	        raise
331  	    if d_type.expressions:
332  	        return all(type_is_known(expression) for expression in d_type.expressions)
333  	    return True
334
335
(Pdb++) d_type
'UNKNOWN'

the offending code in my model file is here:

select
    @STAR(order_dedup)
from order_dedup
where
    snowflake_last_ingested_at between @start_ts and @end_ts

where order_dedup is a View model, perhaps that is the problem (?)

However if I amend the error handling code to:

        if d_type == 'UNKNOWN' or d_type.is_type(exp.DataType.Type.UNKNOWN, exp.DataType.Type.NULL):
            return False

then the plan succeeds and I get the option to apply it

@georgesittas
Copy link
Contributor

Hey @anentropic, thanks for the report. Can you share the full stack trace? How do you reach sqlmesh/utils/__init__.py(330)type_is_known()?

@georgesittas
Copy link
Contributor

Nvm, I think I see the issue. Will fix shortly.

@anentropic
Copy link
Contributor Author

the stack trace was:

  File "/Users/anentropic/dev/etl-future/.venv/lib/python3.11/site-packages/sqlmesh/core/macros.py", line 214, in send
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/anentropic/dev/etl-future/.venv/lib/python3.11/site-packages/sqlmesh/core/macros.py", line 834, in star
    if columns_to_types_all_known(columns_to_types):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/anentropic/dev/etl-future/.venv/lib/python3.11/site-packages/sqlmesh/utils/__init__.py", line 334, in columns_to_types_all_known
    return all(type_is_known(expression) for expression in columns_to_types.values())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/anentropic/dev/etl-future/.venv/lib/python3.11/site-packages/sqlmesh/utils/__init__.py", line 334, in <genexpr>
    return all(type_is_known(expression) for expression in columns_to_types.values())
               ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/anentropic/dev/etl-future/.venv/lib/python3.11/site-packages/sqlmesh/utils/__init__.py", line 325, in type_is_known
    if d_type.is_type(exp.DataType.Type.UNKNOWN, exp.DataType.Type.NULL):
       ^^^^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants