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

"PARTITION BY" not recognized as diff if added to existing table. #200

Open
Glupschauge opened this issue Nov 28, 2018 · 2 comments
Open
Labels

Comments

@Glupschauge
Copy link

When comparing following schemas, "PARTITION BY" is not recognized as a diff if it is added to an already existing table.

schema a:
CREATE TABLE measurement ( city_id int not null, logdate date not null, peaktemp int, unitsales int );

schema b:
CREATE TABLE measurement ( city_id int not null, logdate date not null, peaktemp int, unitsales int ) PARTITION BY RANGE (logdate);

Following commands shows no difference.
dbtoyaml schema_a -o schema_a.yaml
yamltodb schema_b schema_a.yaml

I know this is a special case, however I would be grateful if this problem could be fixed.

@jmafc jmafc added the yamltodb label Nov 28, 2018
@jmafc
Copy link
Member

jmafc commented Nov 28, 2018

This is somewhat related to the limited support of PARTITION BY RANGE (#178), but it's probably (easily) doable by adding a check when diffing tables.

@jmafc
Copy link
Member

jmafc commented Dec 7, 2018

Now that I started researching this issue, and in particular the ALTER TABLE statement, I cannot find a clause to remove a PARTITION BY specification (or for that matter, a clause to add one). So it appears that the only behavior that yamltodb could implement is:

DROP TABLE sch.measurement;
CREATE TABLE sch.measurement (...);

Is that what you want? It seems to me that this opens a whole can of worms because in a realistic production scenario, table measurement (with a PARTITION BY spec) wouldn't just exist by itself, but would have various partitions, so perhaps they would first have to be DETACHed, and then? What happens with the data in those partitions? And of course, there's the converse scenario: the table is not partitioned in the database, but the input YAML says it is.

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

No branches or pull requests

2 participants