Skip to content

Conversation

@tobymao
Copy link
Contributor

@tobymao tobymao commented Feb 16, 2023

No description provided.

@tobymao tobymao requested a review from a team February 16, 2023 00:59
return self.columns_to_types_

if self._columns_to_types is None:
query = annotate_types(self._query_renderer.render())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic. If the optimizer fails because of something other than type annotation we'll ignore the error in the QueryRenderer but will then get an obscure error while trying to add a time filter:

sqlmesh/core/model/definition.py:544: in render_query
    return self._query_renderer.render(
sqlmesh/core/renderer.py:188: in render
    self.filter_time_column(node, *dates[0:2])
sqlmesh/core/renderer.py:216: in filter_time_column
    low = self._time_converter(start)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = Model<name: a, query: SELECT 1, ds>, time = datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)

    def convert_to_time_column(self, time: TimeLike) -> exp.Expression:
        """Convert a TimeLike object to the same time format and type as the model's time column."""
        if self.time_column:
            if self.time_column.format:
                time = to_datetime(time).strftime(self.time_column.format)

            time_column_type = self.columns_to_types[self.time_column.column]
>           if time_column_type.this in exp.DataType.TEXT_TYPES:
E           AttributeError: 'NoneType' object has no attribute 'this'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotate types doesn’t work well on unoptimizable sql.

@tobymao tobymao enabled auto-merge (squash) February 16, 2023 04:08
@tobymao tobymao merged commit a015602 into main Feb 16, 2023
@tobymao tobymao deleted the toby/optimize_all branch February 16, 2023 04:14
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

Successfully merging this pull request may close these issues.

3 participants