-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
374e1aa
to
da24c69
Compare
da24c69
to
79f5ae5
Compare
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.
79f5ae5
to
bad5944
Compare
// 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
tftr! bors r=ecwall |
Build succeeded: |
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.