public PrestoQueryExecution internalExecuteRawQuery(RequestContext context, String query, ClientSession clientSession, boolean update) { return new PrestoQueryExecution(clientSession, query, update); }
return TIMESTAMP; case StandardTypes.ARRAY: return fromPrestoType(parameter.next(), null).convertToArrayType(); case StandardTypes.MAP: Preconditions.checkArgument(parameter.next().equals(StandardTypes.VARCHAR), "The first parameter of MAP must be STRING"); return fromPrestoType(parameter.next(), null).convertToMapValueType(); default: return BINARY;
QueryResult queryResult = new PrestoQueryExecution(defaultSession, getNodeCount, false).getResult().join(); if (queryResult.isFailed()) { throw new RakamException(queryResult.getError().message, SERVICE_UNAVAILABLE);
prestoConfig.getColdStorageConnector(), project, checkCollection(collection), queryEnd, properties); QueryResult join = new PrestoQueryExecution(defaultSession, query, false).getResult().join(); if (join.isFailed()) { if (join.getError().message.contains("exists") || join.getError().message.equals(METADATA_ERROR)) { if (isServerInactive(join.getError())) { throw new RakamException("Database is not active", BAD_GATEWAY);
@Override public void deleteProject(String project) { checkProject(project); try (Handle handle = dbi.open()) { handle.createStatement("delete from project where name = :project") .bind("project", project).execute(); } for (String collectionName : getCollectionNames(project)) { String query = format("DROP TABLE %s.\"%s\".\"%s\"", prestoConfig.getColdStorageConnector(), project, collectionName); QueryResult join = new PrestoQueryExecution(defaultSession, query, true).getResult().join(); if (join.isFailed()) { LOGGER.error("Error while deleting table %s.%s : %s", project, collectionName, join.getError().toString()); } } super.onDeleteProject(project); }
CompletableFuture<QueryResult> result = new PrestoQueryExecution(defaultSession, prestoQuery, true).getResult(); return result.thenApply(v -> { if (v.isFailed()) {
public FieldType fromPrestoType(String name) { TypeSignature typeSignature = TypeSignature.parseTypeSignature(name); return PrestoQueryExecution.fromPrestoType(typeSignature.getBase(), typeSignature.getParameters().stream() .filter(param -> param.getKind() == TYPE) .map(param -> param.getTypeSignature().getBase()).iterator()); }
@Override public List<SchemaField> getCollection(String project, String collection) { return dao.listTableColumns(project, collection).stream() // this field should be removed since the server sets it .filter(a -> !a.getColumnName().equals(prestoConfig.getCheckpointColumn())) .map(column -> { TypeSignature typeSignature = column.getDataType().getTypeSignature(); return new SchemaField(column.getColumnName(), PrestoQueryExecution.fromPrestoType(typeSignature.getBase(), typeSignature.getParameters().stream() .filter(param -> param.getKind() == TYPE) .map(param -> param.getTypeSignature().getBase()).iterator())); }).collect(Collectors.toList()); }
public Map<String, List<SchemaField>> getTables(String project, BiPredicate<String, String> filter) { HashMap<String, List<SchemaField>> map = new HashMap<>(); for (TableColumn tableColumn : dao.listTableColumns(project, null)) { if (tableColumn.getColumnName().startsWith("$") || !filter.test(tableColumn.getTable().getTableName(), tableColumn.getColumnName())) { continue; } TypeSignature typeSignature = tableColumn.getDataType().getTypeSignature(); FieldType fieldType = PrestoQueryExecution.fromPrestoType(typeSignature.getBase(), typeSignature.getParameters().stream() .filter(param -> param.getKind() == TYPE) .map(param -> param.getTypeSignature().getBase()).iterator()); SchemaField column = new SchemaField(tableColumn.getColumnName(), fieldType); map.computeIfAbsent(tableColumn.getTable().getTableName(), key -> new ArrayList()).add(column); } return map; }
.map(c -> { List<ClientTypeSignatureParameter> arguments = c.getTypeSignature().getArguments(); return new SchemaField(c.getName(), fromPrestoType(c.getTypeSignature().getRawType(), arguments.stream() .filter(argument -> argument.getKind() == com.facebook.presto.spi.type.ParameterKind.TYPE)