Skip to content

Commit 7b2f8f2

Browse files
authored
Adds type hints with TablesCrawler for the table crawlers where required #2819 (#2819)
\## Changes Adds type hints with `TablesCrawler` for the table crawlers where required #2819 FasterTableCrawler now extends TablesCrawler ### Linked issues (https://github.com/databrickslabs/ucx/pull/2813/files#r1786418356)
1 parent 0ffd50f commit 7b2f8f2

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/databricks/labs/ucx/contexts/workflow_task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ def global_init_scripts_crawler(self) -> GlobalInitScriptCrawler:
8484
return GlobalInitScriptCrawler(self.workspace_client, self.sql_backend, self.inventory_database)
8585

8686
@cached_property
87-
def tables_crawler(self):
88-
# TODO: Update tables crawler inheritance to specify return type hint
87+
def tables_crawler(self) -> FasterTableScanCrawler:
8988
return FasterTableScanCrawler(self.sql_backend, self.inventory_database, self.config.include_databases)
9089

9190
@cached_property

src/databricks/labs/ucx/hive_metastore/grants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
)
3333
from databricks.labs.ucx.framework.crawlers import CrawlerBase
3434
from databricks.labs.ucx.framework.utils import escape_sql_identifier
35+
from databricks.labs.ucx.hive_metastore import TablesCrawler
3536
from databricks.labs.ucx.hive_metastore.locations import (
3637
ExternalLocations,
3738
Mount,
3839
Mounts,
3940
)
4041
from databricks.labs.ucx.hive_metastore.mapping import TableToMigrate, Rule
4142
from databricks.labs.ucx.hive_metastore.table_migration_status import TableMigrationStatusRefresher
42-
from databricks.labs.ucx.hive_metastore.tables import Table, TablesCrawler
43+
from databricks.labs.ucx.hive_metastore.tables import Table
4344
from databricks.labs.ucx.hive_metastore.udfs import UdfsCrawler
4445
from databricks.labs.ucx.workspace_access.groups import GroupManager
4546

src/databricks/labs/ucx/hive_metastore/table_migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from databricks.labs.ucx.framework.utils import escape_sql_identifier
1010
from databricks.sdk import WorkspaceClient
1111

12-
from databricks.labs.ucx.hive_metastore import TablesCrawler, Mounts
12+
from databricks.labs.ucx.hive_metastore import Mounts, TablesCrawler
1313
from databricks.labs.ucx.hive_metastore.grants import MigrateGrants
1414
from databricks.labs.ucx.hive_metastore.locations import Mount, ExternalLocations
1515
from databricks.labs.ucx.hive_metastore.mapping import (

src/databricks/labs/ucx/hive_metastore/tables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def _describe(self, catalog: str, database: str, table: str) -> Table | None:
486486
return None
487487

488488

489-
class FasterTableScanCrawler(CrawlerBase[Table]):
489+
class FasterTableScanCrawler(TablesCrawler):
490490
"""
491491
FasterTableScanCrawler is a specialized version of TablesCrawler that uses spark._jsparkSession to utilize
492492
faster scanning with Scala APIs.
@@ -503,7 +503,7 @@ def __init__(self, backend: SqlBackend, schema, include_databases: list[str] | N
503503
# pylint: disable-next=import-error,import-outside-toplevel
504504
from pyspark.sql.session import SparkSession # type: ignore[import-not-found]
505505

506-
super().__init__(backend, "hive_metastore", schema, "tables", Table)
506+
super().__init__(backend, schema, include_databases)
507507
self._spark = SparkSession.builder.getOrCreate()
508508

509509
@cached_property

0 commit comments

Comments
 (0)