Skip to content

Commit

Permalink
Fix: remove find method from Schema (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas committed Feb 8, 2024
1 parent 9241858 commit b827626
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions sqlglot/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,6 @@ def has_column(
name = column if isinstance(column, str) else column.name
return name in self.column_names(table, dialect=dialect, normalize=normalize)

@abc.abstractmethod
def find(self, table: exp.Table, raise_on_missing: bool = True) -> t.Optional[t.Any]:
"""
Returns the schema of a given table.
Args:
table: the target table.
raise_on_missing: whether or not to raise in case the schema is not found.
Returns:
The schema of the target table.
"""

@property
@abc.abstractmethod
def supported_table_args(self) -> t.Tuple[str, ...]:
Expand Down Expand Up @@ -170,6 +157,16 @@ def table_parts(self, table: exp.Table) -> t.List[str]:
return [table.text(part) for part in exp.TABLE_PARTS if table.text(part)]

def find(self, table: exp.Table, raise_on_missing: bool = True) -> t.Optional[t.Any]:
"""
Returns the schema of a given table.
Args:
table: the target table.
raise_on_missing: whether or not to raise in case the schema is not found.
Returns:
The schema of the target table.
"""
parts = self.table_parts(table)[0 : len(self.supported_table_args)]
value, trie = in_trie(self.mapping_trie, parts)

Expand Down

0 comments on commit b827626

Please sign in to comment.