fix: RLS in virtual datasets (#36061)

This commit is contained in:
Beto Dealmeida
2025-11-14 14:21:09 -05:00
committed by GitHub
parent 9ef87e75d5
commit f3e620cd0f
8 changed files with 280 additions and 23 deletions

View File

@@ -168,14 +168,7 @@ class RLSTransformer:
table_node.catalog if table_node.catalog else self.catalog,
)
if predicates := self.rules.get(table):
return (
exp.And(
this=predicates[0],
expressions=predicates[1:],
)
if len(predicates) > 1
else predicates[0]
)
return sqlglot.and_(*predicates)
return None
@@ -312,6 +305,21 @@ class Table:
def __eq__(self, other: Any) -> bool:
return str(self) == str(other)
def qualify(
self,
*,
catalog: str | None = None,
schema: str | None = None,
) -> Table:
"""
Return a new Table with the given schema and/or catalog, if not already set.
"""
return Table(
table=self.table,
schema=self.schema or schema,
catalog=self.catalog or catalog,
)
# To avoid unnecessary parsing/formatting of queries, the statement has the concept of
# an "internal representation", which is the AST of the SQL statement. For most of the