-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
sql/sem/tree: support parsing of tuples from string literals #71916
Conversation
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.
looks good!
out of pure curiousity, did you copy postgres' parsing logic or is this rafi proprietary code? if the former it might be worth putting a code link in there
Datums{NewDTuple(tupleOfStringAndInt, NewDString("a12'"), NewDInt(4))}, | ||
}, | ||
{ | ||
`{"(cat,4)", "(null,0)"}`, |
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.
would be good to test non-int/text types, e.g. timestamptz
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.
will do. i need to iron out some of the random test issues too
return nil, false, malformedRecordError | ||
} | ||
if parser.tupleIdx < len(parser.t.TupleContents()) { | ||
return nil, false, errors.WithDetail(malformedRecordError, "Too few columns.") |
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.
nit: errors should not have periods and start with lower case
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.
this is the error detail though. i think we do use full sentences for that?
err = errors.WithDetail(err, `The prefix "pg_" is reserved for system schemas.`) |
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.
can we be more detailed (i.e. print out expected types)?
should we do that for the too many columns case?
541b870
to
5c20242
Compare
This is ready for a full review. I ran with |
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.
lgtm, one optional comment and you have some test cases to change
return nil, false, malformedRecordError | ||
} | ||
if parser.tupleIdx < len(parser.t.TupleContents()) { | ||
return nil, false, errors.WithDetail(malformedRecordError, "Too few columns.") |
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.
can we be more detailed (i.e. print out expected types)?
should we do that for the too many columns case?
the |
5c20242
to
8ece1b5
Compare
Release note (sql change): String literals can now be parsed as tuples, either in a cast expression, or in other contexts like function arguments.
Release note (bug fix): Previously, when records and enums containing escape sequences were shown in the CLI, they would be incorrectly double-escaped. This is now fixed.
8ece1b5
to
a48d5ab
Compare
bors r=otan |
Build failed: |
bors r=otan |
Build succeeded: |
fixes #70030
fixes #63995
Release note (sql change): String literals can now be parsed as tuples,
either in a cast expression, or in other contexts like function
arguments.
Release note (bug fix): Previously, when records and enums containing
escape sequences were shown in the CLI, they would be incorrectly
double-escaped. This is now fixed.