Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move BindCreateIndex from Catalog to Binder #11402

Merged
merged 2 commits into from Apr 2, 2024

Conversation

philippmd
Copy link
Contributor

Currently BindCreateIndex is a method on the Catalog.
However, it doesn't modify or even read the catalog, instead taking a pointer to the Binder.

So I would think this is method fits better on the Binder?

Let me know what you think :)

PS: Sorry for my autoformatter re-ordering imports. I can ofc revert that.

@Tishj
Copy link
Contributor

Tishj commented Mar 28, 2024

This is a virtual method, I would assume that has a reason

	virtual unique_ptr<LogicalOperator> BindCreateIndex(Binder &binder, CreateStatement &stmt, TableCatalogEntry &table,
	                                                    unique_ptr<LogicalOperator> plan) = 0;

The behavior can be overridden by Catalog extensions, which is not possible if this is a method on the Binder

@philippmd
Copy link
Contributor Author

And I guess there is no way to figure out if such an Extension exists?

Are Binder Extensions a thing as well? In that case we could just keep the virtual.

@Mytherin
Copy link
Collaborator

Thanks for the PR! As mentioned, this method is in the catalog on purpose to facilitate pluggable indexes in catalogs. You can see in the CI runs that this change breaks several existing. extensions. For example, this is used in the Postgres extension. We recommend looking at the CI on your own fork prior to opening a PR in DuckDB.

As an alternative we could perhaps move the logic of DuckCatalog::BindCreateIndex into the Binder (e.g. Binder::BindCreateIndex) - and then call that function by DuckCatalog::BindCreateIndex. That way no extension functionality is lost.

@philippmd
Copy link
Contributor Author

We recommend looking at the CI on your own fork prior to opening a PR in DuckDB.

Thanks! Will do that in the future; I only ran make unit before.

As an alternative we could perhaps move the logic of DuckCatalog::BindCreateIndex into the Binder (e.g. Binder::BindCreateIndex) - and then call that function by DuckCatalog::BindCreateIndex. That way no extension functionality is lost.

I think that would be good yes. Apart from that I would also be happy to move the logic to from DuckCatalog to Catalog, such that it's no longer pure virtual.
This would allow other implementors of Catalog to use it as a default, without having to copy the method from DuckCatalog to their own implementation. However it seems that there is no precendence for similar methods on Catalog.

What do you think?

@github-actions github-actions bot marked this pull request as draft March 29, 2024 11:23
@Mytherin Mytherin marked this pull request as ready for review March 29, 2024 11:43
@Mytherin Mytherin merged commit acc5e79 into duckdb:main Apr 2, 2024
43 of 47 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Apr 2, 2024

The current changeset looks good to me - thanks!

github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Apr 2, 2024
Merge pull request duckdb/duckdb#11402 from philippmd/bind-create-index-on-binder
@Mytherin
Copy link
Collaborator

Mytherin commented Apr 2, 2024

Turns out this was breaking the various catalog extensions still - but this was missed because the extension API was broken for a different reason (the xz github repo being removed). Reverting for now in #11478

carlopi added a commit to carlopi/duckdb that referenced this pull request Apr 2, 2024
@Mytherin
Copy link
Collaborator

Mytherin commented Apr 3, 2024

I’ve reverted this PR because of broken CI in #11478, feel free to send a new PR that applies this change

@philippmd
Copy link
Contributor Author

Thanks and sorry for breaking things in the first place.

I'll investigate why and how they broke since I still believe that it would be nice if there was a default implementation of BindCreateIndex that Catalog extensions could use (without copying code around)

@carlopi
Copy link
Contributor

carlopi commented Apr 3, 2024

I think your PR + carlopi@ad28d1f could possibly work together, since then it will retain the dynamic dispatch, but not certain.

Also note that currently CI for building postgres and sqlite is not yet properly functional, probably it will be after #11486 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants