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

importer: support {} format for arrays in CSV #85850

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Aug 9, 2022

fixes #84631

Release note (sql change): Arrays can now be imported in a CSV file
using the {} format, similar to COPY FROM. Importing array expressions
(e.g. ARRAY[1, 2, 3]) is still supported as well.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss force-pushed the fix-import-csv-array branch 2 times, most recently from 374e1aa to da24c69 Compare August 10, 2022 17:24
@rafiss rafiss requested review from ecwall and a team August 10, 2022 17:25
@rafiss rafiss marked this pull request as ready for review August 10, 2022 17:25
@rafiss rafiss requested review from a team and msbutler August 10, 2022 17:25
Release note (sql change): Arrays can now be imported in a CSV file
using the {} format, similar to COPY FROM. Importing array expressions
(e.g. ARRAY[1, 2, 3]) is still supported as well.
// both array expressions (like `ARRAY[1, 2, 3]`) and literals (like
// `{1, 2, 3}`).
var err2 error
conv.Datums[datumIdx], _, err2 = tree.ParseAndRequireString(conv.VisibleColTypes[i], field.Val, conv.EvalCtx)
Copy link
Contributor

Choose a reason for hiding this comment

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

It is probably outside the scope of this change, but is there a grammar that a parser can be generated from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you mean to avoid the fallback logic? it won't be that easy -- the difference between these two formats is that one is an expression (e.g. ARRAY[1, 2, 3 ...]) but the other is the format that arrays represented as string literals use (e.g. in {1, 2, 3 ... }::INT[]). The string literal format isn't (and i think shouldn't) be represented in our sql.y file, but it's handled in pkg/sql/sem/tree/parse_array.go

@rafiss
Copy link
Collaborator Author

rafiss commented Aug 12, 2022

tftr!

bors r=ecwall

@craig craig bot merged commit ff3fc7e into cockroachdb:master Aug 12, 2022
@craig
Copy link
Contributor

craig bot commented Aug 12, 2022

Build succeeded:

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.

CockroachDB Serverless: IMPORT INTO using CSV with array-column fails with syntax error
3 participants