/** * Returns partitions for the given start and end date. * * @param startDate the start date. * @param endDate the end date. * @return partitions for the given start and end date. */ public static Partitions getPartitions( Date startDate, Date endDate ) { Period period = new Period(); period.setStartDate( startDate ); period.setEndDate( endDate ); return getPartitions( period ); }
@Override public DataQueryParams withTableNameAndPartitions( DataQueryParams params, QueryPlannerParams plannerParams ) { Partitions partitions = params.hasStartEndDate() ? PartitionUtils.getPartitions( params.getStartDate(), params.getEndDate() ) : PartitionUtils.getPartitions( params.getAllPeriods() ); return DataQueryParams.newBuilder( params ) .withTableName( plannerParams.getTableName() ) .withPartitions( partitions ) .build(); }
/** * Sets table name and partitions on the given query. * * @param params the event query parameters. * @return a {@link EventQueryParams}. */ private EventQueryParams withTableNameAndPartitions( EventQueryParams params ) { Partitions partitions = params.hasStartEndDate() ? PartitionUtils.getPartitions( params.getStartDate(), params.getEndDate() ) : PartitionUtils.getPartitions( params.getAllPeriods() ); String baseName = params.hasEnrollmentProgramIndicatorDimension() ? AnalyticsTableType.ENROLLMENT.getTableName() : AnalyticsTableType.EVENT.getTableName(); String tableName = PartitionUtils.getTableName( baseName, params.getProgram() ); return new EventQueryParams.Builder( params ) .withTableName( tableName ) .withPartitions( partitions ) .build(); }