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

Exclude CockroachDB's hidden column from a catalog #351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stonewhitener
Copy link
Contributor

@stonewhitener stonewhitener commented Aug 31, 2023

CockroachDB adds a hidden column called crdb_internal_* when a hash-sharded primary key is used, that should not be directly used via the catalog.

https://www.cockroachlabs.com/docs/stable/hash-sharded-indexes#create-a-table-with-a-hash-sharded-primary-key


if (databaseType.equals(DatabaseType.COCKROACHDB)) {
// cockroachdb has a hidden column called "ROWID" that should not be directly used via the catalog
excludedColumns.add("ROWID");
Copy link
Member

@apavlo apavlo Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you just add crdb_internal_ here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the hidden columns to be excluded here must be determined using the startsWith() method, not the equals() method applied to each element of excludedColumns. excludeColumns is only used to exclude a hidden column rowid for CockroachDB.

Copy link
Contributor Author

@stonewhitener stonewhitener Sep 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, the DDL below generates a hidden column crdb_internal_ts_shard_20.

CREATE TABLE products (
    ts DECIMAL PRIMARY KEY USING HASH WITH (bucket_count = 20),
    product_id INT8
);

A suffix of a hidden column name is determined based on the primary key name and bucket size specified in the DDL. We can not exclude such columns by simply applying equals().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what if we create a list of compiled regular expressions and then have it check that instead having separate logic for equals and startsWith.

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.

2 participants