package cn.aixunkeji.datagov.integration.tablefile; import cn.aixunkeji.datagov.integration.api.tablefile.*; import java.time.Instant; import java.nio.charset.StandardCharsets; import java.util.*; /** Actual production DATE arithmetic and compiler. Inputs and all source rows are synthetic. */ public final class BiRelativeWindowMysqlProbe { static String encode(String value){return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));} public static void main(String[] args){ var window=AnalyticsRelativeWindow.resolve(new AnalyticsQuery.RelativeWindow("day",args[0],Integer.parseInt(args[1]),args[2]),Instant.parse(args[3])); var filters=new ArrayList();filters.add(new AnalyticsQuery.Filter("tenant","EQ",List.of("fixture' OR 1=1 --")));if(args.length>4)filters.add(new AnalyticsQuery.Filter("day","GTE",List.of(args[4]))); var plan=new AnalyticsQuery.Plan(List.of(),List.of(),List.of(new AnalyticsQuery.Measure("amount","AVG","average"),new AnalyticsQuery.Measure("person","COUNT_DISTINCT","people")),List.copyOf(filters),List.of(),50,false,null,null,null,window); var compiled=AnalyticsSqlCompiler.compileForSource(plan,List.of("day","amount","person","tenant"),"MYSQL","aixun_datagov_system",null,"bi_relative_fixture"); if(!window.equals(compiled.relativeWindow()))throw new IllegalStateException("Frozen window metadata missing"); System.out.println(encode(compiled.sql()));System.out.println(String.join(",",compiled.parameters().stream().map(BiRelativeWindowMysqlProbe::encode).toList()));System.out.println(String.join(",",compiled.columns()));System.out.println(window.referenceDate()+","+window.startDate()+","+window.endDateExclusive()); } }