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

Remove SPI as dependency for JDBC driver #33

Merged
merged 5 commits into from
Jan 27, 2019
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.CharsetEncoder;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.TimeZone;

import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.US_ASCII;
Expand Down Expand Up @@ -97,7 +97,7 @@ public ClientSession getClientSession()
catalog,
schema,
null,
TimeZone.getDefault().getID(),
ZoneId.systemDefault(),
Locale.getDefault(),
ImmutableMap.of(),
toProperties(this.sessionProperties),
Expand Down
5 changes: 0 additions & 5 deletions presto-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
</properties>

<dependencies>
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-spi</artifactId>
</dependency>

<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package io.prestosql.cli;

import io.prestosql.spi.PrestoWarning;
electrum marked this conversation as resolved.
Show resolved Hide resolved
import io.prestosql.client.Warning;

import java.util.List;
import java.util.OptionalInt;
Expand All @@ -38,7 +38,7 @@ abstract class AbstractWarningsPrinter
this.maxWarnings = requireNonNull(maxWarnings, "maxWarnings is null");
}

private String getWarningMessage(PrestoWarning warning)
private String getWarningMessage(Warning warning)
{
// If this is a real terminal color the warnings yellow
if (REAL_TERMINAL) {
Expand All @@ -47,7 +47,7 @@ private String getWarningMessage(PrestoWarning warning)
return format("WARNING: %s", warning.getMessage());
}

private List<String> getNewWarnings(List<PrestoWarning> warnings)
private List<String> getNewWarnings(List<Warning> warnings)
{
int end = warnings.size();
if (maxWarnings.isPresent()) {
Expand Down Expand Up @@ -94,7 +94,7 @@ private void printWithTrailingSeparator(List<String> warnings)
}

@Override
public void print(List<PrestoWarning> warnings, boolean withInitialSeparator, boolean withTrailingSeparator)
public void print(List<Warning> warnings, boolean withInitialSeparator, boolean withTrailingSeparator)
{
requireNonNull(warnings, "warnings is null");
List<String> newWarnings = getNewWarnings(warnings);
Expand Down
4 changes: 2 additions & 2 deletions presto-cli/src/main/java/io/prestosql/cli/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.TimeZone;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.nullToEmpty;
Expand Down Expand Up @@ -160,7 +160,7 @@ public ClientSession toClientSession()
catalog,
schema,
null,
TimeZone.getDefault().getID(),
ZoneId.systemDefault(),
Locale.getDefault(),
toResourceEstimates(resourceEstimates),
toProperties(sessionProperties),
Expand Down
4 changes: 2 additions & 2 deletions presto-cli/src/main/java/io/prestosql/cli/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.prestosql.client.QueryError;
import io.prestosql.client.QueryStatusInfo;
import io.prestosql.client.StatementClient;
import io.prestosql.spi.PrestoWarning;
import io.prestosql.client.Warning;
import org.fusesource.jansi.Ansi;
import sun.misc.Signal;
import sun.misc.SignalHandler;
Expand Down Expand Up @@ -194,7 +194,7 @@ private void processInitialStatusUpdates(WarningsPrinter warningsPrinter)
warningsPrinter.print(client.currentStatusInfo().getWarnings(), true, false);
client.advance();
}
List<PrestoWarning> warnings;
List<Warning> warnings;
if (client.isRunning()) {
warnings = client.currentStatusInfo().getWarnings();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*/
package io.prestosql.cli;

import io.prestosql.spi.PrestoWarning;
import io.prestosql.client.Warning;

import java.util.List;

public interface WarningsPrinter
{
void print(List<PrestoWarning> warnings, boolean withInitialSeparator, boolean withTrailingSeparator);
void print(List<Warning> warnings, boolean withInitialSeparator, boolean withTrailingSeparator);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import io.airlift.json.JsonCodec;
import io.airlift.units.Duration;
import io.prestosql.client.ClientSession;
import io.prestosql.client.ClientTypeSignature;
import io.prestosql.client.Column;
import io.prestosql.client.QueryResults;
import io.prestosql.client.StatementStats;
import io.prestosql.spi.type.BigintType;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.testng.annotations.AfterMethod;
Expand All @@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.PrintStream;
import java.sql.SQLException;
import java.time.ZoneId;
import java.util.Locale;
import java.util.Optional;

Expand All @@ -41,6 +42,7 @@
import static com.google.common.net.HttpHeaders.SET_COOKIE;
import static io.airlift.json.JsonCodec.jsonCodec;
import static io.prestosql.cli.ClientOptions.OutputFormat.CSV;
import static io.prestosql.client.ClientStandardTypes.BIGINT;
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -92,7 +94,7 @@ public void testCookie()
"catalog",
"schema",
"path",
"America/Los_Angeles",
ZoneId.of("America/Los_Angeles"),
Locale.ENGLISH,
ImmutableMap.of(),
ImmutableMap.of(),
Expand All @@ -117,7 +119,7 @@ private String createResults()
server.url("/query.html?20160128_214710_00012_rk68b").uri(),
null,
null,
ImmutableList.of(new Column("_col0", BigintType.BIGINT)),
ImmutableList.of(new Column("_col0", BIGINT, new ClientTypeSignature(BIGINT))),
ImmutableList.of(ImmutableList.of(123)),
StatementStats.builder().setState("FINISHED").build(),
//new StatementStats("FINISHED", false, true, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null),
Expand Down
11 changes: 6 additions & 5 deletions presto-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
</properties>

<dependencies>
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-spi</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand Down Expand Up @@ -73,6 +68,12 @@
</dependency>

<!-- for testing -->
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-spi</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.airlift.units.Duration;
import io.prestosql.spi.type.TimeZoneKey;

import java.net.URI;
import java.nio.charset.CharsetEncoder;
import java.time.ZoneId;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
Expand All @@ -42,7 +42,7 @@ public class ClientSession
private final String catalog;
private final String schema;
private final String path;
private final TimeZoneKey timeZone;
private final ZoneId timeZone;
private final Locale locale;
private final Map<String, String> resourceEstimates;
private final Map<String, String> properties;
Expand Down Expand Up @@ -72,7 +72,7 @@ public ClientSession(
String catalog,
String schema,
String path,
String timeZoneId,
ZoneId timeZone,
Locale locale,
Map<String, String> resourceEstimates,
Map<String, String> properties,
Expand All @@ -90,7 +90,7 @@ public ClientSession(
this.schema = schema;
this.path = path;
this.locale = locale;
this.timeZone = TimeZoneKey.getTimeZoneKey(timeZoneId);
this.timeZone = requireNonNull(timeZone, "timeZone is null");
this.transactionId = transactionId;
this.resourceEstimates = ImmutableMap.copyOf(requireNonNull(resourceEstimates, "resourceEstimates is null"));
this.properties = ImmutableMap.copyOf(requireNonNull(properties, "properties is null"));
Expand Down Expand Up @@ -163,7 +163,7 @@ public String getPath()
return path;
}

public TimeZoneKey getTimeZone()
public ZoneId getTimeZone()
{
return timeZone;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ public static final class Builder
private String catalog;
private String schema;
private String path;
private TimeZoneKey timeZone;
private ZoneId timeZone;
private Locale locale;
private Map<String, String> resourceEstimates;
private Map<String, String> properties;
Expand Down Expand Up @@ -317,7 +317,7 @@ public ClientSession build()
catalog,
schema,
path,
timeZone.getId(),
timeZone,
locale,
resourceEstimates,
properties,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.prestosql.client;

public final class ClientStandardTypes
{
public static final String BIGINT = "bigint";
public static final String INTEGER = "integer";
public static final String SMALLINT = "smallint";
public static final String TINYINT = "tinyint";
public static final String BOOLEAN = "boolean";
public static final String DATE = "date";
public static final String DECIMAL = "decimal";
public static final String REAL = "real";
public static final String DOUBLE = "double";
public static final String HYPER_LOG_LOG = "HyperLogLog";
public static final String QDIGEST = "qdigest";
public static final String P4_HYPER_LOG_LOG = "P4HyperLogLog";
public static final String INTERVAL_DAY_TO_SECOND = "interval day to second";
public static final String INTERVAL_YEAR_TO_MONTH = "interval year to month";
public static final String TIMESTAMP = "timestamp";
public static final String TIMESTAMP_WITH_TIME_ZONE = "timestamp with time zone";
public static final String TIME = "time";
public static final String TIME_WITH_TIME_ZONE = "time with time zone";
public static final String VARBINARY = "varbinary";
public static final String VARCHAR = "varchar";
public static final String CHAR = "char";
public static final String ROW = "row";
public static final String ARRAY = "array";
public static final String MAP = "map";
public static final String JSON = "json";
public static final String IPADDRESS = "ipaddress";
public static final String GEOMETRY = "Geometry";
public static final String BING_TILE = "BingTile";

private ClientStandardTypes() {}
}
Loading