-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Implement schemas.list
RPC method
#3598
Conversation
Note this is stacked on top of #3597 |
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.
Tests look great, overall organization is also nice.
I have some changes to request for the SQL code itself; see my specific line comments.
db/sql/0_msar.sql
Outdated
min(s.nspname) AS name, | ||
min(d.description) AS description, |
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.
I'd prefer either adding these to the GROUP BY
, or just using the any_value
aggregate here. I find the min
call a bit misleading. My personal preference is adding these columns to the GROUP BY
since it makes it clear(er) that you're getting a single row per oid, name, description
tuple.
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.
Fixed in d85df60
I originally wanted to use any_value
but (to my surprise) this function was only just recently added in PostgreSQL 16.
I'm accustomed to the behavior in MySQL which basically automatically applies any_value
any time you don't explicitly use an aggregate function.
It's helpful to know what sort of patterns you prefer to use for cases like this. Thanks. I'll try to use additional grouping columns going forward.
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.
I originally wanted to use
any_value
but (to my surprise) this function was only just recently added in PostgreSQL 16.
Innnteresting. I could swear there was something like that before, but maybe I dreamt it.
db/sql/0_msar.sql
Outdated
min(s.nspname) AS name, | ||
min(d.description) AS description, |
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.
Are you aware of the obj_description
function? It's specific to PostgreSQL (I think), but it would simplify things by avoiding one of the joins below.
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.
Fixed in 38d8cee.
I did notice that function. But I chose to use the join because my instinct was that it would be more performant. I suppose performance isn't critical here anyway because we're not likely to be returning thousands of schemas. And perhaps Postgres needs to do similar things under the hood when using obj_description
vs when querying system catalog tables. But basically in the general sense I just wouldn't be inclined to use lookup functions in the SELECT
clause when we could use a JOIN
to get the same data. Since you seem to prefer the lookup function at least in this case I've changed it here for clarity/simplicity.
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.
I suspect you're correct that the join would be more performant, but I note that the psql
command \d
uses the obj_description
, so it's probably not that bad.
Ready for re-review, @mathemancer |
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.
I have one tiny change to request. If you're okay with that, feel free to merge after namespacing the obj_description
function.
db/sql/0_msar.sql
Outdated
min(s.nspname) AS name, | ||
min(d.description) AS description, |
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.
I suspect you're correct that the join would be more performant, but I note that the psql
command \d
uses the obj_description
, so it's probably not that bad.
db/sql/0_msar.sql
Outdated
SELECT | ||
s.oid AS oid, | ||
s.nspname AS name, | ||
obj_description(s.oid) AS description, |
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.
I'm sorry to go around again for such a small thing, but I think you were correct in a previous conversation (or comment; can't remember) when you noted that we should namespace these things since a (perhaps foolish) user could have created a function with the same name in some context. So, it'd be better to use pg_catalog.obj_description
.
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.
Cool. Makes sense. Fixed in f328964
@seancolsen I noticed that this PR doesn't have any python test for testing the |
@Anish9901 It didn't seem worth testing to me. Do you think it should have a test? What would you want to assert in that test? I'm open to it certainly. But also trying to avoid too much boilerplate in order to move quickly. For reference, we discussed this in our last meeting (starting at about 48:20 and my take-away from that discussion was that the test coverage that matters the most to us right now is the test coverage at the SQL layer. |
Ok, I just went through the video, as per my understanding, I don't think we agreed on not adding the python tests for the rpc endpoints rather I think we decided on not having end-to-end python tests which would call up the db and hence tend to be slow. FWIW, I think we should at least have one test for making sure that the sql function is called with appropriate parameters, this is relatively low effort. I'd like to hear @mathemancer's opinion on whether or not we want tests that check the wiring of the functions that are called from within the rpc functions. |
As I'm looking through the PR with @Anish9901 's concerns in mind:
This would be similar to, for example, the test for |
Fixes #3596
Checklist
Update index.md
).develop
branch of the repositoryDeveloper Certificate of Origin
Developer Certificate of Origin