Skip to content

Commit

Permalink
fixing default values
Browse files Browse the repository at this point in the history
  • Loading branch information
ilongin committed Dec 20, 2024
1 parent 8fa9465 commit d1c5109
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/datachain/lib/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,22 @@ def _to_list(obj: Union[str, Sequence[str]]) -> list[str]:
*[C(f"{_rprefix(c, rc)}{c}") == None for c, rc in zip(on, right_on)] # noqa: E711
)
)

def _default_val(chain: "DataChain", col: str):
col_type = chain._query.column_types[col] # type: ignore[index]
val = sa.literal(col_type.default_value(dialect)).label(col)
val.type = col_type()
return val

right_left_merge_select = right_left_merge._query.select(
*(
[C(c) for c in right_left_merge.signals_schema.db_signals("sys")]
+ [
C(c) # type: ignore[misc]
if c == rc
else sa.literal(
left._query.column_types[c].default_value(dialect) # type: ignore[index]
).label(c)
C(c) if c == rc else _default_val(left, c)
for c, rc in zip(on, right_on)
]
+ [
C(c) # type: ignore[misc]
if c in right_cols
else sa.literal(
left._query.column_types[c].default_value(dialect) # type: ignore[index]
).label(c) # type: ignore[arg-type]
C(c) if c in right_cols else _default_val(left, c) # type: ignore[arg-type]
for c in cols
if c not in on
]
Expand Down

0 comments on commit d1c5109

Please sign in to comment.