Skip to content

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

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-import-csv-array
Aug 12, 2022
Merged

importer: support {} format for arrays in CSV#85850
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:fix-import-csv-array

Conversation

@rafiss
Copy link
Copy Markdown
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
Copy Markdown
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 a team and ecwall 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
@rafiss rafiss force-pushed the fix-import-csv-array branch from da24c69 to 79f5ae5 Compare August 10, 2022 22:05
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.
@rafiss rafiss force-pushed the fix-import-csv-array branch from 79f5ae5 to bad5944 Compare August 11, 2022 16:16
// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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