github-actions[bot] commented on code in PR #60779:
URL: https://github.com/apache/doris/pull/60779#discussion_r2968340781
##########
extension/dbt-doris/dbt/adapters/doris/impl.py:
##########
@@ -139,56 +131,14 @@ def list_relations_without_caching(self, schema_relation:
DorisRelation) -> List
return relations
- def get_catalog(self, manifest):
- schema_map = self._get_catalog_schemas(manifest)
-
- with executor(self.config) as tpe:
- futures: List[Future[agate.Table]] = []
- for info, schemas in schema_map.items():
- for schema in schemas:
- futures.append(
- tpe.submit_connected(
- self,
- schema,
- self._get_one_catalog,
- info,
- [schema],
- manifest,
- )
- )
- catalogs, exceptions = catch_as_completed(futures)
- return catalogs, exceptions
-
- @classmethod
- def _catalog_filter_schemas(cls, manifest: Manifest) ->
Callable[[agate.Row], bool]:
- schemas = frozenset((None, s.lower()) for d, s in
manifest.get_used_schemas())
-
- def _(row: agate.Row) -> bool:
- table_database = _expect_row_value("table_database", row)
- table_schema = _expect_row_value("table_schema", row)
- if table_schema is None:
- return False
- return (table_database, table_schema.lower()) in schemas
-
- return _
-
- @classmethod
- def _catalog_filter_table(cls, table: agate.Table, manifest: Manifest) ->
agate.Table:
- table = table_from_rows(
- table.rows,
- table.column_names,
- text_only_columns=["table_schema", "table_name"],
- )
- return table.where(cls._catalog_filter_schemas(manifest))
-
def _get_one_catalog(
self,
information_schema: InformationSchema,
schemas: Set[str],
manifest: Manifest,
) -> agate.Table:
Review Comment:
**CRITICAL: Signature mismatch with base class.**
The base `BaseAdapter._get_one_catalog` signature (in `dbt-adapters`) is:
```python
def _get_one_catalog(
self,
information_schema: InformationSchema,
schemas: Set[str],
used_schemas: FrozenSet[Tuple[str, str]],
) -> "agate.Table":
```
But this override uses `manifest: Manifest` as the third parameter. Since
the custom `get_catalog` was removed, the base `get_catalog` will now be
called, which passes `used_schemas` (a `FrozenSet[Tuple[str, str]]`) as the
third argument. This will fail at runtime because this override expects a
`Manifest` object.
**Fix**: Update the signature to match the base class:
```python
def _get_one_catalog(
self,
information_schema: InformationSchema,
schemas: Set[str],
used_schemas: FrozenSet[Tuple[str, str]],
) -> agate.Table:
if len(schemas) != 1:
raise CompilationError(
f"Expected only one schema in Doris _get_one_catalog, found
{schemas}"
)
return super()._get_one_catalog(information_schema, schemas,
used_schemas)
```
Also:
- Add `FrozenSet` to the typing imports
- Remove the now-unused `from dbt.contracts.graph.manifest import Manifest`
import
##########
extension/dbt-doris/dbt/adapters/doris/impl.py:
##########
@@ -20,37 +20,29 @@
from dbt.adapters.sql import SQLAdapter
-from concurrent.futures import Future
from enum import Enum
from typing import (
Any,
- Callable,
Dict,
- Iterable,
- Iterator,
List,
- Mapping,
Optional,
Set,
- Tuple,
- Type,
- Union,
+ Tuple
)
import agate
import dbt.exceptions
-from dbt.adapters.base.impl import _expect_row_value, catch_as_completed
from dbt.adapters.base.relation import InformationSchema, BaseRelation
from dbt.adapters.doris.column import DorisColumn
from dbt.adapters.doris.connections import DorisConnectionManager
from dbt.adapters.doris.relation import DorisRelation
from dbt.adapters.protocol import AdapterConfig
from dbt.adapters.sql.impl import LIST_RELATIONS_MACRO_NAME,
LIST_SCHEMAS_MACRO_NAME
-from dbt_common.clients.agate_helper import table_from_rows
from dbt.contracts.graph.manifest import Manifest
from dbt.adapters.contracts.relation import RelationType
Review Comment:
**Minor**: Since `_get_one_catalog` signature should be updated to use
`used_schemas: FrozenSet[Tuple[str, str]]` instead of `manifest: Manifest`,
this import will become unused and should be removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]