001package gudusoft.gsqlparser.nodes; 002 003 004import gudusoft.gsqlparser.EUniqueRowFilterType; 005import gudusoft.gsqlparser.TBaseType; 006 007public class TSelectDistinct extends TParseTreeNode { 008 private int distinctType = TBaseType.dtNone; 009 private EUniqueRowFilterType uniqueRowFilter = EUniqueRowFilterType.urfNone; 010 011 public void setUniqueRowFilter(EUniqueRowFilterType uniqueRowFilter) { 012 this.uniqueRowFilter = uniqueRowFilter; 013 } 014 015 public EUniqueRowFilterType getUniqueRowFilter() { 016 017 return uniqueRowFilter; 018 } 019 020 private TExpressionList expressionList; 021 022 public TExpressionList getExpressionList() { 023 return expressionList; 024 } 025 026 public void setDistinctType(int distinctType) { 027 this.distinctType = distinctType; 028 } 029 030 public boolean isAll(){ 031 return uniqueRowFilter == EUniqueRowFilterType.urfAll; 032 } 033 034 /** 035 * @deprecated As of 1.7.3.3, replaced by {@link #getUniqueRowFilter()} 036 */ 037 public int getDistinctType() { 038 039 return distinctType; 040 } 041 042 public void init(Object arg1){ 043 this.expressionList = (TExpressionList)arg1; 044 } 045 046 public void setExpressionList(TExpressionList expressionList) { 047 this.expressionList = expressionList; 048 } 049 050 public void accept(TParseTreeVisitor v){ 051 v.preVisit(this); 052 v.postVisit(this); 053 } 054 055 public void acceptChildren(TParseTreeVisitor v){ 056 v.preVisit(this); 057 // Slice 73: descend into the DISTINCT ON expression list so 058 // visitor-based passes (resolver-2 ScopeBuilder, Semantic IR 059 // builder collectors) see the partition expressions. Without 060 // this, `SELECT DISTINCT ON (a) ...` leaves `a` invisible to 061 // any visitor walking from the enclosing TSelectSqlStatement, 062 // because TSelectSqlStatement.acceptChildren calls 063 // selectDistinct.acceptChildren but the latter previously did 064 // not recurse into expressionList. Delegates to 065 // TExpressionList.acceptChildren (inherited from 066 // TParseTreeNodeList), which iterates element children. 067 if (expressionList != null) { 068 expressionList.acceptChildren(v); 069 } 070 v.postVisit(this); 071 } 072}