Repository: SuperDuperDB/superduperdb
File: superduperdb/backends/ibis/query.py (Python)

Code before:
                                version=db.show('model', model)[-1]
                            ),
                        )
                    )
                }
            )
            attr = getattr(  # type: ignore[call-overload]
                self, self.table_or_collection.primary_id
            )
            other_query = self.join(symbol_table, symbol_table.input_id == attr)
            other_query.filter(
                symbol_table.key == key and symbol_table.query_id == query_id
            )
            return other_query

    def compile(self, db: 'Datalayer', tables: t.Optional[t.Dict] = None):
        table_id = self.table_or_collection.identifier
        if tables is None:
            tables = {}
        if table_id not in tables:
            tables = {table_id: db.databackend.conn.table(table_id)}
        result = tables[table_id]
        for member in self.members:
            result, tables = member.compile(parent=result, db=db, tables=tables)
        return result, tables

    def execute(self, db):
        native_query, _ = self.compile(db)
        try:
            result = native_query.execute()
        except Exception as exc:
            raise IbisBackendError(
                f'{native_query} Wrong query or not supported yet :: {exc}'
            )
        return result


class QueryType(str, enum.Enum):
    QUERY = 'query'
    ATTR = 'attr'


@dc.dataclass(repr=False)
class Table(Component):
    """
    This is a representation of an SQL table in ibis,
    saving the important meta-data associated with the table
    in the ``superduperdb`` meta-data store.

    :param identifier: The name of the table
    :param schema: The schema of the table

Review comment (suggestion):
We don't need query_id to query the data, just use symbol_table.key, and query_id is build as `hash(query)`, It will change




we just need to use model_message to query data in func `_outpus(model_message)`.

Code after:
                        lambda db, value: value.format(
                            version=db.show('model', model)[-1]
                        ),
                    )
                ),
                primary_id='output_id',
            )
            symbol_table = symbol_table.relabel(
                {
                    'output': (
                        f'_outputs.{key}.{model}.{version}'
                        if version is not None
                        else Variable(
                            f'_outputs.{key}.{model}' + '.{version}',
                            lambda db, value: value.format(
                                version=db.show('model', model)[-1]
                            ),
                        )
                    )
                }
            )
            attr = getattr(  # type: ignore[call-overload]
                self, self.table_or_collection.primary_id
            )
            other_query = self.join(symbol_table, symbol_table.input_id == attr)
            other_query = other_query.filter(symbol_table.key == key)
            return other_query

    def compile(self, db: 'Datalayer', tables: t.Optional[t.Dict] = None):
        table_id = self.table_or_collection.identifier
        if tables is None:
            tables = {}
        if table_id not in tables:
            tables = {table_id: db.databackend.conn.table(table_id)}
        result = tables[table_id]
        for member in self.members:
            result, tables = member.compile(parent=result, db=db, tables=tables)
        return result, tables

    def execute(self, db):
        native_query, _ = self.compile(db)
        try:
            result = native_query.execute()
        except Exception as exc:
            raise IbisBackendError(
                f'{native_query} Wrong query or not supported yet :: {exc}'
            )
        return result


class QueryType(str, enum.Enum):