Skip to content

Commit c8dcad6

Browse files
committed
fix: duckdb column names with spaces
1 parent deee14c commit c8dcad6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

narwhals/_duckdb/dataframe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,24 +243,24 @@ def join(
243243
assert right_on is not None # noqa: S101
244244

245245
conditions = [
246-
f"lhs.{left} = rhs.{right}" for left, right in zip(left_on, right_on)
246+
f'lhs."{left}" = rhs."{right}"' for left, right in zip(left_on, right_on)
247247
]
248248
condition = " and ".join(conditions)
249249
rel = self._native_frame.set_alias("lhs").join(
250250
other._native_frame.set_alias("rhs"), condition=condition, how=how
251251
)
252252

253253
if how in ("inner", "left", "cross"):
254-
select = [f"lhs.{x}" for x in self._native_frame.columns]
254+
select = [f'lhs."{x}"' for x in self._native_frame.columns]
255255
for col in other._native_frame.columns:
256256
if col in self._native_frame.columns and (
257257
right_on is None or col not in right_on
258258
):
259-
select.append(f"rhs.{col} as {col}{suffix}")
259+
select.append(f'rhs."{col}" as "{col}{suffix}"')
260260
elif right_on is None or col not in right_on:
261261
select.append(col)
262262
else: # semi
263-
select = [f"lhs.{x}" for x in self._native_frame.columns]
263+
select = ["lhs.*"]
264264

265265
res = rel.select(", ".join(select)).set_alias(original_alias)
266266
return self._from_native_frame(res)

0 commit comments

Comments
 (0)