use of com.facebook.presto.client.ClientSession in project presto by prestodb.
the class TestClientOptions method testServerHostPort.
@Test
public void testServerHostPort() {
ClientOptions options = new ClientOptions();
options.server = "localhost:8888";
ClientSession session = options.toClientSession();
assertEquals(session.getServer().toString(), "http://localhost:8888");
}
use of com.facebook.presto.client.ClientSession in project presto by prestodb.
the class TestTableNameCompleter method testAutoCompleteWithoutSchema.
@Test
public void testAutoCompleteWithoutSchema() {
ClientSession session = new ClientOptions().toClientSession();
QueryRunner runner = QueryRunner.create(session, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), false, null);
TableNameCompleter completer = new TableNameCompleter(runner);
assertEquals(completer.complete("SELECT is_infi", 14, ImmutableList.of()), 7);
}
use of com.facebook.presto.client.ClientSession in project presto by prestodb.
the class Console method run.
@Override
public void run() {
ClientSession session = clientOptions.toClientSession();
KerberosConfig kerberosConfig = clientOptions.toKerberosConfig();
boolean hasQuery = !Strings.isNullOrEmpty(clientOptions.execute);
boolean isFromFile = !Strings.isNullOrEmpty(clientOptions.file);
if (!hasQuery && !isFromFile) {
AnsiConsole.systemInstall();
}
initializeLogging(clientOptions.logLevelsFile);
String query = clientOptions.execute;
if (hasQuery) {
query += ";";
}
if (isFromFile) {
if (hasQuery) {
throw new RuntimeException("both --execute and --file specified");
}
try {
query = Files.toString(new File(clientOptions.file), UTF_8);
hasQuery = true;
} catch (IOException e) {
throw new RuntimeException(format("Error reading from file %s: %s", clientOptions.file, e.getMessage()));
}
}
AtomicBoolean exiting = new AtomicBoolean();
interruptThreadOnExit(Thread.currentThread(), exiting);
try (QueryRunner queryRunner = QueryRunner.create(session, Optional.ofNullable(clientOptions.socksProxy), Optional.ofNullable(clientOptions.keystorePath), Optional.ofNullable(clientOptions.keystorePassword), Optional.ofNullable(clientOptions.truststorePath), Optional.ofNullable(clientOptions.truststorePassword), Optional.ofNullable(clientOptions.user), clientOptions.password ? Optional.of(getPassword()) : Optional.empty(), Optional.ofNullable(clientOptions.krb5Principal), Optional.ofNullable(clientOptions.krb5RemoteServiceName), clientOptions.authenticationEnabled, kerberosConfig)) {
if (hasQuery) {
executeCommand(queryRunner, query, clientOptions.outputFormat);
} else {
runConsole(queryRunner, session, exiting);
}
}
}
use of com.facebook.presto.client.ClientSession in project presto by prestodb.
the class TestClientOptions method testServerHttpUri.
@Test
public void testServerHttpUri() {
ClientOptions options = new ClientOptions();
options.server = "http://localhost/foo";
ClientSession session = options.toClientSession();
assertEquals(session.getServer().toString(), "http://localhost/foo");
}
use of com.facebook.presto.client.ClientSession in project presto by prestodb.
the class TestClientOptions method testServerHttpsUri.
@Test
public void testServerHttpsUri() {
ClientOptions options = new ClientOptions();
options.server = "https://localhost/foo";
ClientSession session = options.toClientSession();
assertEquals(session.getServer().toString(), "https://localhost/foo");
}
Aggregations