Search in sources :

Example 11 with SqlParserOptions

use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.

the class TestQueues method createQueryRunner.

private static DistributedQueryRunner createQueryRunner(Map<String, String> properties) throws Exception {
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().build(), 2, ImmutableMap.of(), properties, new SqlParserOptions());
    try {
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Example 12 with SqlParserOptions

use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.

the class TestQueues method createQueryRunner.

private static DistributedQueryRunner createQueryRunner(String dbConfigUrl, H2ResourceGroupsDao dao) throws Exception {
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    builder.put("experimental.resource-groups-enabled", "true");
    Map<String, String> properties = builder.build();
    DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().build(), 2, ImmutableMap.of(), properties, new SqlParserOptions());
    try {
        Plugin h2ResourceGroupManagerPlugin = new H2ResourceGroupManagerPlugin();
        queryRunner.installPlugin(h2ResourceGroupManagerPlugin);
        queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager(NAME, ImmutableMap.of("resource-groups.config-db-url", dbConfigUrl));
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        setup(queryRunner, dao);
        return queryRunner;
    } catch (Exception e) {
        queryRunner.close();
        throw e;
    }
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) ImmutableMap(com.google.common.collect.ImmutableMap) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) Plugin(com.facebook.presto.spi.Plugin)

Example 13 with SqlParserOptions

use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.

the class TestPrestoDriverAuth method setup.

@BeforeClass
public void setup() throws Exception {
    Logging.initialize();
    URL resource = getClass().getClassLoader().getResource("33.privateKey");
    assertNotNull(resource, "key directory not found");
    File keyDir = new File(resource.getFile()).getAbsoluteFile().getParentFile();
    defaultKey = getMimeDecoder().decode(asCharSource(new File(keyDir, "default-key.key"), US_ASCII).read().getBytes(US_ASCII));
    hmac222 = getMimeDecoder().decode(asCharSource(new File(keyDir, "222.key"), US_ASCII).read().getBytes(US_ASCII));
    privateKey33 = PemReader.loadPrivateKey(new File(keyDir, "33.privateKey"), Optional.empty());
    server = new TestingPrestoServer(true, ImmutableMap.<String, String>builder().put("http-server.authentication.type", "JWT").put("http.authentication.jwt.key-file", new File(keyDir, "${KID}.key").toString()).put("http-server.https.enabled", "true").put("http-server.https.keystore.path", getResource("localhost.keystore").getPath()).put("http-server.https.keystore.key", "changeit").build(), null, null, new SqlParserOptions(), ImmutableList.of());
    server.installPlugin(new TpchPlugin());
    server.createCatalog(TEST_CATALOG, "tpch");
    waitForNodeRefresh(server);
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) File(java.io.File) URL(java.net.URL) BeforeClass(org.testng.annotations.BeforeClass)

Example 14 with SqlParserOptions

use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.

the class TestHttpRequestSessionContext method testPreparedStatementsSpecialCharacters.

@Test
public void testPreparedStatementsSpecialCharacters() {
    HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_SOURCE, "testSource").put(PRESTO_CATALOG, "testCatalog").put(PRESTO_SCHEMA, "testSchema").put(PRESTO_LANGUAGE, "zh-TW").put(PRESTO_TIME_ZONE, "Asia/Taipei").put(PRESTO_CLIENT_INFO, "null").put(PRESTO_PREPARED_STATEMENT, "query1=select * from \"tbl:ns\"").build(), "testRemote");
    SqlParserOptions options = new SqlParserOptions();
    options.allowIdentifierSymbol(EnumSet.allOf(IdentifierSymbol.class));
    new HttpRequestSessionContext(request, options);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) IdentifierSymbol(com.facebook.presto.sql.parser.IdentifierSymbol) Test(org.testng.annotations.Test)

Example 15 with SqlParserOptions

use of com.facebook.presto.sql.parser.SqlParserOptions in project presto by prestodb.

the class TestHttpRequestSessionContext method testPreparedStatementsHeaderDoesNotParse.

@Test(expectedExceptions = WebApplicationException.class)
public void testPreparedStatementsHeaderDoesNotParse() {
    HttpServletRequest request = new MockHttpServletRequest(ImmutableListMultimap.<String, String>builder().put(PRESTO_USER, "testUser").put(PRESTO_SOURCE, "testSource").put(PRESTO_CATALOG, "testCatalog").put(PRESTO_SCHEMA, "testSchema").put(PRESTO_LANGUAGE, "zh-TW").put(PRESTO_TIME_ZONE, "Asia/Taipei").put(PRESTO_CLIENT_INFO, "null").put(PRESTO_PREPARED_STATEMENT, "query1=abcdefg").build(), "testRemote");
    new HttpRequestSessionContext(request, new SqlParserOptions());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) Test(org.testng.annotations.Test)

Aggregations

SqlParserOptions (com.facebook.presto.sql.parser.SqlParserOptions)18 Test (org.testng.annotations.Test)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 SqlParser (com.facebook.presto.sql.parser.SqlParser)5 CatalogManager (com.facebook.presto.metadata.CatalogManager)4 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)4 SqlEnvironmentConfig (com.facebook.presto.sql.SqlEnvironmentConfig)4 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)4 JsonBinder.jsonBinder (com.facebook.airlift.json.JsonBinder.jsonBinder)3 BlockEncodingManager (com.facebook.presto.common.block.BlockEncodingManager)3 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)3 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)3 HandleJsonModule (com.facebook.presto.metadata.HandleJsonModule)3 StaticCatalogStore (com.facebook.presto.metadata.StaticCatalogStore)3 StaticFunctionNamespaceStore (com.facebook.presto.metadata.StaticFunctionNamespaceStore)3 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)3 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 Threads.daemonThreadsNamed (com.facebook.airlift.concurrent.Threads.daemonThreadsNamed)2 AbstractConfigurationAwareModule (com.facebook.airlift.configuration.AbstractConfigurationAwareModule)2