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

CSV IMPORT fails for columns with enum type and default value #85903

Closed
dejan-lokar opened this issue Aug 10, 2022 · 3 comments
Closed

CSV IMPORT fails for columns with enum type and default value #85903

dejan-lokar opened this issue Aug 10, 2022 · 3 comments
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner

Comments

@dejan-lokar
Copy link

dejan-lokar commented Aug 10, 2022

Describe the problem

IMPORT INTO statement fails when importing CSV data into a table with an enum column type that has a default value.

To Reproduce

  1. setup schema and a test row
CREATE TYPE IF NOT EXISTS teststate AS ENUM ('ENABLED', 'DISABLED');

CREATE TABLE table1
(
    id STRING NOT NULL,
    state teststate NOT NULL DEFAULT 'DISABLED' -- does not work
    -- state teststate NOT NULL -- works
);

INSERT INTO test1 (id, state) VALUES
    ('id1', 'ENABLED');
  1. export table data into CSV
EXPORT INTO CSV 's3://bucket1' FROM TABLE db1.table1
  1. import CSV
IMPORT INTO db1.table1 CSV DATA ('s3://bucket1/FILENAME')

Step #3 fails with the following error:
pq: s3://test-bucket/export170a08f5d51fbaf10000000000000001-n786690423440965633.0.csv?AWS_ACCESS_KEY_ID=****&AWS_ENDPOINT=****&AWS_REGION=us-east-2&AWS_SECRET_ACCESS_KEY=****: process default and computed columns: type OID 100112 does not exist

Environment:

  • CockroachDB version 21.1.9

Jira issue: CRDB-18484

@dejan-lokar dejan-lokar added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Aug 10, 2022
@blathers-crl
Copy link

blathers-crl bot commented Aug 10, 2022

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

  • @cockroachdb/sql-experience (found keywords: IMPORT)
  • @cockroachdb/bulk-io (found keywords: export)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added A-disaster-recovery O-community Originated from the community X-blathers-triaged blathers was able to find an owner T-disaster-recovery labels Aug 10, 2022
@blathers-crl
Copy link

blathers-crl bot commented Aug 10, 2022

cc @cockroachdb/bulk-io

@msbutler msbutler added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Aug 10, 2022
@ZhouXing19
Copy link
Collaborator

This has been fixed by 5608424 from v22.1.0 and forward. The test can be found here:

// Test CSV default and computed column imports.
{
create: `
a greeting, b greeting default 'hi', c greeting
AS (
CASE a
WHEN 'hello' THEN 'hi'
WHEN 'hi' THEN 'hello'
END
) STORED`,
intoCols: "a",
typ: "CSV",
contents: "hello\nhi\n",
verifyQuery: "SELECT * FROM t ORDER BY a",
expected: [][]string{{"hello", "hi", "hi"}, {"hi", "hi", "hello"}},
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

No branches or pull requests

4 participants