private static Map<String, String> mergeSessionAndCatalogProperties(SessionRepresentation session) { Map<String, String> mergedProperties = new LinkedHashMap<>(session.getSystemProperties()); // Either processed or unprocessed catalog properties, but not both. Instead of trying to enforces this while // firing events, allow both to be set and if there is a duplicate favor the processed properties. for (Map.Entry<String, Map<String, String>> catalogEntry : session.getUnprocessedCatalogProperties().entrySet()) { for (Map.Entry<String, String> entry : catalogEntry.getValue().entrySet()) { mergedProperties.put(catalogEntry.getKey() + "." + entry.getKey(), entry.getValue()); } } for (Map.Entry<ConnectorId, Map<String, String>> catalogEntry : session.getCatalogProperties().entrySet()) { for (Map.Entry<String, String> entry : catalogEntry.getValue().entrySet()) { mergedProperties.put(catalogEntry.getKey().getCatalogName() + "." + entry.getKey(), entry.getValue()); } } return ImmutableMap.copyOf(mergedProperties); }
@POST @Path("{taskId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createOrUpdateTask(@PathParam("taskId") TaskId taskId, TaskUpdateRequest taskUpdateRequest, @Context UriInfo uriInfo) { requireNonNull(taskUpdateRequest, "taskUpdateRequest is null"); Session session = taskUpdateRequest.getSession().toSession(sessionPropertyManager); TaskInfo taskInfo = taskManager.updateTask(session, taskId, taskUpdateRequest.getFragment(), taskUpdateRequest.getSources(), taskUpdateRequest.getOutputIds(), taskUpdateRequest.getTotalPartitions()); if (shouldSummarize(uriInfo)) { taskInfo = taskInfo.summarize(); } return Response.ok().entity(taskInfo).build(); }
public SessionRepresentation toSessionRepresentation() { return new SessionRepresentation( queryId.toString(), transactionId, clientTransactionSupport, identity.getUser(), identity.getPrincipal().map(Principal::toString), source, catalog, schema, path, traceToken, timeZoneKey, locale, remoteUserAddress, userAgent, clientInfo, clientTags, clientCapabilities, resourceEstimates, startTime, systemProperties, connectorProperties, unprocessedCatalogProperties, preparedStatements); }
private QueryContext createQueryContext(SessionRepresentation session, Optional<ResourceGroupId> resourceGroup) { return new QueryContext( session.getUser(), session.getPrincipal(), session.getRemoteUserAddress(), session.getUserAgent(), session.getClientInfo(), session.getClientTags(), session.getClientCapabilities(), session.getSource(), session.getCatalog(), session.getSchema(), resourceGroup, mergeSessionAndCatalogProperties(session), session.getResourceEstimates(), serverAddress, serverVersion, environment); }
private static QueryStateInfo createQueryStateInfo( BasicQueryInfo queryInfo, Optional<ResourceGroupId> groupId, Optional<List<ResourceGroupInfo>> pathToRoot, Optional<QueryProgressStats> progress) { return new QueryStateInfo( queryInfo.getQueryId(), queryInfo.getState(), groupId, queryInfo.getQuery(), queryInfo.getQueryStats().getCreateTime(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource(), queryInfo.getSession().getClientInfo(), queryInfo.getSession().getCatalog(), queryInfo.getSession().getSchema(), pathToRoot, progress); }
public void createdEvent(QueryInfo queryInfo) { eventClient.post( new QueryCreatedEvent( queryInfo.getQueryId(), queryInfo.getSession().getTransactionId().map(TransactionId::toString).orElse(null), queryInfo.getSession().getUser(), queryInfo.getSession().getPrincipal().orElse(null), queryInfo.getSession().getSource().orElse(null), serverVersion, environment, queryInfo.getSession().getCatalog().orElse(null), queryInfo.getSession().getSchema().orElse(null), queryInfo.getSession().getRemoteUserAddress().orElse(null), queryInfo.getSession().getUserAgent().orElse(null), queryInfo.getSelf(), queryInfo.getQuery(), queryInfo.getQueryStats().getCreateTime() ) ); }
assertEquals(queryInfo.getSession().getSystemProperties(), ImmutableMap.builder() .put(QUERY_MAX_MEMORY, "1GB") .put(JOIN_DISTRIBUTION_TYPE, "partitioned") assertEquals(queryInfo.getSession().getClientInfo().get(), "{\"clientVersion\":\"testVersion\"}"); assertEquals(queryInfo.getSession().getPreparedStatements(), ImmutableMap.builder() .put("foo", "select * from bar") .build());
assertEquals(queryInfo.getSession().getSystemProperties(), ImmutableMap.builder() .put(QUERY_MAX_MEMORY, "1GB") .put(DISTRIBUTED_JOIN, "true")
mergedProperties.putAll(queryInfo.getSession().getSystemProperties()); for (Map.Entry<String, Map<String, String>> catalogEntry : queryInfo.getSession().getCatalogProperties().entrySet()) { for (Map.Entry<String, String> entry : catalogEntry.getValue().entrySet()) { mergedProperties.put(catalogEntry.getKey() + "." + entry.getKey(), entry.getValue()); new QueryCompletionEvent( queryInfo.getQueryId(), queryInfo.getSession().getTransactionId().map(TransactionId::toString).orElse(null), queryInfo.getSession().getUser(), queryInfo.getSession().getPrincipal().orElse(null), queryInfo.getSession().getSource().orElse(null), serverVersion, environment, queryInfo.getSession().getCatalog().orElse(null), queryInfo.getSession().getSchema().orElse(null), queryInfo.getSession().getRemoteUserAddress().orElse(null), queryInfo.getSession().getUserAgent().orElse(null), queryInfo.getState(), queryInfo.getSelf(),
@Override public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession session, TupleDomain<Integer> constraint) { Builder table = InMemoryRecordSet.builder(QUERY_TABLE); for (QueryInfo queryInfo : queryManager.getAllQueryInfo()) { QueryStats queryStats = queryInfo.getQueryStats(); table.addRow( nodeId, queryInfo.getQueryId().toString(), queryInfo.getState().toString(), queryInfo.getSession().getUser(), queryInfo.getSession().getSource().orElse(null), queryInfo.getQuery(), toMillis(queryStats.getQueuedTime()), toMillis(queryStats.getAnalysisTime()), toMillis(queryStats.getDistributedPlanningTime()), toTimeStamp(queryStats.getCreateTime()), toTimeStamp(queryStats.getExecutionStartTime()), toTimeStamp(queryStats.getLastHeartbeat()), toTimeStamp(queryStats.getEndTime())); } return table.build().cursor(); }
private Optional<String> createTextQueryPlan(QueryInfo queryInfo) { try { if (queryInfo.getOutputStage().isPresent()) { return Optional.of(textDistributedPlan( queryInfo.getOutputStage().get(), functionRegistry, queryInfo.getSession().toSession(sessionPropertyManager), false)); } } catch (Exception e) { // Sometimes it is expected to fail. For example if generated plan is too long. // Don't fail to create event if the plan can not be created. log.warn(e, "Error creating explain plan for query %s", queryInfo.getQueryId()); } return Optional.empty(); }
public SessionRepresentation toSessionRepresentation() { return new SessionRepresentation( queryId.toString(), transactionId, clientTransactionSupport, identity.getUser(), identity.getPrincipal().map(Principal::toString), source, catalog, schema, timeZoneKey, locale, remoteUserAddress, userAgent, startTime, systemProperties, catalogProperties); }
defaultSession = defaultSession.toSessionRepresentation().toSession(coordinator.getMetadata().getSessionPropertyManager()); this.prestoClient = closer.register(new TestingPrestoClient(coordinator, defaultSession));
session = queryManager.getFullQueryInfo(queryId).getSession().toSession(sessionPropertyManager); serde = new PagesSerdeFactory(blockEncodingSerde, isExchangeCompressionEnabled(session)).createPagesSerde();
@POST @Path("{taskId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createOrUpdateTask(@PathParam("taskId") TaskId taskId, TaskUpdateRequest taskUpdateRequest, @Context UriInfo uriInfo) { requireNonNull(taskUpdateRequest, "taskUpdateRequest is null"); Session session = taskUpdateRequest.getSession().toSession(sessionPropertyManager); TaskInfo taskInfo = taskManager.updateTask(session, taskId, taskUpdateRequest.getFragment(), taskUpdateRequest.getSources(), taskUpdateRequest.getOutputIds()); if (shouldSummarize(uriInfo)) { taskInfo = taskInfo.summarize(); } return Response.ok().entity(taskInfo).build(); }
defaultSession = defaultSession.toSessionRepresentation().toSession(coordinator.getMetadata().getSessionPropertyManager()); this.prestoClient = closer.register(new TestingPrestoClient(coordinator, defaultSession));