Skip to content

Commit 0d9444a

Browse files
committed
MLE-25002 Another order-by test
1 parent f54af46 commit 0d9444a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

flux-cli/src/test/java/com/marklogic/flux/impl/importdata/ImportJdbcWithAggregatesTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,39 @@ void customerWithArrayOfRentalsAndArrayOfPayments() {
109109
assertEquals(4020, rentals.get(1).get("inventory_id").asInt());
110110
}
111111

112+
/**
113+
* Attempts to reproduce the query in MLE-25002 by using select statements for the "from" and "inner join".
114+
*/
115+
@Test
116+
void orderByWithFromAndInnerJoinsThatUseSelects() {
117+
String query = """
118+
select
119+
c.customer_id, c.first_name,
120+
p.payment_id, p.amount
121+
from (select * from customer c where c.customer_id = 1) as c
122+
inner join (select * from payment where payment_id < 19000) p on c.customer_id = p.customer_id
123+
order by p.amount desc
124+
""";
125+
126+
run(
127+
"import-jdbc",
128+
"--jdbc-url", PostgresUtil.URL_WITH_AUTH, "--jdbc-driver", PostgresUtil.DRIVER,
129+
"--query", query,
130+
"--group-by", "customer_id",
131+
"--aggregate", "payments=payment_id,amount",
132+
"--connection-string", makeConnectionString(),
133+
"--permissions", DEFAULT_PERMISSIONS,
134+
"--uri-template", "/customer/{customer_id}.json"
135+
);
136+
137+
JsonNode doc = readJsonDocument("/customer/1.json");
138+
139+
ArrayNode payments = (ArrayNode) doc.get("payments");
140+
assertEquals(7, payments.size(), "The query should have selected 7 related payments.");
141+
assertEquals(0.99, payments.get(6).get("amount").asDouble());
142+
assertEquals(9.99, payments.get(0).get("amount").asDouble());
143+
}
144+
112145
/**
113146
* Demonstrates that a join can produce an array with atomic/simple values, instead of structs / objects.
114147
*/

0 commit comments

Comments
 (0)