Skip to content

feat: Support replacing existing table relations#430

Open
Zirak wants to merge 1 commit intoduckdb:mainfrom
Zirak:create-replace-flag
Open

feat: Support replacing existing table relations#430
Zirak wants to merge 1 commit intoduckdb:mainfrom
Zirak:create-replace-flag

Conversation

@Zirak
Copy link
Copy Markdown

@Zirak Zirak commented Apr 20, 2026

relation.create_view supports a replace flag, which is equivalent to

CREATE OR REPLACE VIEW

However, there was nothing for the relation.create, despite the underlying duckdb binding supporting it. This commit threads the flag through.

Note that we've got a confusing case of similar functions, different default values:

def create     (self, table_name: str, replace: bool = False)
def create_view(self, view_name: str, replace: bool = True)

While create_view defaults to replace=True, the regular create does not replace by default. This is done mostly for backwards compatibility.

`relation.create_view` supports a `replace` flag, which is equivalent to

```
CREATE OR REPLACE VIEW
```

However, there was nothing for the `relation.create`, despite the
underlying duckdb binding supporting it. This commit threads the flag
through.

Note that we've got a confusing case of similar functions, different
default values:

```
def create     (self, table_name: str, replace: bool = False)
def create_view(self, view_name: str, replace: bool = True)
```

While `create_view` defaults to `replace=True`, the regular `create`
does not `replace` by default. This is done mostly for backwards
compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant