@Override public Session getDefaultSession() { return prestoClient.getDefaultSession(); }
private static Function<List<Object>, MaterializedRow> dataToRow(final List<Type> types) { return data -> { checkArgument(data.size() == types.size(), "columns size does not match types size"); List<Object> row = new ArrayList<>(); for (int i = 0; i < data.size(); i++) { Object value = data.get(i); Type type = types.get(i); row.add(convertToRowValue(type, value)); } return new MaterializedRow(DEFAULT_PRECISION, row); }; }
public ResultWithQueryId<MaterializedResult> executeWithQueryId(Session session, @Language("SQL") String sql) { lock.readLock().lock(); try { return prestoClient.execute(session, sql); } finally { lock.readLock().unlock(); } }
public static void loadTpchTable(EmbeddedRedis embeddedRedis, TestingPrestoClient prestoClient, String tableName, QualifiedObjectName tpchTableName, String dataFormat) { RedisLoader tpchLoader = new RedisLoader(prestoClient.getServer(), prestoClient.getDefaultSession(), embeddedRedis.getJedisPool(), tableName, dataFormat); tpchLoader.execute(format("SELECT * from %s", tpchTableName)); }
@Override public List<QualifiedObjectName> listTables(Session session, String catalog, String schema) { lock.readLock().lock(); try { return prestoClient.listTables(session, catalog, schema); } finally { lock.readLock().unlock(); } }
this.prestoClient = closer.register(new TestingPrestoClient(coordinator, defaultSession));
@Override public void addResults(QueryStatusInfo statusInfo, QueryData data) { if (!loggedUri.getAndSet(true)) { log.info("Query %s: %s", statusInfo.getId(), statusInfo.getInfoUri()); } if (types.get() == null && statusInfo.getColumns() != null) { types.set(getTypes(statusInfo.getColumns())); } if (data.getData() != null) { checkState(types.get() != null, "data received without types"); rows.addAll(transform(data.getData(), dataToRow(types.get()))); } }
public static void loadTpchTopic(EmbeddedKafka embeddedKafka, TestingPrestoClient prestoClient, String topicName, QualifiedObjectName tpchTableName) { try (CloseableProducer<Long, Object> producer = embeddedKafka.createProducer(); KafkaLoader tpchLoader = new KafkaLoader(producer, topicName, prestoClient.getServer(), prestoClient.getDefaultSession())) { tpchLoader.execute(format("SELECT * from %s", tpchTableName)); } }
@Override public List<QualifiedObjectName> listTables(Session session, String catalog, String schema) { lock.readLock().lock(); try { return prestoClient.listTables(session, catalog, schema); } finally { lock.readLock().unlock(); } }
public StandaloneQueryRunner(Session defaultSession) throws Exception { requireNonNull(defaultSession, "defaultSession is null"); try { server = createTestingPrestoServer(); } catch (Exception e) { close(); throw e; } this.prestoClient = new TestingPrestoClient(server, defaultSession); refreshNodes(); server.getMetadata().addFunctions(AbstractTestQueries.CUSTOM_FUNCTIONS); SessionPropertyManager sessionPropertyManager = server.getMetadata().getSessionPropertyManager(); sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES); sessionPropertyManager.addConnectorSessionProperties(new ConnectorId("catalog"), TEST_CATALOG_PROPERTIES); }
@Override public void addResults(QueryStatusInfo statusInfo, QueryData data) { if (!loggedUri.getAndSet(true)) { log.info("Query %s: %s", statusInfo.getId(), statusInfo.getInfoUri()); } if (types.get() == null && statusInfo.getColumns() != null) { types.set(getTypes(statusInfo.getColumns())); } if (data.getData() != null) { checkState(types.get() != null, "data received without types"); rows.addAll(transform(data.getData(), dataToRow(types.get()))); } }
private static void loadTpchTopic(EmbeddedElasticsearchNode embeddedElasticsearchNode, TestingPrestoClient prestoClient, TpchTable<?> table) { long start = System.nanoTime(); LOG.info("Running import for %s", table.getTableName()); ElasticsearchLoader loader = new ElasticsearchLoader(embeddedElasticsearchNode.getClient(), table.getTableName().toLowerCase(ENGLISH), prestoClient.getServer(), prestoClient.getDefaultSession()); loader.execute(format("SELECT * from %s", new QualifiedObjectName(TPCH_SCHEMA, TINY_SCHEMA_NAME, table.getTableName().toLowerCase(ENGLISH)))); LOG.info("Imported %s in %s", table.getTableName(), nanosSince(start).convertToMostSuccinctTimeUnit()); }
@Override public Session getDefaultSession() { return prestoClient.getDefaultSession(); }
@Override public MaterializedResult execute(Session session, @Language("SQL") String sql) { lock.readLock().lock(); try { return prestoClient.execute(session, sql).getResult(); } finally { lock.readLock().unlock(); } }
@Override public List<QualifiedObjectName> listTables(Session session, String catalog, String schema) { lock.readLock().lock(); try { return prestoClient.listTables(session, catalog, schema); } finally { lock.readLock().unlock(); } }
.map(element -> convertToRowValue(((ArrayType) type).getElementType(), element)) .collect(toList()); return ((Map<Object, Object>) value).entrySet().stream() .collect(Collectors.toMap( e -> convertToRowValue(((MapType) type).getKeyType(), e.getKey()), e -> convertToRowValue(((MapType) type).getValueType(), e.getValue())));
this.prestoClient = closer.register(new TestingPrestoClient(coordinator, defaultSession));
@Override public Session getDefaultSession() { return prestoClient.getDefaultSession(); }
@Override public MaterializedResult execute(Session session, @Language("SQL") String sql) { lock.readLock().lock(); try { return prestoClient.execute(session, sql).getResult(); } finally { lock.readLock().unlock(); } }
@Override public List<QualifiedObjectName> listTables(Session session, String catalog, String schema) { lock.readLock().lock(); try { return prestoClient.listTables(session, catalog, schema); } finally { lock.readLock().unlock(); } }