static ClientSession processSessionParameterChange( Object parsedStatement, ClientSession session) { if (parsedStatement instanceof Use) { Use use = (Use) parsedStatement; return ClientSession.withCatalogAndSchema( session, use.getCatalog().orElse(session.getCatalog()), use.getSchema()); } return session; }
private static Request buildQueryRequest(ClientSession session, String query) { Request.Builder builder = preparePost() .setUri(uriBuilderFrom(session.getServer()).replacePath("/v1/execute").build()) .setBodyGenerator(createStaticBodyGenerator(query, Charsets.UTF_8)); if (session.getUser() != null) { builder.setHeader(PrestoHeaders.PRESTO_USER, session.getUser()); } if (session.getSource() != null) { builder.setHeader(PrestoHeaders.PRESTO_SOURCE, session.getSource()); } if (session.getCatalog() != null) { builder.setHeader(PrestoHeaders.PRESTO_CATALOG, session.getCatalog()); } if (session.getSchema() != null) { builder.setHeader(PrestoHeaders.PRESTO_SCHEMA, session.getSchema()); } builder.setHeader(PrestoHeaders.PRESTO_SCHEMA, session.getTimeZoneId()); builder.setHeader(USER_AGENT, USER_AGENT_VALUE); return builder.build(); }