Skip to content
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

Add query history to the Preview Web UI #24875

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.TRINO_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.TRINO_AWS_REGION }}
S3_BUCKET: ${{ vars.TRINO_S3_BUCKET }}
S3_TABLES_BUCKET: ${{ vars.TRINO_S3_TABLES_BUCKET }}
GCP_CREDENTIALS_KEY: ${{ secrets.GCP_CREDENTIALS_KEY }}
GCP_STORAGE_BUCKET: ${{ vars.GCP_STORAGE_BUCKET }}
ABFS_CONTAINER: ${{ vars.AZURE_ABFS_HIERARCHICAL_CONTAINER }}
Expand Down Expand Up @@ -882,7 +883,6 @@ jobs:
- suite-7-non-generic
- suite-hive-transactional
- suite-azure
- suite-delta-lake-databricks104
- suite-delta-lake-databricks113
- suite-delta-lake-databricks122
- suite-delta-lake-databricks133
Expand Down Expand Up @@ -922,9 +922,6 @@ jobs:
ignore exclusion if: >-
${{ env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || secrets.GCP_CREDENTIALS_KEY != '' }}

- suite: suite-delta-lake-databricks104
ignore exclusion if: >-
${{ env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || secrets.DATABRICKS_TOKEN != '' }}
- suite: suite-delta-lake-databricks113
ignore exclusion if: >-
${{ env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || secrets.DATABRICKS_TOKEN != '' }}
Expand Down Expand Up @@ -989,7 +986,6 @@ jobs:
AWS_REGION: ""
TRINO_AWS_ACCESS_KEY_ID: ""
TRINO_AWS_SECRET_ACCESS_KEY: ""
DATABRICKS_104_JDBC_URL: ""
DATABRICKS_113_JDBC_URL: ""
DATABRICKS_122_JDBC_URL: ""
DATABRICKS_133_JDBC_URL: ""
Expand Down Expand Up @@ -1066,7 +1062,6 @@ jobs:
AWS_REGION: ${{ vars.TRINO_AWS_REGION }}
TRINO_AWS_ACCESS_KEY_ID: ${{ vars.TRINO_AWS_ACCESS_KEY_ID }}
TRINO_AWS_SECRET_ACCESS_KEY: ${{ secrets.TRINO_AWS_SECRET_ACCESS_KEY }}
DATABRICKS_104_JDBC_URL: ${{ vars.DATABRICKS_104_JDBC_URL }}
DATABRICKS_113_JDBC_URL: ${{ vars.DATABRICKS_113_JDBC_URL }}
DATABRICKS_122_JDBC_URL: ${{ vars.DATABRICKS_122_JDBC_URL }}
DATABRICKS_133_JDBC_URL: ${{ vars.DATABRICKS_133_JDBC_URL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'trinodb/trino'
steps:
- uses: actions/stale@v9.0.0
- uses: actions/stale@v9.1.0
with:
stale-pr-message: 'This pull request has gone a while without any activity. Tagging for triage help: @mosabua'
days-before-pr-stale: 21
Expand All @@ -21,7 +21,7 @@ jobs:
stale-pr-label: 'stale'
exempt-pr-labels: 'stale-ignore'
start-date: '2020-01-01T00:00:00Z'
exempt-draft-pr: true
exempt-draft-pr: false
operations-per-run: 200
# Avoid processing issues completely, see https://github.com/actions/stale/issues/1112
days-before-issue-stale: -1
Expand Down
6 changes: 6 additions & 0 deletions .mvn/modernizer/violations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,10 @@
<version>1.8</version>
<comment>Use io.trino.plugin.base.util.JsonUtils.jsonFactoryBuilder() instead</comment>
</violation>

<violation>
<name>software/amazon/awssdk/services/glue/model/Table.tableType:()Ljava/lang/String;</name>
<version>1.8</version>
<comment>Table type is nullable in Glue model, which is too easy to forget about. Prefer GlueConverter.getTableTypeNullable</comment>
</violation>
</modernizer>
2 changes: 1 addition & 1 deletion client/trino-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.trino</groupId>
<artifactId>trino-root</artifactId>
<version>470-SNAPSHOT</version>
<version>471-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import io.trino.client.ClientSession;
import io.trino.client.ClientTypeSignature;
import io.trino.client.Column;
import io.trino.client.JsonCodec;
import io.trino.client.QueryResults;
import io.trino.client.StatementStats;
import io.trino.client.TrinoJsonCodec;
import io.trino.client.TypedQueryData;
import io.trino.client.uri.PropertyName;
import io.trino.client.uri.TrinoUri;
Expand All @@ -46,7 +46,7 @@
import static io.trino.cli.ClientOptions.OutputFormat.CSV;
import static io.trino.cli.TerminalUtils.getTerminal;
import static io.trino.client.ClientStandardTypes.BIGINT;
import static io.trino.client.JsonCodec.jsonCodec;
import static io.trino.client.TrinoJsonCodec.jsonCodec;
import static io.trino.client.auth.external.ExternalRedirectStrategy.PRINT;
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -55,7 +55,7 @@
@TestInstance(PER_METHOD)
public class TestQueryRunner
{
private static final JsonCodec<QueryResults> QUERY_RESULTS_CODEC = jsonCodec(QueryResults.class);
private static final TrinoJsonCodec<QueryResults> QUERY_RESULTS_CODEC = jsonCodec(QueryResults.class);
private MockWebServer server;

@BeforeEach
Expand Down
2 changes: 1 addition & 1 deletion client/trino-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.trino</groupId>
<artifactId>trino-root</artifactId>
<version>470-SNAPSHOT</version>
<version>471-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public int hashCode()
public static class ClientTypeSignatureParameterDeserializer
extends JsonDeserializer<ClientTypeSignatureParameter>
{
private static final ObjectMapper MAPPER = JsonCodec.OBJECT_MAPPER_SUPPLIER.get();
private static final ObjectMapper MAPPER = TrinoJsonCodec.OBJECT_MAPPER_SUPPLIER.get();

@Override
public ClientTypeSignatureParameter deserialize(JsonParser jp, DeserializationContext ctxt)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.client;

import java.io.Closeable;
import java.util.Iterator;

/*
* A CloseableIterator is an Iterator that must be closed to release resources.
*/
public interface CloseableIterator<T>
extends Iterator<T>, Closeable
{
static <T> CloseableIterator<T> closeable(Iterator<T> iterator)
{
return new CloseableIterator<T>()
{
@Override
public void close()
{
}

@Override
public boolean hasNext()
{
return iterator.hasNext();
}

@Override
public T next()
{
return iterator.next();
}

@Override
public String toString()
{
return "CloseableIterator{iterator=" + iterator + '}';
}
};
}

@Override
String toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@
import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

public final class JsonResultRows
public final class JsonIterators
{
private static final JsonFactory JSON_FACTORY = createJsonFactory();

private JsonResultRows() {}
private JsonIterators() {}

private static class RowWiseIterator
private static class JsonIterator
extends AbstractIterator<List<Object>>
implements CloseableIterator<List<Object>>
{
private final Closer closer = Closer.create();
private boolean closed;
private final JsonParser parser;
private final TypeDecoder[] decoders;

public RowWiseIterator(JsonParser parser, TypeDecoder[] decoders)
public JsonIterator(JsonParser parser, TypeDecoder[] decoders)
throws IOException
{
requireNonNull(decoders, "decoders is null");
Expand All @@ -77,7 +78,7 @@ public RowWiseIterator(JsonParser parser, TypeDecoder[] decoders)
}
}

public RowWiseIterator(InputStream stream, TypeDecoder[] decoders)
public JsonIterator(InputStream stream, TypeDecoder[] decoders)
throws IOException
{
this(JSON_FACTORY.createParser(requireNonNull(stream, "stream is null")), decoders);
Expand Down Expand Up @@ -128,36 +129,25 @@ public List<Object> computeNext()
}
}

private void close()
@Override
public void close()
throws IOException
{
this.closed = true;
closer.close();
}
}

public static ResultRows forJsonParser(JsonParser parser, List<Column> columns)
public static CloseableIterator<List<Object>> forJsonParser(JsonParser parser, List<Column> columns)
throws IOException
{
return () -> {
try {
return new RowWiseIterator(parser, createTypeDecoders(columns));
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
};
return new JsonIterator(parser, createTypeDecoders(columns));
}

public static ResultRows forInputStream(InputStream stream, TypeDecoder[] decoders)
public static CloseableIterator<List<Object>> forInputStream(InputStream stream, TypeDecoder[] decoders)
throws IOException
{
return () -> {
try {
return new RowWiseIterator(stream, decoders);
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
};
return new JsonIterator(stream, decoders);
}

@SuppressModernizer // There is no JsonFactory in the client module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public String toString()
.toString();
}

public static <T> JsonResponse<T> execute(JsonCodec<T> codec, Call.Factory client, Request request, OptionalLong materializedJsonSizeLimit)
public static <T> JsonResponse<T> execute(TrinoJsonCodec<T> codec, Call.Factory client, Request request, OptionalLong materializedJsonSizeLimit)
{
try (Response response = client.newCall(request).execute()) {
ResponseBody responseBody = requireNonNull(response.body());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import okhttp3.Request;
import okhttp3.Response;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
Expand Down Expand Up @@ -65,7 +64,7 @@ public InputStream load(SpooledSegment segment)
}

if (response.isSuccessful()) {
return delegatingInputStream(response, response.body().byteStream(), segment);
return response.body().byteStream();
}
throw new IOException(format("Could not open segment for streaming, got error '%s' with code %d", response.message(), response.code()));
}
Expand Down Expand Up @@ -95,21 +94,6 @@ public void onResponse(Call call, Response response)
});
}

private InputStream delegatingInputStream(Response response, InputStream delegate, SpooledSegment segment)
{
return new FilterInputStream(delegate)
{
@Override
public void close()
throws IOException
{
try (Response ignored = response; InputStream ignored2 = delegate) {
acknowledge(segment);
}
}
};
}

private static Headers toHeaders(Map<String, List<String>> headers)
{
Headers.Builder builder = new Headers.Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface Factory
*
* @throws IOException if an I/O error occurs
*/
ResultRows decode(InputStream input, DataAttributes segmentAttributes)
CloseableIterator<List<Object>> decode(InputStream input, DataAttributes segmentAttributes)
throws IOException;

String encoding();
Expand Down
43 changes: 40 additions & 3 deletions client/trino-client/src/main/java/io/trino/client/ResultRows.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@
*/
package io.trino.client;

import java.io.Closeable;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import static com.google.common.base.Verify.verify;
import static java.util.Collections.emptyIterator;

/**
* Allows iterating over decoded result data in row-wise manner.
*
* Iterator can be acquired only once, and it should be closed after use.
*/
public interface ResultRows
extends Iterable<List<Object>>
extends Iterable<List<Object>>, Closeable
{
ResultRows NULL_ROWS = new ResultRows() {
@Override
public void close() {}

@Override
public boolean isNull()
{
Expand All @@ -38,11 +46,40 @@ public Iterator<List<Object>> iterator()
{
return emptyIterator();
}

@Override
public String toString()
{
return "EmptyResultRows{}";
}
};

static ResultRows fromIterableRows(Iterable<List<Object>> values)
static ResultRows wrapIterator(CloseableIterator<List<Object>> iterator)
{
return values::iterator;
return new ResultRows() {
private volatile boolean fetched;

@Override
public void close()
throws IOException
{
iterator.close();
}

@Override
public Iterator<List<Object>> iterator()
{
verify(!fetched, "Iterator already fetched");
fetched = true;
return iterator;
}

@Override
public String toString()
{
return "ResultRows{iterator=" + iterator + "}";
}
};
}

default boolean isNull()
Expand Down
Loading
Loading