1
0
Fork 0

Merging upstream version 16.4.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 20:15:27 +01:00
parent 2426bb8908
commit 2e72f978c2
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
79 changed files with 72289 additions and 29264 deletions

View file

@ -1528,6 +1528,7 @@ class Insert(Expression):
"exists": False,
"partition": False,
"alternative": False,
"where": False,
}
def with_(
@ -5704,11 +5705,12 @@ def column_table_names(expression: Expression, exclude: str = "") -> t.Set[str]:
}
def table_name(table: Table | str) -> str:
def table_name(table: Table | str, dialect: DialectType = None) -> str:
"""Get the full name of a table as a string.
Args:
table: table expression node or string.
table: Table expression node or string.
dialect: The dialect to generate the table name for.
Examples:
>>> from sqlglot import exp, parse_one
@ -5724,7 +5726,10 @@ def table_name(table: Table | str) -> str:
if not table:
raise ValueError(f"Cannot parse {table}")
return ".".join(part for part in (table.text("catalog"), table.text("db"), table.name) if part)
return ".".join(
part.sql(dialect=dialect) if not SAFE_IDENTIFIER_RE.match(part.name) else part.name
for part in table.parts
)
def replace_tables(expression: E, mapping: t.Dict[str, str], copy: bool = True) -> E: