public static SqlParserOptions copyOf(SqlParserOptions other) { return new SqlParserOptions(other.allowedIdentifierSymbols, other.enhancedErrorHandlerEnabled); } }
public ServerMainModule(SqlParserOptions sqlParserOptions) { requireNonNull(sqlParserOptions, "sqlParserOptions is null"); this.sqlParserOptions = SqlParserOptions.copyOf(sqlParserOptions); }
@Inject public SqlParser(SqlParserOptions options) { requireNonNull(options, "options is null"); allowedIdentifierSymbols = EnumSet.copyOf(options.getAllowedIdentifierSymbols()); enhancedErrorHandlerEnabled = options.isEnhancedErrorHandlerEnabled(); }
@Test public void testAllowIdentifierColon() { SqlParser sqlParser = new SqlParser(new SqlParserOptions().allowIdentifierSymbol(COLON)); sqlParser.createStatement("select * from foo:bar"); }
sqlParserOptions.useEnhancedErrorHandler(serverConfig.isEnhancedErrorReporting());
@SuppressWarnings("deprecation") @Test public void testAllowIdentifierAtSign() { SqlParser sqlParser = new SqlParser(new SqlParserOptions().allowIdentifierSymbol(AT_SIGN)); sqlParser.createStatement("select * from foo@bar"); }
sqlParserOptions.useEnhancedErrorHandler(serverConfig.isEnhancedErrorReporting());
/** * Override this method to change the parser options used when parsing queries to decide if they match the allowed query types */ protected SqlParserOptions getParserOptions() { return new SqlParserOptions(); }
@Inject public SqlParser(SqlParserOptions options) { requireNonNull(options, "options is null"); allowedIdentifierSymbols = EnumSet.copyOf(options.getAllowedIdentifierSymbols()); enhancedErrorHandlerEnabled = options.isEnhancedErrorHandlerEnabled(); }
public ServerMainModule(SqlParserOptions sqlParserOptions) { requireNonNull(sqlParserOptions, "sqlParserOptions is null"); this.sqlParserOptions = SqlParserOptions.copyOf(sqlParserOptions); }
public static SqlParserOptions copyOf(SqlParserOptions other) { return new SqlParserOptions(other.allowedIdentifierSymbols, other.enhancedErrorHandlerEnabled); } }
public PrestoServer() { this(new SqlParserOptions()); }
public SqlParser() { this(new SqlParserOptions()); }
public PrestoServer() { this(new SqlParserOptions()); }
public SqlParser() { this(new SqlParserOptions()); }
private static TestingPrestoServer createTestingPrestoServer() throws Exception { ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder() .put("query.client.timeout", "10m") .put("exchange.http-client.idle-timeout", "1h") .put("node-scheduler.min-candidates", "1") .put("datasources", "system"); return new TestingPrestoServer(true, properties.build(), null, null, new SqlParserOptions(), ImmutableList.of()); } }
public TestingPrestoServer(boolean coordinator, Map<String, String> properties, String environment, URI discoveryUri, SqlParserOptions parserOptions, List<Module> additionalModules) throws Exception { this.coordinator = coordinator; baseDataDir = Files.createTempDirectory("PrestoTest"); properties = new HashMap<>(properties); String coordinatorPort = properties.remove("http-server.http.port"); if (coordinatorPort == null) { coordinatorPort = "0"; } ImmutableMap.Builder<String, String> serverProperties = ImmutableMap.<String, String>builder() .putAll(properties) .put("coordinator", String.valueOf(coordinator)) .put("presto.version", "testversion") .put("task.concurrency", "4") .put("task.max-worker-threads", "4") .put("exchange.client-threads", "4"); if (coordinator) { // TODO: enable failure detector serverProperties.put("failure-detector.enabled", "false"); }
public TestingPrestoServer(boolean coordinator, Map<String, String> properties, String environment, URI discoveryUri, SqlParserOptions parserOptions, List<Module> additionalModules) throws Exception { this.coordinator = coordinator; baseDataDir = Files.createTempDirectory("PrestoTest"); properties = new HashMap<>(properties); String coordinatorPort = properties.remove("http-server.http.port"); if (coordinatorPort == null) { coordinatorPort = "0"; } ImmutableMap.Builder<String, String> serverProperties = ImmutableMap.<String, String>builder() .putAll(properties) .put("coordinator", String.valueOf(coordinator)) .put("presto.version", "testversion") .put("task.concurrency", "4") .put("task.max-worker-threads", "4") .put("exchange.client-threads", "4"); if (coordinator) { // TODO: enable failure detector serverProperties.put("failure-detector.enabled", "false"); }
@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); }
@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); }