Search in sources :

Example 1 with PinotClient

use of io.trino.plugin.pinot.client.PinotClient in project trino by trinodb.

the class TestBrokerQueries method testBrokerResponseHasTooManyRows.

@Test
public void testBrokerResponseHasTooManyRows() throws IOException {
    List<Object[]> tooManyRowsTestData = ImmutableList.<Object[]>builder().add(new Object[] { "col_1_row1", 1L, "col_3_row1" }).add(new Object[] { "col_1_row2", 2L, "col_3_data" }).add(new Object[] { "col_1_row3", 3L, "col_3_data" }).build();
    ResultTable tooManyRowsResultTable = new ResultTable(DATA_SCHEMA, tooManyRowsTestData);
    BrokerResponseNative tooManyRowsResponse = new BrokerResponseNative();
    tooManyRowsResponse.setResultTable(tooManyRowsResultTable);
    tooManyRowsResponse.setNumServersQueried(1);
    tooManyRowsResponse.setNumServersResponded(1);
    tooManyRowsResponse.setNumDocsScanned(3);
    PinotClient testingPinotClient = new MockPinotClient(pinotConfig, getTestingMetadata(), tooManyRowsResponse.toJsonString());
    List<PinotColumnHandle> columnHandles = ImmutableList.<PinotColumnHandle>builder().add(new PinotColumnHandle("col_1", VARCHAR)).add(new PinotColumnHandle("col_2", BIGINT)).add(new PinotColumnHandle("col_3", VARCHAR)).build();
    PinotBrokerPageSource pageSource = new PinotBrokerPageSource(createSessionWithNumSplits(1, false, pinotConfig), new PinotQueryInfo("test_table", "SELECT col_1, col_2, col_3 FROM test_table", 0), columnHandles, testingPinotClient, LIMIT_FOR_BROKER_QUERIES);
    assertThatExceptionOfType(PinotException.class).isThrownBy(() -> pageSource.getNextPage()).withMessage("Broker query returned '3' rows, maximum allowed is '2' rows. with query \"SELECT col_1, col_2, col_3 FROM test_table\"");
}
Also used : PinotQueryInfo(io.trino.plugin.pinot.query.PinotQueryInfo) PinotClient.fromResultTable(io.trino.plugin.pinot.client.PinotClient.fromResultTable) ResultTable(org.apache.pinot.common.response.broker.ResultTable) BrokerResponseNative(org.apache.pinot.common.response.broker.BrokerResponseNative) PinotClient(io.trino.plugin.pinot.client.PinotClient) Test(org.testng.annotations.Test)

Example 2 with PinotClient

use of io.trino.plugin.pinot.client.PinotClient in project trino by trinodb.

the class TestPinotClient method testBrokersParsed.

@Test
public void testBrokersParsed() {
    HttpClient httpClient = new TestingHttpClient(request -> TestingResponse.mockResponse(HttpStatus.OK, MediaType.JSON_UTF_8, "{\n" + "  \"tableName\": \"dummy\",\n" + "  \"brokers\": [\n" + "    {\n" + "      \"tableType\": \"offline\",\n" + "      \"instances\": [\n" + "        \"Broker_dummy-broker-host1-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host2-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host4-datacenter1_6513\"\n" + "      ]\n" + "    },\n" + "    {\n" + "      \"tableType\": \"realtime\",\n" + "      \"instances\": [\n" + "        \"Broker_dummy-broker-host1-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host2-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host3-datacenter1_6513\"\n" + "      ]\n" + "    }\n" + "  ],\n" + "  \"server\": [\n" + "    {\n" + "      \"tableType\": \"offline\",\n" + "      \"instances\": [\n" + "        \"Server_dummy-server-host8-datacenter1_7090\",\n" + "        \"Server_dummy-server-host9-datacenter1_7090\"\n" + "      ]\n" + "    },\n" + "    {\n" + "      \"tableType\": \"realtime\",\n" + "      \"instances\": [\n" + "        \"Server_dummy-server-host7-datacenter1_7090\",\n" + "        \"Server_dummy-server-host4-datacenter1_7090\",\n" + "        \"Server_dummy-server-host5-datacenter1_7090\",\n" + "        \"Server_dummy-server-host6-datacenter1_7090\"\n" + "      ]\n" + "    }\n" + "  ]\n" + "}"));
    PinotConfig pinotConfig = new PinotConfig().setMetadataCacheExpiry(new Duration(0, TimeUnit.MILLISECONDS)).setControllerUrls("localhost:7900");
    PinotClient pinotClient = new PinotClient(pinotConfig, new IdentityPinotHostMapper(), httpClient, MetadataUtil.TABLES_JSON_CODEC, MetadataUtil.BROKERS_FOR_TABLE_JSON_CODEC, MetadataUtil.TIME_BOUNDARY_JSON_CODEC, MetadataUtil.BROKER_RESPONSE_NATIVE_JSON_CODEC, PinotControllerAuthenticationProvider.create(PinotEmptyAuthenticationProvider.instance()), PinotBrokerAuthenticationProvider.create(PinotEmptyAuthenticationProvider.instance()));
    ImmutableSet<String> brokers = ImmutableSet.copyOf(pinotClient.getAllBrokersForTable("dummy"));
    Assert.assertEquals(ImmutableSet.of("dummy-broker-host1-datacenter1:6513", "dummy-broker-host2-datacenter1:6513", "dummy-broker-host3-datacenter1:6513", "dummy-broker-host4-datacenter1:6513"), brokers);
}
Also used : IdentityPinotHostMapper(io.trino.plugin.pinot.client.IdentityPinotHostMapper) HttpClient(io.airlift.http.client.HttpClient) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) PinotClient(io.trino.plugin.pinot.client.PinotClient) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Aggregations

PinotClient (io.trino.plugin.pinot.client.PinotClient)2 Test (org.testng.annotations.Test)2 HttpClient (io.airlift.http.client.HttpClient)1 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)1 Duration (io.airlift.units.Duration)1 IdentityPinotHostMapper (io.trino.plugin.pinot.client.IdentityPinotHostMapper)1 PinotClient.fromResultTable (io.trino.plugin.pinot.client.PinotClient.fromResultTable)1 PinotQueryInfo (io.trino.plugin.pinot.query.PinotQueryInfo)1 BrokerResponseNative (org.apache.pinot.common.response.broker.BrokerResponseNative)1 ResultTable (org.apache.pinot.common.response.broker.ResultTable)1