-
Notifications
You must be signed in to change notification settings - Fork 249
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
impr(quaint/qe): PostgreSQL DISTINCT ON
#4223
Conversation
DISTINCT ON
DISTINCT ON
CodSpeed Performance ReportMerging #4223 will not alter performanceComparing Summary
|
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
@Druue any progress on this PR? Would be very beneficial for performance on |
04a77e2
to
5104698
Compare
DISTINCT ON
DISTINCT ON
5104698
to
105e979
Compare
queries::distinct::distinct::with_duplicates
Add capability for db distinct in: - read_many - m2m - one2m
105e979
to
611cc4e
Compare
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.
Good first step. Some things could be improved. Also, it looks like a lot of tests are failing atm.
query-engine/core/src/interpreter/query_interpreters/inmemory_record_processor.rs
Outdated
Show resolved
Hide resolved
query-engine/core/src/interpreter/query_interpreters/inmemory_record_processor.rs
Outdated
Show resolved
Hide resolved
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
using builder
DISTINCT ON
DISTINCT ON
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
- track current in-mem snapshots - track in-db pg snapshots
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/distinct.rs
Outdated
Show resolved
Hide resolved
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.
Let's revisit the tests in the next bits of work, LGTM for now, nice job 👍
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 👍
#[connector_test(only(Postgres))] | ||
async fn no_panic_pg(runner: Runner) -> TestResult<()> { | ||
test_user(&runner, r#"{ id: 1, first_name: "Joe", last_name: "Doe", email: "1" }"#).await?; | ||
test_user(&runner, r#"{ id: 2, first_name: "Doe", last_name: "Joe", email: "2" }"#).await?; | ||
|
||
assert_query!( | ||
runner, | ||
"query { findManyUser(distinct: [first_name, last_name]) { id } }", | ||
r#"{"data":{"findManyUser":[{"id":1},{"id":2}]}}"# | ||
insta::assert_snapshot!( | ||
run_query!( | ||
&runner, | ||
indoc!("{ | ||
findManyUser(distinct: [first_name, last_name]) | ||
{ id } | ||
}") | ||
), | ||
@r###"{"data":{"findManyUser":[{"id":2},{"id":1}]}}"### | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Regression test for not selecting the fields the distinct is performed on: https://github.com/prisma/prisma/issues/5969 | ||
#[connector_test(exclude(Postgres))] | ||
async fn no_panic_other(runner: Runner) -> TestResult<()> { | ||
test_user(&runner, r#"{ id: 1, first_name: "Joe", last_name: "Doe", email: "1" }"#).await?; | ||
test_user(&runner, r#"{ id: 2, first_name: "Doe", last_name: "Joe", email: "2" }"#).await?; | ||
|
||
insta::assert_snapshot!( | ||
run_query!( | ||
&runner, | ||
indoc!("{ | ||
findManyUser(distinct: [first_name, last_name]) | ||
{ id } | ||
}") | ||
), | ||
@r###"{"data":{"findManyUser":[{"id":1},{"id":2}]}}"### | ||
); |
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 not differentiate the snapshots by "connector" here and avoid the duplication?
This PR is looking to introduce the structure for further in-db
distinct
work and the base case for PostgreSQL'sdistinct on
DISTINCT ON
DISTINCT ON
api from quaint// Add support for more granularly opting in to db-level
distinct
per query args// in-memory-builder was removed
Follow-up steps involve
orderBy
supportorderBy
supportcontributes prisma/prisma#14765
closes https://github.com/prisma/team-orm/issues/774
relevant discovery work