@@ -37,6 +37,7 @@ public class PlainSelect extends Select {
3737 private FromItem fromItem ;
3838 private List <LateralView > lateralViews ;
3939 private List <Join > joins ;
40+ private Expression preWhere ;
4041 private Expression where ;
4142 private GroupByElement groupBy ;
4243 private Expression having ;
@@ -160,6 +161,14 @@ public void setWhere(Expression where) {
160161 this .where = where ;
161162 }
162163
164+ public Expression getPreWhere () {
165+ return preWhere ;
166+ }
167+
168+ public void setPreWhere (Expression preWhere ) {
169+ this .preWhere = preWhere ;
170+ }
171+
163172 public PlainSelect withFromItem (FromItem item ) {
164173 this .setFromItem (item );
165174 return this ;
@@ -569,6 +578,9 @@ public StringBuilder appendSelectBodyTo(StringBuilder builder) {
569578 if (ksqlWindow != null ) {
570579 builder .append (" WINDOW " ).append (ksqlWindow );
571580 }
581+ if (preWhere != null ) {
582+ builder .append (" PREWHERE " ).append (preWhere );
583+ }
572584 if (where != null ) {
573585 builder .append (" WHERE " ).append (where );
574586 }
@@ -597,6 +609,9 @@ public StringBuilder appendSelectBodyTo(StringBuilder builder) {
597609 }
598610 } else {
599611 // without from
612+ if (preWhere != null ) {
613+ builder .append (" PREWHERE " ).append (preWhere );
614+ }
600615 if (where != null ) {
601616 builder .append (" WHERE " ).append (where );
602617 }
@@ -669,6 +684,11 @@ public PlainSelect withWhere(Expression where) {
669684 return this ;
670685 }
671686
687+ public PlainSelect withPreWhere (Expression preWhere ) {
688+ this .setPreWhere (preWhere );
689+ return this ;
690+ }
691+
672692 public PlainSelect withOptimizeFor (OptimizeFor optimizeFor ) {
673693 this .setOptimizeFor (optimizeFor );
674694 return this ;
@@ -767,6 +787,10 @@ public <E extends Expression> E getWhere(Class<E> type) {
767787 return type .cast (getWhere ());
768788 }
769789
790+ public <E extends Expression > E getPreWhere (Class <E > type ) {
791+ return type .cast (getPreWhere ());
792+ }
793+
770794 public <E extends Expression > E getHaving (Class <E > type ) {
771795 return type .cast (getHaving ());
772796 }
0 commit comments