@Override public QueryExecution query(RequestContext context, List<FunnelStep> steps, Optional<String> dimension, Optional<String> segment, LocalDate startDate, LocalDate endDate, Optional<FunnelWindow> window, ZoneId zoneId, Optional<List<String>> connectors, FunnelType funnelType) { if (funnelType == FunnelType.APPROXIMATE) { return approxFunnelQueryExecutor.query(context, steps, dimension, segment, startDate, endDate, window, zoneId, connectors, funnelType); } if (funnelType != FunnelType.ORDERED) { return fastPrestoFunnelQueryExecutor.query(context, steps, dimension, segment, startDate, endDate, window, zoneId, connectors, funnelType); } if (dimension.isPresent() && projectConfig.getUserColumn().equals(dimension.get())) { throw new RakamException("Dimension and connector field cannot be equal", HttpResponseStatus.BAD_REQUEST); } return super.query(context, steps, dimension, segment, startDate, endDate, window, zoneId, connectors, funnelType); }
@Inject public PrestoFunnelQueryExecutor( ProjectConfig projectConfig, PrestoConfig prestoConfig, FastGenericFunnelQueryExecutor fastPrestoFunnelQueryExecutor, PrestoApproxFunnelQueryExecutor approxFunnelQueryExecutor, Metastore metastore, QueryExecutor executor, UserPluginConfig userPluginConfig) { super(projectConfig, metastore, executor); this.prestoConfig = prestoConfig; this.fastPrestoFunnelQueryExecutor = fastPrestoFunnelQueryExecutor; this.approxFunnelQueryExecutor = approxFunnelQueryExecutor; this.userMappingEnabled = userPluginConfig.getEnableUserMapping(); this.fastPrestoFunnelQueryExecutor.setTimeStampMapping(timeStampMapping); this.approxFunnelQueryExecutor.setTimeStampMapping(timeStampMapping); super.timeStampMapping = timeStampMapping; }
if (dimension.isPresent()) { String queries = IntStream.range(0, steps.size()).mapToObj(step -> String.format("(select %s as dimension, %s as _user, %d as step from %s where %s between timestamp '%s' and timestamp '%s' and %s)", dimension.map(ValidationUtil::checkTableColumn).map(v -> segment.isPresent() ? applySegment(v, segment) : v).orElse(""), checkTableColumn(projectConfig.getUserColumn()), step, checkCollection(steps.get(step).getCollection()), checkTableColumn(projectConfig.getTimeColumn()), startDateStr, endDateStr, getFilterExp(steps.get(step)))).collect(Collectors.joining(" union all ")); checkCollection(step.getCollection()), checkTableColumn(projectConfig.getTimeColumn()), startDateStr, endDateStr, getFilterExp(step))) .collect(Collectors.joining(", "));
@BeforeSuite @Override public void setup() throws Exception { testingEnvironment = new TestingEnvironment(); PrestoConfig prestoConfig = testingEnvironment.getPrestoConfig(); InMemoryQueryMetadataStore inMemoryQueryMetadataStore = new InMemoryQueryMetadataStore(); JDBCPoolDataSource prestoMetastore = testingEnvironment.getPrestoMetastore(); EventBus eventBus = new EventBus(); metastore = new PrestoRakamRaptorMetastore(prestoMetastore, eventBus, new ProjectConfig(), prestoConfig); metastore.setup(); PrestoQueryExecutor prestoQueryExecutor = new PrestoQueryExecutor(new ProjectConfig(), prestoConfig, null, metastore); PrestoMaterializedViewService materializedViewService = new PrestoMaterializedViewService( new PrestoConfig(), prestoQueryExecutor, metastore, inMemoryQueryMetadataStore, Clock.systemUTC()); QueryExecutorService queryExecutorService = new QueryExecutorService(prestoQueryExecutor, metastore, materializedViewService, '"'); FastGenericFunnelQueryExecutor fastGenericFunnelQueryExecutor = new FastGenericFunnelQueryExecutor(queryExecutorService, new ProjectConfig(), metastore); PrestoApproxFunnelQueryExecutor prestoApproxFunnelQueryExecutor = new PrestoApproxFunnelQueryExecutor(new ProjectConfig(), queryExecutorService, metastore); funnelQueryExecutor = new PrestoFunnelQueryExecutor(new ProjectConfig(), new PrestoConfig(), fastGenericFunnelQueryExecutor, prestoApproxFunnelQueryExecutor, metastore, prestoQueryExecutor, new UserPluginConfig()); testingPrestoEventStore = new TestingPrestoEventStore(prestoQueryExecutor, prestoConfig); super.setup(); }