diff --git a/client/trino-adbc/pom.xml b/client/trino-adbc/pom.xml
new file mode 100644
index 000000000000..8a974a8f8b67
--- /dev/null
+++ b/client/trino-adbc/pom.xml
@@ -0,0 +1,230 @@
+
+
+ 4.0.0
+
+
+ io.trino
+ trino-root
+ 469-SNAPSHOT
+ ../../pom.xml
+
+
+ trino-adbc
+ Trino - ADBC driver
+
+
+ 8
+ io.trino.adbc.\$internal
+
+
+
+
+
+
+ io.trino
+ trino-client
+
+
+
+ jakarta.annotation
+ jakarta.annotation-api
+
+ 2.1.1
+
+
+
+ org.apache.arrow.adbc
+ adbc-core
+ 0.15.0
+
+
+
+
+
+
+
+ true
+ src/main/resources
+
+ io/trino/jdbc/driver.properties
+
+
+
+ false
+ src/main/resources
+
+ io/trino/jdbc/driver.properties
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ ISO-8859-1
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+
+
+
+
+ io.airlift:units
+
+
+
+
+
+ io.airlift:aircompressor-v3
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+
+ shade
+
+ package
+
+ true
+ true
+
+
+ io.trino.client
+ ${shadeBase}.client
+
+
+ io.opentelemetry.instrumentation.okhttp.v3_0
+ ${shadeBase}.opentelemetry.okhttp.v3_0
+
+
+ com.fasterxml.jackson
+ ${shadeBase}.jackson
+
+
+ com.google.common
+ ${shadeBase}.guava
+
+
+ com.google.thirdparty
+ ${shadeBase}.guava
+
+
+ io.airlift
+ ${shadeBase}.airlift
+
+
+ jakarta.annotation
+ ${shadeBase}.jakarta.annotation
+
+
+ net.bytebuddy
+ ${shadeBase}.net.bytebuddy
+
+
+ org.joda.time
+ ${shadeBase}.joda.time
+
+
+ okhttp3
+ ${shadeBase}.okhttp3
+
+
+ okio
+ ${shadeBase}.okio
+
+
+ dev.failsafe
+ ${shadeBase}.dev.failsafe
+
+
+ kotlin
+ ${shadeBase}.kotlin
+
+
+
+
+ io.airlift:units
+
+ ValidationMessages.properties
+
+
+
+ *:*
+
+ org/jetbrains/**
+ org/intellij/**
+ com/google/errorprone/**
+ META-INF/maven/**
+ META-INF/licenses/**
+ META-INF/services/com.fasterxml.**
+ META-INF/proguard/**
+ LICENSE
+ META-INF/**.kotlin_module
+ META-INF/versions/**
+ META-INF/NOTICE**
+ META-INF/*-NOTICE
+ META-INF/*-LICENSE
+ META-INF/LICENSE**
+ META-INF/io/opentelemetry/**
+ io/opentelemetry/semconv/**
+ META-INF/native-image/**
+ META-INF/kotlin-project-structure-metadata.json
+ **/*.knm
+ **/manifest
+ **/module
+
+
+
+
+
+
+
+
+
+
+
+
+ ci
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+
+
+ ${project.build.directory}/${project.name}-${project.version}.jar
+
+
+
+
+
+ integration-test
+ verify
+
+
+
+
+
+
+
+
+
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoAdbcResult.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoAdbcResult.java
new file mode 100644
index 000000000000..f77fb4068719
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoAdbcResult.java
@@ -0,0 +1,29 @@
+package io.trino.adbc;
+
+import org.apache.arrow.adbc.core.AdbcStatement;
+import org.apache.arrow.vector.types.pojo.Schema;
+
+public class TrinoAdbcResult implements AdbcStatement.QueryResult {
+ @Override
+ public Schema getSchema() {
+ // Return result schema
+ return null;
+ }
+
+ @Override
+ public boolean next() {
+ // Move to next row
+ return false;
+ }
+
+ @Override
+ public Object getValue(int columnIndex) {
+ // Get value at specified column
+ return null;
+ }
+
+ @Override
+ public void close() {
+ // Implement result cleanup
+ }
+}
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoConnection.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoConnection.java
new file mode 100644
index 000000000000..eb659c2e6da1
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoConnection.java
@@ -0,0 +1,156 @@
+package io.trino.adbc;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableList;
+import com.google.common.primitives.Ints;
+import io.trino.client.ClientInfoProperty;
+import io.trino.client.ClientSelectedRole;
+import io.trino.client.StatementClient;
+import io.trino.client.StatementClientFactory;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import org.apache.arrow.adbc.core.AdbcConnection;
+import org.apache.arrow.adbc.core.AdbcException;
+import org.apache.arrow.adbc.core.AdbcStatement;
+import org.apache.arrow.vector.ipc.ArrowReader;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.net.URI;
+import java.sql.SQLException;
+import java.time.ZoneId;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static com.google.common.base.Preconditions.checkState;
+import static io.trino.client.ClientInfoProperty.*;
+import static java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
+import static java.util.Collections.newSetFromMap;
+import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MINUTES;
+
+public class TrinoConnection implements AdbcConnection {
+ private static final Logger logger = Logger.getLogger(TrinoConnection.class.getPackage().getName());
+
+ private final AtomicBoolean closed = new AtomicBoolean();
+ private final AtomicBoolean autoCommit = new AtomicBoolean(true);
+ private final AtomicInteger isolationLevel = new AtomicInteger(TRANSACTION_READ_UNCOMMITTED);
+ private final AtomicBoolean readOnly = new AtomicBoolean();
+ private final AtomicReference catalog = new AtomicReference<>();
+ private final AtomicReference schema = new AtomicReference<>();
+ private final AtomicReference> path = new AtomicReference<>(ImmutableList.of());
+ private final AtomicReference authorizationUser = new AtomicReference<>();
+ private final AtomicReference timeZoneId = new AtomicReference<>();
+ private final AtomicReference locale = new AtomicReference<>();
+ private final AtomicReference networkTimeoutMillis = new AtomicReference<>(Ints.saturatedCast(MINUTES.toMillis(2)));
+ private final AtomicLong nextStatementId = new AtomicLong(1);
+ private final AtomicReference> sessionUser = new AtomicReference<>();
+
+ private final URI jdbcUri;
+ private final URI httpUri;
+ private final Optional user;
+ private final boolean compressionDisabled;
+ private final Optional encoding;
+ private final boolean assumeLiteralNamesInMetadataCallsForNonConformingClients;
+ private final boolean assumeLiteralUnderscoreInMetadataCallsForNonConformingClients;
+ private final Map extraCredentials;
+ private final Optional applicationNamePrefix;
+ private final Optional source;
+ private final Map clientInfo = new ConcurrentHashMap<>();
+ private final Map sessionProperties = new ConcurrentHashMap<>();
+ private final Map preparedStatements = new ConcurrentHashMap<>();
+ private final Map roles = new ConcurrentHashMap<>();
+ private final AtomicReference transactionId = new AtomicReference<>();
+ private final Call.Factory httpCallFactory;
+ private final Call.Factory segmentHttpCallFactory;
+ private final Set statements = newSetFromMap(new ConcurrentHashMap<>());
+ private boolean useExplicitPrepare = true;
+ private boolean assumeNullCatalogMeansCurrentCatalog;
+
+ public TrinoConnection(TrinoDriverUri uri, Call.Factory httpCallFactory, Call.Factory segmentHttpCallFactory) {
+ requireNonNull(uri, "uri is null");
+ this.jdbcUri = uri.getUri();
+ this.httpUri = uri.getHttpUri();
+ uri.getSchema().ifPresent(schema::set);
+ uri.getCatalog().ifPresent(catalog::set);
+ this.user = uri.getUser();
+ this.sessionUser.set(uri.getSessionUser());
+ this.applicationNamePrefix = uri.getApplicationNamePrefix();
+ this.source = uri.getSource();
+ this.extraCredentials = uri.getExtraCredentials();
+ this.compressionDisabled = uri.isCompressionDisabled();
+ this.encoding = uri.getEncoding();
+ this.assumeLiteralNamesInMetadataCallsForNonConformingClients = uri.isAssumeLiteralNamesInMetadataCallsForNonConformingClients();
+
+ if (this.assumeLiteralNamesInMetadataCallsForNonConformingClients) {
+ logger.log(Level.WARNING, "Connection config assumeLiteralNamesInMetadataCallsForNonConformingClients is deprecated, please use " +
+ "assumeLiteralUnderscoreInMetadataCallsForNonConformingClients.");
+ }
+
+ this.assumeLiteralUnderscoreInMetadataCallsForNonConformingClients = uri.isAssumeLiteralUnderscoreInMetadataCallsForNonConformingClients();
+
+ this.httpCallFactory = requireNonNull(httpCallFactory, "httpCallFactory is null");
+ this.segmentHttpCallFactory = requireNonNull(segmentHttpCallFactory, "segmentHttpCallFactory is null");
+ uri.getClientInfo().ifPresent(tags -> clientInfo.put(CLIENT_INFO, tags));
+ uri.getClientTags().ifPresent(tags -> clientInfo.put(CLIENT_TAGS, Joiner.on(",").join(tags)));
+ uri.getTraceToken().ifPresent(tags -> clientInfo.put(TRACE_TOKEN, tags));
+
+ roles.putAll(uri.getRoles());
+ timeZoneId.set(uri.getTimeZone());
+ locale.set(Locale.getDefault());
+ sessionProperties.putAll(uri.getSessionProperties());
+
+ uri.getExplicitPrepare().ifPresent(value -> this.useExplicitPrepare = value);
+ uri.getAssumeNullCatalogMeansCurrentCatalog().ifPresent(value -> this.assumeNullCatalogMeansCurrentCatalog = value);
+ }
+
+ @Override
+ public AdbcStatement createStatement() throws AdbcException {
+ checkOpen();
+ TrinoStatement statement = new TrinoStatement(this, this::unregisterStatement);
+ registerStatement(statement);
+ return statement; }
+
+ @Override
+ public ArrowReader getInfo(int @Nullable [] infoCodes) throws AdbcException {
+ return null;
+ }
+
+ private void checkOpen()
+ throws AdbcException
+ {
+ if (isClosed()) {
+ throw AdbcException.invalidState("Connection is closed");
+ }
+ }
+
+ private void registerStatement(TrinoStatement statement)
+ {
+ checkState(statements.add(statement), "Statement is already registered");
+ }
+
+ private void unregisterStatement(TrinoStatement statement)
+ {
+ checkState(statements.remove(statement), "Statement is not registered");
+ }
+
+ boolean shouldStartTransaction()
+ {
+ return !autoCommit.get() && (transactionId.get() == null);
+ }
+
+ public boolean isClosed()
+ {
+ return closed.get();
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+}
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDatabase.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDatabase.java
new file mode 100644
index 000000000000..09d8e3427df4
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDatabase.java
@@ -0,0 +1,34 @@
+package io.trino.adbc;
+
+import io.trino.client.uri.HttpClientFactory;
+import okhttp3.ConnectionPool;
+import okhttp3.Dispatcher;
+import okhttp3.OkHttpClient;
+import org.apache.arrow.adbc.core.AdbcConnection;
+import org.apache.arrow.adbc.core.AdbcDatabase;
+import org.apache.arrow.adbc.core.AdbcException;
+
+import java.io.IOException;
+
+public class TrinoDatabase implements AdbcDatabase {
+ private final TrinoDriverUri uri;
+ private final OkHttpClient httpClient;
+ private final OkHttpClient segmentClient;
+
+ public TrinoDatabase(TrinoDriverUri uri, OkHttpClient httpClient, OkHttpClient segmentClient) {
+ this.uri = uri;//TODO should this be shared at the db level?
+ this.httpClient = httpClient;
+ this.segmentClient = segmentClient;
+ }
+ @Override
+ public AdbcConnection connect() throws AdbcException {
+ return new TrinoConnection(uri, httpClient, segmentClient);
+ }
+
+ @Override
+ public void close()
+ throws IOException
+ {
+
+ }
+}
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriver.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriver.java
new file mode 100644
index 000000000000..c879e288d237
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriver.java
@@ -0,0 +1,68 @@
+package io.trino.adbc;
+
+import io.trino.client.uri.HttpClientFactory;
+import okhttp3.ConnectionPool;
+import okhttp3.Dispatcher;
+import okhttp3.OkHttpClient;
+import org.apache.arrow.adbc.core.AdbcDatabase;
+import org.apache.arrow.adbc.core.AdbcDriver;
+import org.apache.arrow.adbc.core.AdbcException;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+
+public class TrinoDriver implements AdbcDriver, Closeable {
+ private final Dispatcher dispatcher;
+ private final ConnectionPool pool;
+ public TrinoDriver() {
+ dispatcher = new Dispatcher();
+ pool = new ConnectionPool();
+ }
+
+ @Override
+ public AdbcDatabase open(Map parameters) throws AdbcException {
+ String url = PARAM_URI.get(parameters);
+ if (url == null) {
+ Object target = parameters.get(AdbcDriver.PARAM_URL);
+ if (!(target instanceof String)) {
+ throw AdbcException.invalidArgument(
+ "[Trino] Must provide String " + PARAM_URI + " parameter");
+ }
+ url = (String) target;
+ }
+
+ Properties driverProperties = new Properties();
+ driverProperties.putAll(parameters);
+ TrinoDriverUri uri = null;
+ try {
+ uri = TrinoDriverUri.createDriverUri(url, driverProperties);
+ } catch (SQLException e) {
+ throw AdbcException.invalidArgument("failed to create driver uri: " + uri)
+ .withCause(e);
+ }
+ OkHttpClient.Builder httpClientBuilder = HttpClientFactory.toHttpClientBuilder(uri, "trino-adbc/0.0.1");//TODO agent
+ httpClientBuilder.connectionPool(pool);
+ httpClientBuilder.dispatcher(dispatcher);
+ OkHttpClient httpClient = httpClientBuilder.build();
+
+ OkHttpClient.Builder segmentHttpClientBuilder = HttpClientFactory.unauthenticatedClientBuilder(uri, USER_AGENT);
+ segmentHttpClientBuilder.connectionPool(pool);
+ segmentHttpClientBuilder.dispatcher(dispatcher);
+ OkHttpClient segmentClient = segmentHttpClientBuilder.build();
+
+ return new TrinoDatabase(uri, httpClient, segmentClient);
+
+ }
+
+ @Override
+ public void close()
+ throws IOException
+ {
+ // Close dispatcher and pool shared between multiple clients
+ dispatcher.executorService().shutdown();
+ pool.evictAll();
+ }
+}
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriverUri.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriverUri.java
new file mode 100644
index 000000000000..a26aa2207d9e
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoDriverUri.java
@@ -0,0 +1,128 @@
+/*
+ * 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.adbc;
+
+import io.trino.client.uri.ConnectionProperty;
+import io.trino.client.uri.TrinoUri;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import static com.google.common.base.MoreObjects.firstNonNull;
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+/**
+ * Parses and extracts parameters from a Trino JDBC URL.
+ */
+public final class TrinoDriverUri
+ extends TrinoUri
+{
+ private static final String ADBC_URL_PREFIX = "adbc:";
+ private static final String JDBC_URL_START = ADBC_URL_PREFIX + "trino:";
+
+ private TrinoDriverUri(String uri, Properties driverProperties)
+ throws SQLException
+ {
+ super(parseDriverUrl(uri), driverProperties);
+ }
+
+ static TrinoDriverUri createDriverUri(String url, Properties properties)
+ throws SQLException
+ {
+ try {
+ return new TrinoDriverUri(url, firstNonNull(properties, new Properties()));
+ }
+ catch (RuntimeException e) {
+ throw new SQLException(e.getMessage(), e.getCause());
+ }
+ }
+
+ public static boolean acceptsURL(String url)
+ {
+ return url.startsWith(JDBC_URL_START);
+ }
+
+ private static URI parseDriverUrl(String url)
+ throws SQLException
+ {
+ validatePrefix(url);
+ URI uri = parseUrl(url);
+
+ if (isNullOrEmpty(uri.getHost())) {
+ throw new SQLException("No host specified: " + url);
+ }
+ if (uri.getPort() == 0 || uri.getPort() > 65535) {
+ throw new SQLException("Invalid port number: " + url);
+ }
+ return uri;
+ }
+
+ private static URI parseUrl(String url)
+ throws SQLException
+ {
+ try {
+ return new URI(url.substring(ADBC_URL_PREFIX.length()));
+ }
+ catch (URISyntaxException e) {
+ throw new SQLException("Invalid JDBC URL: " + url, e);
+ }
+ }
+
+ private static void validatePrefix(String url)
+ throws SQLException
+ {
+ if (!url.startsWith(JDBC_URL_START)) {
+ throw new SQLException("Invalid JDBC URL: " + url);
+ }
+
+ if (url.equals(JDBC_URL_START)) {
+ throw new SQLException("Empty JDBC URL: " + url);
+ }
+ }
+
+ public static DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
+ {
+ Properties properties = urlProperties(url, info);
+ return allProperties().stream()
+ .filter(property -> property.isValid(properties))
+ .map(property -> getDriverPropertyInfo(property, properties))
+ .toArray(DriverPropertyInfo[]::new);
+ }
+
+ /*
+ * Combines properties extracted from url with provided ones
+ */
+ private static Properties urlProperties(String url, Properties info)
+ {
+ try {
+ return create(url, info).getProperties();
+ }
+ catch (RuntimeException e) {
+ return info;
+ }
+ }
+
+ private static DriverPropertyInfo getDriverPropertyInfo(ConnectionProperty, ?> property, Properties properties)
+ {
+ String currentValue = properties.getProperty(property.getKey());
+ DriverPropertyInfo result = new DriverPropertyInfo(property.getKey(), currentValue);
+ result.required = property.isRequired(properties);
+ result.choices = property.getChoices();
+ property.getValue(properties).ifPresent(value -> result.value = value.toString());
+ return result;
+ }
+}
diff --git a/client/trino-adbc/src/main/java/io/trino/adbc/TrinoStatement.java b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoStatement.java
new file mode 100644
index 000000000000..70d2219ac2cb
--- /dev/null
+++ b/client/trino-adbc/src/main/java/io/trino/adbc/TrinoStatement.java
@@ -0,0 +1,67 @@
+package io.trino.adbc;
+
+import io.trino.client.QueryStats;
+import io.trino.client.StatementClient;
+import org.apache.arrow.adbc.core.AdbcException;
+import org.apache.arrow.adbc.core.AdbcStatement;
+
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Consumer;
+
+import static io.trino.client.StatementClientFactory.newStatementClient;
+import static java.util.Objects.requireNonNull;
+
+
+public class TrinoStatement implements AdbcStatement {
+
+ private String query;
+
+ private final AtomicLong maxRows = new AtomicLong();
+ private final AtomicInteger queryTimeoutSeconds = new AtomicInteger();
+ private final AtomicInteger fetchSize = new AtomicInteger();
+ private final AtomicBoolean closeOnCompletion = new AtomicBoolean();
+ private final AtomicReference connection;
+ private final Consumer onClose;
+ private final AtomicReference executingClient = new AtomicReference<>();
+ private final AtomicReference currentResult = new AtomicReference<>();
+ //private final AtomicReference> currentWarningsManager = new AtomicReference<>(Optional.empty());
+ private final AtomicLong currentUpdateCount = new AtomicLong(-1);
+ private final AtomicReference currentUpdateType = new AtomicReference<>();
+ private final AtomicReference>> progressCallback = new AtomicReference<>(Optional.empty());
+ private final Consumer progressConsumer = value -> progressCallback.get().ifPresent(callback -> callback.accept(value));
+
+ public TrinoStatement(TrinoConnection connection, Consumer onClose){
+ this.connection = new AtomicReference<>(requireNonNull(connection, "connection is null"));
+ this.onClose = requireNonNull(onClose, "onClose is null");
+ }
+
+ @Override
+ public void setSqlQuery(String query) throws AdbcException {
+ this.query = query;
+ }
+
+ @Override
+ public QueryResult executeQuery() throws AdbcException {
+ requireNonNull(query, "query is null");
+ StatementClient client = newStatementClient();
+ }
+
+ @Override
+ public UpdateResult executeUpdate() throws AdbcException {
+ return null;
+ }
+
+ @Override
+ public void prepare() throws AdbcException {
+
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+}
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/ClientInfoProperty.java b/client/trino-client/src/main/java/io/trino/client/ClientInfoProperty.java
similarity index 96%
rename from client/trino-jdbc/src/main/java/io/trino/jdbc/ClientInfoProperty.java
rename to client/trino-client/src/main/java/io/trino/client/ClientInfoProperty.java
index 39556a114db2..660886bb2a16 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/ClientInfoProperty.java
+++ b/client/trino-client/src/main/java/io/trino/client/ClientInfoProperty.java
@@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.trino.jdbc;
+package io.trino.client;
import java.util.Map;
import java.util.Optional;
@@ -21,7 +21,7 @@
import static java.util.Objects.requireNonNull;
import static java.util.function.Function.identity;
-enum ClientInfoProperty
+public enum ClientInfoProperty
{
APPLICATION_NAME("ApplicationName"),
CLIENT_INFO("ClientInfo"),
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java b/client/trino-client/src/main/java/io/trino/client/QueryStats.java
similarity index 97%
rename from client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java
rename to client/trino-client/src/main/java/io/trino/client/QueryStats.java
index d09f3297de66..6ea59938569d 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/QueryStats.java
+++ b/client/trino-client/src/main/java/io/trino/client/QueryStats.java
@@ -11,9 +11,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.trino.jdbc;
-
-import io.trino.client.StatementStats;
+package io.trino.client;
import java.util.Optional;
import java.util.OptionalDouble;
@@ -101,7 +99,7 @@ static QueryStats create(String queryId, StatementStats stats)
stats.getProcessedRows(),
stats.getProcessedBytes(),
stats.getPeakMemoryBytes(),
- Optional.ofNullable(stats.getRootStage()).map(StageStats::create));
+ Optional.ofNullable(stats.getRootStage()));
}
public String getQueryId()
diff --git a/client/trino-client/src/main/java/io/trino/client/StatementClientV1.java b/client/trino-client/src/main/java/io/trino/client/StatementClientV1.java
index c5056aecf96d..712f3271a416 100644
--- a/client/trino-client/src/main/java/io/trino/client/StatementClientV1.java
+++ b/client/trino-client/src/main/java/io/trino/client/StatementClientV1.java
@@ -511,7 +511,7 @@ private void processResponse(Headers headers, QueryResults results)
}
currentResults.set(results);
- currentRows.set(resultRowsDecoder.toRows(results));
+ //currentRows.set(resultRowsDecoder.toRows(results)); TODO dont be lazy
}
private List safeSplitToList(String value)
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/AsyncResultIterator.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/AsyncResultIterator.java
index aba8a174a4be..0a5f2dc76b69 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/AsyncResultIterator.java
+++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/AsyncResultIterator.java
@@ -16,6 +16,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.AbstractIterator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import io.trino.client.QueryStats;
import io.trino.client.QueryStatusInfo;
import io.trino.client.StatementClient;
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
index d2ddf7df4f43..c6ce824b95a9 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
+++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoConnection.java
@@ -21,6 +21,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints;
import io.airlift.units.Duration;
+import io.trino.client.ClientInfoProperty;
import io.trino.client.ClientSelectedRole;
import io.trino.client.ClientSession;
import io.trino.client.StatementClient;
@@ -68,10 +69,10 @@
import static com.google.common.base.Strings.nullToEmpty;
import static com.google.common.collect.Maps.fromProperties;
import static io.trino.client.StatementClientFactory.newStatementClient;
-import static io.trino.jdbc.ClientInfoProperty.APPLICATION_NAME;
-import static io.trino.jdbc.ClientInfoProperty.CLIENT_INFO;
-import static io.trino.jdbc.ClientInfoProperty.CLIENT_TAGS;
-import static io.trino.jdbc.ClientInfoProperty.TRACE_TOKEN;
+import static io.trino.client.ClientInfoProperty.APPLICATION_NAME;
+import static io.trino.client.ClientInfoProperty.CLIENT_INFO;
+import static io.trino.client.ClientInfoProperty.CLIENT_TAGS;
+import static io.trino.client.ClientInfoProperty.TRACE_TOKEN;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.util.Collections.newSetFromMap;
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDatabaseMetaData.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDatabaseMetaData.java
index 16ce4a13dc8f..a13589d87c5d 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDatabaseMetaData.java
+++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoDatabaseMetaData.java
@@ -16,6 +16,7 @@
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
+import io.trino.client.ClientInfoProperty;
import io.trino.client.ClientTypeSignature;
import io.trino.client.ClientTypeSignatureParameter;
import io.trino.client.Column;
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoResultSet.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoResultSet.java
index a28d6bf62a56..5a6c58e899b5 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoResultSet.java
+++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoResultSet.java
@@ -15,6 +15,7 @@
import com.google.errorprone.annotations.concurrent.GuardedBy;
import io.trino.client.Column;
+import io.trino.client.QueryStats;
import io.trino.client.QueryStatusInfo;
import io.trino.client.StatementClient;
diff --git a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java
index 736c72dc946f..b807b13896a8 100644
--- a/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java
+++ b/client/trino-jdbc/src/main/java/io/trino/jdbc/TrinoStatement.java
@@ -16,6 +16,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;
import io.trino.client.ClientException;
+import io.trino.client.QueryStats;
import io.trino.client.QueryStatusInfo;
import io.trino.client.StatementClient;
diff --git a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java
index 000b47195e8c..244058aba343 100644
--- a/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java
+++ b/client/trino-jdbc/src/test/java/io/trino/jdbc/TestProgressMonitor.java
@@ -18,11 +18,7 @@
import io.airlift.json.JsonCodec;
import io.airlift.json.JsonCodecFactory;
import io.airlift.json.ObjectMapperProvider;
-import io.trino.client.ClientTypeSignature;
-import io.trino.client.Column;
-import io.trino.client.QueryResults;
-import io.trino.client.StatementStats;
-import io.trino.client.TypedQueryData;
+import io.trino.client.*;
import io.trino.server.protocol.spooling.QueryDataJacksonModule;
import io.trino.spi.type.StandardTypes;
import okhttp3.mockwebserver.MockResponse;