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
dolt table import requires an empty column for AUTO_INCREMENT columns #5848
Comments
It seems like
The docs for
Seems like we should make two changes:
|
This appears to be a case of overzealous checks. import.go::newImportSqlEngineMover has a check that every PK exists in the csv and errors if it doesn't. Removing that check prints a warning further down the line:
But all rows get successfully added. We probably want to fix this check to skip auto incrementing rows. What's curious is why the workaround from #5855 worked, if this check exists. It turns out, our SQL engine appears to consider a result table column to not be a primary key if it has a default value! |
You can correct me if I'm wrong, but here's how I interpret the CSV import logic: "make sure that the CSV has all the necessary primary key columns, except if it has a default value for one of those columns. In that case, replace the column with the default value." This is equivalent to saying "if it has a default value, consider this column to not be a primary key, for the purpose of this initial check." Which seems reasonable to me. However I still think that the "correct" way to import a CSV is to check that the inserted row has all of its primary key values upon inserting, and not upon reading. Whether this can be done efficiently I don't really know. |
There's definitely a bug on our end where tables with default values have an incorrect schema. I filed it as dolthub/go-mysql-server#1753 I agree with your reasoning here though: we perform this check as soon as the CSV is read, but it's overbroad and we should instead be running checks like this when we're actually performing the inserts... and we are. This check appears to be redundant, in order to fail early and return a more helpful error message. But it's not helpful if it's wrong. I could relax the check, but I don't think we're going to be able to fix #5855 unless we remove it entirely. So that's what I'm going to do. |
Should be fixed as of #5881 |
This works.
This also works.
However this does not work:
bodegas.csv
To restate the point more concisely, you can do
insert into bodegas (bodega_name) values ('The Bodega of Cats')
without drawing a foul, but you can't insert the same datafrom a CSV.
You should be allowed to insert files via CSV without providing the
bodega_id
column.The text was updated successfully, but these errors were encountered: