Adding upstream version 7.1.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
291e0c125c
commit
768d386bf5
42 changed files with 1430 additions and 253 deletions
|
@ -1,4 +1,5 @@
|
|||
import itertools
|
||||
from collections import defaultdict
|
||||
from enum import Enum, auto
|
||||
|
||||
from sqlglot import exp
|
||||
|
@ -314,6 +315,16 @@ class Scope:
|
|||
self._external_columns = [c for c in self.columns if c.table not in self.selected_sources]
|
||||
return self._external_columns
|
||||
|
||||
@property
|
||||
def unqualified_columns(self):
|
||||
"""
|
||||
Unqualified columns in the current scope.
|
||||
|
||||
Returns:
|
||||
list[exp.Column]: Unqualified columns
|
||||
"""
|
||||
return [c for c in self.columns if not c.table]
|
||||
|
||||
@property
|
||||
def join_hints(self):
|
||||
"""
|
||||
|
@ -403,6 +414,21 @@ class Scope:
|
|||
yield from child_scope.traverse()
|
||||
yield self
|
||||
|
||||
def ref_count(self):
|
||||
"""
|
||||
Count the number of times each scope in this tree is referenced.
|
||||
|
||||
Returns:
|
||||
dict[int, int]: Mapping of Scope instance ID to reference count
|
||||
"""
|
||||
scope_ref_count = defaultdict(lambda: 0)
|
||||
|
||||
for scope in self.traverse():
|
||||
for _, source in scope.selected_sources.values():
|
||||
scope_ref_count[id(source)] += 1
|
||||
|
||||
return scope_ref_count
|
||||
|
||||
|
||||
def traverse_scope(expression):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue