001package gudusoft.gsqlparser.nodes;
002
003import gudusoft.gsqlparser.*;
004import gudusoft.gsqlparser.compiler.*;
005import gudusoft.gsqlparser.nodes.couchbase.*;
006import gudusoft.gsqlparser.nodes.hive.THiveVariable;
007import gudusoft.gsqlparser.nodes.teradata.TDataConversion;
008import gudusoft.gsqlparser.stmt.TSelectSqlStatement;
009import gudusoft.gsqlparser.sqlenv.ESQLDataObjectType;
010import gudusoft.gsqlparser.util.SQLUtil;
011
012import java.util.ArrayDeque;
013import java.util.ArrayList;
014import java.util.Deque;
015import java.util.Stack;
016
017
018class calculateExprVisitor implements IExpressionVisitor {
019
020    TCustomSqlStatement sqlStatement;
021
022    Stack<TFrame> frameStack;
023
024    public calculateExprVisitor(Stack<TFrame> pframeStack, TCustomSqlStatement pSqlStatement){
025        sqlStatement = pSqlStatement;
026        this.frameStack = pframeStack;
027    }
028
029    Stack<TExpression> expressionStack = new Stack<>();
030
031    void evaluateLeafExpr(TExpression expr){
032        String plainText = expr.getPlainText();
033
034        switch (expr.getExpressionType()){
035            case simple_constant_t:
036                TConstant constant = expr.getConstantOperand();
037                switch (constant.getLiteralType()){
038                    case etString:
039                        plainText = TBaseType.getStringInsideLiteral(plainText);
040                        expr.setVal(plainText);
041                        expr.setDataType(TPrimitiveType.String);
042                        if (constant.getStartToken() != null){
043                           expr.setPlainTextLineNo(constant.getStartToken().lineNo);
044                           expr.setPlainTextColumnNo(constant.getStartToken().columnNo);
045                        }
046
047                        break;
048                    case etNumber:
049                        break;
050                }
051                break;
052            case function_t:
053                plainText = expr.getFunctionCall().getFunctionName().toString();
054                expr.setPlainTextLineNo(expr.getFunctionCall().getFunctionName().getStartToken().lineNo);
055                expr.setPlainTextColumnNo(expr.getFunctionCall().getFunctionName().getStartToken().columnNo);
056                break;
057            case simple_object_name_t:
058                boolean getValueFromVar = false;
059                TVariable symbolVariable =  TSymbolTableManager.searchSymbolVariable(frameStack,plainText);
060                if (symbolVariable != null){
061                    if (symbolVariable.getVariableStr() != null){
062                        plainText = symbolVariable.getVariableStr();
063                        expr.setPlainTextLineNo( symbolVariable.getLineNo());
064                        expr.setPlainTextColumnNo(symbolVariable.getColumnNo());
065                        getValueFromVar = true;
066                        // variableStr is only recorded for resolved string values,
067                        // so a successful lookup carries a real value
068                        expr.setVal(plainText);
069                        expr.setValPartial(symbolVariable.isVariableStrPartial());
070                        //System.out.println("variable name:"+symbolVariable.getName()+", value: "+plainText);
071                    }
072                }
073                if (!getValueFromVar){
074                    plainText = plainText.replace(".", "_");
075                }
076
077//                if (expr.getObjectOperand().getDbObjectType() == EDbObjectType.variable){
078//                }else {
079//                    plainText = plainText.replace(".", "_");
080//                }
081
082                break;
083            case case_t:
084                TExpression resultExpr = expr.getCaseExpression().getWhenClauseItemList().getWhenClauseItem(0).getReturn_expr();
085                resultExpr.evaluate(frameStack,sqlStatement);
086                plainText = resultExpr.getPlainText();
087                expr.setVal(resultExpr.getVal());
088                expr.setValPartial(resultExpr.isValPartial());
089
090                //System.out.println(plainText);
091                break;
092            default:
093                break;
094        }
095
096          expr.setPlainText(plainText);
097    }
098
099    public boolean exprVisit(TParseTreeNode pNode, boolean isLeafNode){
100        if (isLeafNode){
101            evaluateLeafExpr(((TExpression)pNode));
102            expressionStack.push((TExpression)pNode);
103        }
104
105        TExpression expr = (TExpression)pNode;
106        switch (expr.getExpressionType()){
107            case concatenate_t:
108            case arithmetic_plus_t:
109                TExpression expr1 = expressionStack.pop();
110                TExpression expr2 = expressionStack.pop();
111                ((TExpression)pNode).setPlainText(expr2.getPlainText() + expr1.getPlainText());
112                // a concatenation carries a real string value when at least one
113                // operand resolved to one; unresolved operands stay in the text
114                // as placeholder identifiers (e.g. 'WHERE id = ' || v_id) and
115                // mark the value as partially resolved
116                if (expr1.getVal() != null || expr2.getVal() != null){
117                    ((TExpression)pNode).setVal(expr2.getPlainText() + expr1.getPlainText());
118                    ((TExpression)pNode).setValPartial(expr1.getVal() == null || expr2.getVal() == null
119                            || expr1.isValPartial() || expr2.isValPartial());
120                }
121                expressionStack.push((TExpression)pNode);
122                break;
123        }
124        return true;
125    };
126
127}
128
129class columnVisitor extends TParseTreeVisitor {
130    ArrayList<TObjectName> columns;
131
132    public columnVisitor( ArrayList<TObjectName> columnsInsideExpression){
133        columns = columnsInsideExpression;
134    }
135
136    @Override
137    public void preVisit(TObjectName node) {
138        if (node.getDbObjectType() == EDbObjectType.column){
139            columns.add(node);
140        }
141    }
142
143//    public boolean exprVisit(TParseTreeNode pNode,boolean isLeafNode){
144//        TExpression expr = (TExpression)pNode;
145//        switch (expr.getExpressionType()){
146//            case simple_object_name_t:
147//                columns.add(expr.getObjectOperand());
148//                break;
149//            case function_t:
150//                if (expr.getFunctionCall().getArgs() != null){
151//                    for(int i=0;i<expr.getFunctionCall().getArgs().size();i++){
152//                        ArrayList<TObjectName>  list = expr.getFunctionCall().getArgs().getExpression(i).getColumnsInsideExpression();
153//                        for(int j=0;j<list.size();j++){
154//                            columns.add(list.get(j));
155//                        }
156//                    }
157//                }
158//                break;
159//            default:
160//                break;
161//        }
162//        return true;
163//    };
164}
165
166
167/**
168 * @deprecated As of v2.0.5.6, use class ColumnVisitor in package demos.columnInWhereClause instead.
169 */
170class searchColumnVisitor implements IExpressionVisitor {
171    private TExpressionList _resultList;
172    private String _targetColumn;
173
174    public searchColumnVisitor(String targetColumn, TExpressionList resultList){
175        _resultList = resultList;
176        _targetColumn = targetColumn;
177    }
178
179    public boolean exprVisit(TParseTreeNode pNode,boolean isLeafNode){
180        TExpression expr = (TExpression)pNode;
181        if (expr.getExpressionType() == EExpressionType.simple_object_name_t){
182            if (_targetColumn.contains(".")){
183                if (SQLUtil.compareIdentifier(expr.dbvendor, ESQLDataObjectType.dotColumn, _targetColumn, expr.getObjectOperand().toString())){
184                    _resultList.addExpression(expr);
185                }
186            }else{
187                if (SQLUtil.sameName(expr.dbvendor, ESQLDataObjectType.dotColumn, _targetColumn, expr.getObjectOperand().getColumnNameOnly())){
188                    _resultList.addExpression(expr);
189                }
190            }
191        }else if ((expr.getExpressionType() == EExpressionType.function_t)&&(expr.getFunctionCall().getArgs() != null)){
192            if (expr.getFunctionCall().getArgs().size() > 0){
193                TExpressionList list1;
194                for(int i=0;i<expr.getFunctionCall().getArgs().size();i++){
195                    list1 = expr.getFunctionCall().getArgs().getExpression(i).searchColumn(_targetColumn);
196                    if (list1.size() > 0){
197                        for(int j=0;j<list1.size();j++){
198                            _resultList.addExpression(list1.getExpression(j));
199                        }
200                    }
201                }
202                //expr.getFunctionCall().getArgs().getExpression(0).
203            }
204        }
205        return true;
206    };
207}
208
209class TFlattenVisitor implements IExpressionVisitor {
210
211    private ArrayList flattedAndOrExprs = new ArrayList();
212
213    public ArrayList getFlattedAndOrExprs() {
214        return flattedAndOrExprs;
215    }
216
217    public boolean exprVisit(TParseTreeNode pNode,boolean isLeafNode){
218        TExpression expr = (TExpression)pNode;
219        if (isLeafNode) flattedAndOrExprs.add(expr);
220        return true;
221    }
222
223}
224
225/**
226* An expression is a combination of one or more values, operators, and SQL functions that evaluates to a value.
227* There are lots of types of expression in this SQL parser, {@link #getExpressionType()} was used to distinguish these types.
228 *
229 * <p>
230 *     OBJECT NAME/CONSTANT/SOURCE TOKEN/FUNCTION CALL
231 *     <ul>
232  *         <li>object name, usually this is a column reference like emp.ename
233  *         <ul>
234   *             <li>type: {@link EExpressionType#simple_object_name_t}</li>
235 *               <li>object name: {@link #getObjectOperand()}</li>
236   *             <li>left operand:  N/A</li>
237   *             <li>right operand: N/A </li>
238   *             <li>operator: N/A </li>
239   *             </ul>
240   *         </li>
241 *         <li>constant
242 *         <ul>
243  *             <li>type: {@link EExpressionType#simple_constant_t}</li>
244*               <li>constant: {@link #getConstantOperand()}</li>
245  *             <li>left operand:  N/A</li>
246  *             <li>right operand: N/A </li>
247  *             <li>operator: N/A </li>
248  *             </ul>
249  *         </li>
250 *         <li>sourcetoken
251 *         <ul>
252  *             <li>type: {@link EExpressionType#simple_source_token_t}</li>
253*               <li>source token: {@link #getSourcetokenOperand()}</li>
254  *             <li>left operand:  N/A</li>
255  *             <li>right operand: N/A </li>
256  *             <li>operator: N/A </li>
257  *             </ul>
258  *         </li>
259 *         <li>function call
260 *         <ul>
261  *             <li>type: {@link EExpressionType#function_t}</li>
262*               <li>funcation call: {@link #getFunctionCall()}</li>
263  *             <li>left operand:  N/A</li>
264  *             <li>right operand: N/A </li>
265  *             <li>operator: N/A </li>
266  *             </ul>
267  *         </li>
268  *         </ul>
269 *
270 *     UNARY
271 *     <ul>
272 *         <li>  + expr1
273 *         <ul>
274  *             <li>type: {@link EExpressionType#unary_plus_t}</li>
275  *             <li>left operand:  N/A</li>
276  *             <li>right operand: getRightOperand</li>
277  *             <li>operator: {@link #getOperatorToken()}</li>
278  *             </ul>
279  *         </li>
280 *         <li>  - expr1
281 *         <ul>
282  *             <li>type: {@link EExpressionType#unary_minus_t}</li>
283 *             <li>left operand:  N/A</li>
284 *             <li>right operand: getRightOperand</li>
285 *             <li>operator: {@link #getOperatorToken()}</li>
286  *             </ul>
287  *         </li>
288 *         <li>  expr1 !
289 *         <ul>
290  *             <li>type: {@link EExpressionType#unary_factorial_t}</li>
291 *             <li>left operand:  {@link #getLeftOperand()}</li>
292 *             <li>right operand: N/A</li>
293 *             <li>operator: {@link #getOperatorToken()}</li>
294  *             </ul>
295  *         </li>
296 *         <li>  ~ expr1
297 *         <ul>
298  *             <li>type: {@link EExpressionType#unary_bitwise_not_t}</li>
299 *             <li>left operand:  N/A</li>
300 *             <li>right operand: {@link #getRightOperand()}</li>
301 *             <li>operator: {@link #getOperatorToken()}</li>
302  *             </ul>
303  *         </li>
304 *         <li>  @ expr1
305 *         <ul>
306  *             <li>type: {@link EExpressionType#unary_absolutevalue_t}</li>
307 *             <li>left operand:  N/A</li>
308 *             <li>right operand: {@link #getRightOperand()}</li>
309 *             <li>operator: {@link #getOperatorToken()}</li>
310  *             </ul>
311  *         </li>
312 *         <li>  |/ expr1
313 *         <ul>
314  *             <li>type: {@link EExpressionType#unary_squareroot_t}</li>
315 *             <li>left operand:  N/A</li>
316 *             <li>right operand: {@link #getRightOperand()}</li>
317 *             <li>operator: {@link #getOperatorToken()}</li>
318  *             </ul>
319  *         </li>
320 *         <li>  ||/ expr1
321 *         <ul>
322  *             <li>type: {@link EExpressionType#unary_cuberoot_t}</li>
323 *             <li>left operand:  N/A</li>
324 *             <li>right operand: {@link #getRightOperand()}</li>
325 *             <li>operator: {@link #getOperatorToken()}</li>
326  *             </ul>
327  *         </li>
328 *         <li>  !! expr1
329 *         <ul>
330  *             <li>type: {@link EExpressionType#unary_factorialprefix_t}</li>
331 *             <li>left operand:  N/A</li>
332 *             <li>right operand: {@link #getRightOperand()}</li>
333 *             <li>operator: {@link #getOperatorToken()}</li>
334  *             </ul>
335  *         </li>
336 *         <li>  Oracle: PRIOR expr1
337 *         <ul>
338  *             <li>type: {@link EExpressionType#unary_prior_t}</li>
339 *             <li>left operand:  N/A</li>
340 *             <li>right operand: getRightOperand</li>
341 *             <li>operator: {@link #getOperatorToken()}</li>
342  *             </ul>
343  *         </li>
344 *         <li>  Oracle: CONNECT_BY_ROOT expr1
345 *         <ul>
346  *             <li>type: {@link EExpressionType#unary_connect_by_root_t}</li>
347 *             <li>left operand:  N/A</li>
348 *             <li>right operand: getRightOperand</li>
349 *             <li>operator: {@link #getOperatorToken()}</li>
350  *             </ul>
351  *         </li>
352 *         <li>  MySQL: BINARY expr1
353 *         <ul>
354  *             <li>type: {@link EExpressionType#unary_prior_t}</li>
355 *             <li>left operand:  N/A</li>
356 *             <li>right operand: getRightOperand</li>
357 *             <li>operator: {@link #getOperatorToken()}</li>
358  *             </ul>
359  *         </li>
360 *         </ul>
361 *
362 *     ARITHMETIC
363 *     <ul>
364 *         <li>Addition: expr1 + expr2
365 *         <ul>
366 *             <li>type: {@link EExpressionType#arithmetic_plus_t}</li>
367 *             <li>left operand:  {@link #getLeftOperand()}</li>
368 *             <li>right operand: {@link #getRightOperand()} </li>
369 *             <li>operator: {@link #getOperatorToken()} </li>
370 *             </ul>
371 *         </li>
372 *         <li>Subtraction: expr1 - expr2
373 *         <ul>
374 *             <li>type: {@link EExpressionType#arithmetic_minus_t}</li>
375 *             <li>left operand:  {@link #getLeftOperand()}</li>
376 *             <li>right operand: {@link #getRightOperand()} </li>
377 *             <li>operator: {@link #getOperatorToken()} </li>
378 *             </ul>
379 *         </li>
380 *         <li>Multiplication: expr1 * expr2
381 *         <ul>
382 *             <li>type: {@link EExpressionType#arithmetic_times_t}</li>
383 *             <li>left operand:  {@link #getLeftOperand()}</li>
384 *             <li>right operand: {@link #getRightOperand()} </li>
385 *             <li>operator: {@link #getOperatorToken()} </li>
386 *             </ul>
387 *         </li>
388 *         <li>Division: expr1 / expr2
389 *         <ul>
390 *             <li>type: {@link EExpressionType#arithmetic_divide_t}</li>
391 *             <li>left operand:  {@link #getLeftOperand()}</li>
392 *             <li>right operand: {@link #getRightOperand()} </li>
393 *             <li>operator: {@link #getOperatorToken()} </li>
394 *             </ul>
395 *         </li>
396 *         <li>Modula: expr1 % expr2
397 *         <ul>
398 *             <li>type: {@link EExpressionType#arithmetic_modulo_t}</li>
399 *             <li>left operand:  {@link #getLeftOperand()}</li>
400 *             <li>right operand: {@link #getRightOperand()} </li>
401 *             <li>operator: {@link #getOperatorToken()} </li>
402 *             </ul>
403 *         </li>
404 *         <li>exponentiate: expr1 ^ expr2
405 *         <ul>
406 *             <li>type: {@link EExpressionType#exponentiate_t}</li>
407 *             <li>left operand:  {@link #getLeftOperand()}</li>
408 *             <li>right operand: {@link #getRightOperand()} </li>
409 *             <li>operator: {@link #getOperatorToken()} </li>
410 *             </ul>
411 *         </li>
412 *         <li>sql server 2008 +=,-=,*=,/=,%=: expr1 [+=|-=|*=|/=|%=] expr2
413 *         <ul>
414 *             <li>type: {@link EExpressionType#arithmetic_compound_operator_t}</li>
415 *             <li>left operand:  {@link #getLeftOperand()}</li>
416 *             <li>right operand: {@link #getRightOperand()} </li>
417 *             <li>operator: {@link #getOperatorToken()} </li>
418 *             </ul>
419 *         </li>
420 *     </uL>
421 *
422 *     LOGICAL
423 *     <ul>
424 *         <li>expr1 AND|&amp;&amp; expr2</li>
425  *             <li>type: {@link EExpressionType#logical_and_t}</li>
426  *             <li>left operand:  {@link #getLeftOperand()}</li>
427  *             <li>right operand: {@link #getRightOperand()} </li>
428  *             <li>operator: {@link #getOperatorToken()} </li>
429  *
430 *         <li>expr1 OR | || expr2
431 *         <ul>
432  *             <li>type: {@link EExpressionType#logical_or_t}</li>
433  *             <li>left operand:  {@link #getLeftOperand()}</li>
434  *             <li>right operand: {@link #getRightOperand()} </li>
435  *             <li>operator: {@link #getOperatorToken()} </li>
436  *             </ul>
437  *         </li>
438 *         <li>expr1 XOR expr2
439 *         <ul>
440  *             <li>type: {@link EExpressionType#logical_xor_t}</li>
441  *             <li>left operand:  {@link #getLeftOperand()}</li>
442  *             <li>right operand: {@link #getRightOperand()} </li>
443  *             <li>operator: {@link #getOperatorToken()} </li>
444  *             </ul>
445  *         </li>
446 *         <li>NOT|! expr1
447 *         <ul>
448  *             <li>type: {@link EExpressionType#logical_not_t}</li>
449  *             <li>left operand:  N/A</li>
450  *             <li>right operand: {@link #getRightOperand()} </li>
451  *             <li>operator: {@link #getOperatorToken()} </li>
452  *             </ul>
453  *         </li>
454 *         </ul>
455 *
456 *     ASSIGNMENT
457 *     <ul>
458 *         <li>ASSIGNMENT: expr1 [:=|=] expr2
459 *         <ul>
460  *             <li>type: {@link EExpressionType#assignment_t}</li>
461  *             <li>left operand:  {@link #getLeftOperand()}</li>
462  *             <li>right operand: {@link #getRightOperand()} </li>
463  *             <li>operator: {@link #getOperatorToken()} </li>
464  *             </ul>
465  *         </li>
466 *         </ul>
467 *
468 *     CONCATENATE
469 *     <ul>
470 *         <li>CONCATENATE: expr1 || expr2
471 *         <ul>
472  *             <li>type: {@link EExpressionType#concatenate_t}</li>
473  *             <li>left operand:  {@link #getLeftOperand()}</li>
474  *             <li>right operand: {@link #getRightOperand()} </li>
475  *             <li>operator: {@link #getOperatorToken()} </li>
476  *             </ul>
477  *         </li>
478 *         </ul>
479 *
480 *     AT TIME ZONE
481 *     <ul>
482 *         <li>expr1 at time zone expr2
483 *         <ul>
484  *             <li>type: {@link EExpressionType#at_time_zone_t}</li>
485  *             <li>left operand:  {@link #getLeftOperand()}</li>
486  *             <li>right operand: {@link #getRightOperand()} </li>
487  *             <li>operator: N/A</li>
488  *             </ul>
489  *         </li>
490 *         </ul>
491 *
492 *     AT LOCAL
493 *     <ul>
494 *         <li>expr1 at local
495 *         <ul>
496  *             <li>type: {@link EExpressionType#at_local_t}</li>
497  *             <li>left operand:  {@link #getLeftOperand()}</li>
498  *             <li>right operand: N/A </li>
499  *             <li>operator: N/A</li>
500  *             </ul>
501  *         </li>
502 *         </ul>
503 *
504 *     BITWISE
505 *     <ul>
506 *         <li>Bitwise and : expr1 &amp; expr2
507 *         <ul>
508  *             <li>type: {@link EExpressionType#bitwise_and_t}</li>
509  *             <li>left operand:  {@link #getLeftOperand()}</li>
510  *             <li>right operand: {@link #getRightOperand()} </li>
511  *             <li>operator: {@link #getOperatorToken()} </li>
512  *             </ul>
513  *         </li>
514 *         <li>Bitwise or : expr1 | expr2
515 *         <ul>
516  *             <li>type: {@link EExpressionType#bitwise_or_t}</li>
517  *             <li>left operand:  {@link #getLeftOperand()}</li>
518  *             <li>right operand: {@link #getRightOperand()} </li>
519  *             <li>operator: {@link #getOperatorToken()} </li>
520  *             </ul>
521  *         </li>
522 *         <li>Bitwise exclusive or : expr1 ^ expr2
523 *         <ul>
524  *             <li>type: {@link EExpressionType#bitwise_exclusive_or_t}</li>
525  *             <li>left operand:  {@link #getLeftOperand()}</li>
526  *             <li>right operand: {@link #getRightOperand()} </li>
527  *             <li>operator: {@link #getOperatorToken()} </li>
528  *             </ul>
529  *         </li>
530 *         <li>Bitwise xor : expr1 ^ expr2
531 *         <ul>
532  *             <li>type: {@link EExpressionType#bitwise_xor_t}</li>
533  *             <li>left operand:  {@link #getLeftOperand()}</li>
534  *             <li>right operand: {@link #getRightOperand()} </li>
535  *             <li>operator: {@link #getOperatorToken()} </li>
536  *             </ul>
537  *         </li>
538 *         <li>Bitwise shift left : expr1 &lt;&lt; expr2
539 *         <ul>
540  *             <li>type: {@link EExpressionType#bitwise_shift_left_t}</li>
541  *             <li>left operand:  {@link #getLeftOperand()}</li>
542  *             <li>right operand: {@link #getRightOperand()} </li>
543  *             <li>operator: {@link #getOperatorToken()} </li>
544  *             </ul>
545  *         </li>
546 *         <li><pre>Bitwise shift right : expr1 &gt;&gt; expr2</pre>
547 *         <ul>
548  *             <li>type: {@link EExpressionType#bitwise_shift_right_t}</li>
549  *             <li>left operand:  {@link #getLeftOperand()}</li>
550  *             <li>right operand: {@link #getRightOperand()} </li>
551  *             <li>operator: {@link #getOperatorToken()} </li>
552  *             </ul>
553  *         </li>
554 *         </ul>
555 *
556 *     SUBQUERY
557 *     <ul>
558 *         <li> A scalar subquery expression is a subquery that returns exactly one column value from one row.
559 *         <ul>
560  *             <li>type: {@link EExpressionType#subquery_t}</li>
561 *              <li>subquery: {@link #getSubQuery()} </li>
562  *             <li>left operand:  N/A</li>
563  *             <li>right operand: N/A </li>
564  *             <li>operator: N/A</li>
565  *             </ul>
566  *         </li>
567 *         </ul>
568 *
569 *     EXPRESSION WITH PARENTHESIS
570 *     <ul>
571 *         <li> ( expr1 )
572 *         <ul>
573  *             <li>type: {@link EExpressionType#parenthesis_t}</li>
574  *             <li>left operand is expr1:  {@link #getLeftOperand()}</li>
575  *             <li>right operand: N/A </li>
576  *             <li>operator: use {@link #getStartToken()} to get ( and {@link #getEndToken()} to get )</li>
577  *             </ul>
578  *         </li>
579 *         </ul>
580 *
581 *     LIST EXPRESSION
582 *     <ul>
583 *         <li>An expression list inside parenthesis like (expr,expr,...),
584 *         or one or more set of expressions: ((expr1,expr2,...),(expr1,expr2,...),(expr1,expr2,...)...)
585 *         <ul>
586  *             <li>type: {@link EExpressionType#list_t}</li>
587 *              <li>expr list: {@link #getExprList()}, may return null when expression list in syntax like this: () </li>
588  *             <li>left operand:  N/A</li>
589  *             <li>right operand: N/A </li>
590  *             <li>operator: open parenthsis ( can be fetched via {@link #getStartToken()},
591 *             close parenthesis ) can be fetched via {@link #getEndToken()} </li>
592  *             </ul>
593  *         </li>
594 *         </ul>
595 *
596 *    COLLECTION CONSTRUCTORS (informix)
597 *    <ul>
598 *        <li>Use a collection constructor to specify values for a collection column.
599 *        SET|MULTISET|LIST { epxr_list }
600 *          <ul>
601 *             <li>type: {@link EExpressionType#collection_constructor_set_t}</li>
602 *             <li>type: {@link EExpressionType#collection_constructor_multiset_t}</li>
603 *             <li>type: {@link EExpressionType#collection_constructor_list_t}</li>
604 *              <li>expr list: {@link #getExprList()}, may return null when expression list in syntax like this: () </li>
605 *             <li>left operand:  N/A</li>
606 *             <li>right operand: N/A </li>
607 *          </ul>
608 *        </li>
609 *
610 *
611 *    </ul>
612 *
613 *     GROUP EXPRESSION,  @deprecated As of v1.4.3.3
614 *     <ul>
615 *         <li>
616  *         </li>
617 *         </ul>
618 *
619 *     COMPARISON
620 *     <ul>
621 *         <li>A <b>simple comparison condition</b> specifies a comparison with expressions or subquery results.
622 *         <br>expr1 EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN expr2,
623 *         or, (expr_list) EQUAL|NOT_EQUAL (subquery)
624 *             <ul>
625 *             <li>type: {@link EExpressionType#simple_comparison_t}</li>
626 *             <li>left operand:  {@link #getLeftOperand()}</li>
627 *             <li>right operand: {@link #getRightOperand()} </li>
628 *             <li>operator: {@link #getOperatorToken()}</li>
629 *             </ul>
630 *         </li>
631 *         <li>A <b>group comparison condition</b> specifies a comparison with any or all members
632 *         in a list or subquery.
633 *         <br>expr EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN ANY|SOME|ALL (expr_list|subquery),
634 *         or, (expr_list) EQUAL|NOT_EQUAL ANY|SOME|ALL (expr_list|subquery)
635 *             <ul>
636 *             <li>type: {@link EExpressionType#group_comparison_t}</li>
637 *             <li>left operand:  {@link #getLeftOperand()}</li>
638 *             <li>right operand: {@link #getRightOperand()} </li>
639 *             <li>operator: {@link #getOperatorToken()}</li>
640 *             <li> ANY|SOME|ALL: {@link #getQuantifier()}</li>
641 *             </ul>
642 *         </li>
643 *         </ul>
644 *
645 *     IN
646 *     <ul>
647 *         <li>(expr|expr_list) |NOT] IN (expr_list)|(subquery)|expr
648 *         <ul>
649  *             <li>type: {@link EExpressionType#in_t}</li>
650 *             <li>left operand:  {@link #getLeftOperand()}</li>
651 *             <li>right operand: {@link #getRightOperand()} </li>
652  *            <li>operator is IN: {@link #getOperatorToken()} </li>
653 *             <li>NOT keyword: {@link #getNotToken()} </li>
654  *             </ul>
655  *         </li>
656 *         </ul>
657 *
658 *     CASE
659 *     <ul>
660 *         <li>case expression,let you use IF ... THEN ... ELSE logic in SQL statements without having to invoke procedures.
661 *         <ul>
662  *             <li>type: {@link EExpressionType#case_t}</li>
663 *              <li> case expression: {@link #getCaseExpression()}}</li>
664  *             <li>left operand:  N/A</li>
665  *             <li>right operand: N/A </li>
666  *             <li>operator: N/A </li>
667  *             </ul>
668  *         </li>
669 *         </ul>
670 *
671 *     CURSOR
672 *     <ul>
673 *         <li>CURSOR subquery
674 *         <ul>
675  *             <li>type: {@link EExpressionType#cursor_t}</li>
676 *              <li>subquery: {@link #getSubQuery()}</li>
677  *             <li>left operand:  N/A</li>
678  *             <li>right operand: N/A </li>
679  *             <li>operator: CURSOR can be fetched via {@link #getStartToken()} </li>
680  *             </ul>
681  *         </li>
682 *         </ul>
683 *
684 *     PATTERN MATCHING
685 *     <ul>
686 *         <li>expr1 [NOT] [LIKE|ILIKE|RLIKE|REGEXP|SIMILAR TO] [ALL|ANY|SOME]expr2 [ESCAPE expr3]
687 *         <ul>
688  *             <li>type: {@link EExpressionType#pattern_matching_t}</li>
689  *             <li>left operand:  {@link #getLeftOperand()}</li>
690  *             <li>right operand:{@link #getRightOperand()} </li>
691 *              <li>expr3: {@link #getLikeEscapeOperand()} </li>
692  *             <li>operator: {@link #getOperatorToken()}</li>
693 *              <li>NOT keyword: {@link #getNotToken()}</li>
694 *              <li>ALL|ANY|SOME keyword: {@link #getQuantifier()}</li>
695 *              <li>ESCAPE keyword: N/A</li>
696  *             </ul>
697  *         </li>
698 *         </ul>
699 *
700 *     NULL
701 *     <ul>
702 *         <li>expr ISNULL|NOTNULL|IS [NOT] NULL
703 *         <ul>
704  *             <li>type: {@link EExpressionType#null_t}</li>
705  *             <li>left operand:  {@link #getLeftOperand()}</li>
706  *             <li>right operand: N/A </li>
707  *             <li>operator is NULL: {@link #getOperatorToken()}</li>
708 *              <li>NOT keyword: {@link #getNotToken()}</li>
709  *             </ul>
710  *         </li>
711 *         </ul>
712 *
713 *     BETWEEN
714 *     <ul>
715 *         <li>expr1 [NOT] BETWEEN expr2 AND expr3
716 *         <ul>
717  *             <li>type: {@link EExpressionType#between_t}</li>
718 *              <li>expr1:  {@link #getBetweenOperand()}</li>
719  *             <li>expr2:  {@link #getLeftOperand()}</li>
720  *             <li>expr3: {@link #getRightOperand()} </li>
721  *             <li>operator is BETWEEN: {@link #getOperatorToken()}</li>
722 *              <li>NOT keyword: {@link #getNotToken()}</li>
723  *             </ul>
724  *         </li>
725 *         </ul>
726 *
727 *     EXISTS
728 *     <ul>
729 *         <li>EXISTS (subquery)
730 *         <ul>
731  *             <li>type: {@link EExpressionType#exists_t}</li>
732 *              <li>left operand:  N/A</li>
733  *             <li>right operand: N/A</li>
734  *             <li>subquery: {@link #getSubQuery()} </li>
735  *             <li>EXISTS: {@link #getStartToken()}</li>
736  *             </ul>
737  *         </li>
738 *         </ul>
739 *
740 *    IS UNKNOWN
741 *     <ul>
742 *         <li> expr1 IS [NOT] UNKNOWN
743 *         <ul>
744  *             <li>type: {@link EExpressionType#is_unknown_t}</li>
745 *             <li>left operand:  {@link #getLeftOperand()}</li>
746 *             <li>right operand: N/A </li>
747  *             <li>operator: {@link #getOperatorToken()}</li>
748 *             <li>NOT keyword: {@link #getNotToken()}</li>
749  *             </ul>
750  *         </li>
751 *         </ul>
752 *
753 *    IS TRUE
754 *     <ul>
755 *         <li> expr1 IS [NOT] TRUE
756 *         <ul>
757  *             <li>type: {@link EExpressionType#is_true_t}</li>
758 *             <li>left operand:  {@link #getLeftOperand()}</li>
759 *             <li>right operand: N/A </li>
760  *             <li>operator: {@link #getOperatorToken()}</li>
761 *             <li>NOT keyword: {@link #getNotToken()}</li>
762  *             </ul>
763  *         </li>
764 *         </ul>
765 *
766 *    IS FALSE
767 *     <ul>
768 *         <li> expr1 IS [NOT] FALSE
769 *         <ul>
770  *             <li>type: {@link EExpressionType#is_false_t}</li>
771 *             <li>left operand:  {@link #getLeftOperand()}</li>
772 *             <li>right operand: N/A </li>
773  *             <li>operator: {@link #getOperatorToken()}</li>
774 *             <li>NOT keyword: {@link #getNotToken()}</li>
775  *             </ul>
776  *         </li>
777 *         </ul>
778 *
779 *     DAY TO SECOND
780 *     <ul>
781 *         <li>expr DAY [( integer )] TO SECOND [( integer )]
782 *         <ul>
783  *             <li>type: {@link EExpressionType#day_to_second_t}</li>
784  *             <li>left operand:  {@link #getLeftOperand()}</li>
785  *             <li>right operand: N/A </li>
786  *             <li>operator: N/A</li>
787  *             </ul>
788  *         </li>
789 *         </ul>
790 *
791 *     YEAR TO MONTH
792 *     <ul>
793 *         <li>expr YEAR [( integer )] TO MONTH
794 *         <ul>
795  *             <li>type: {@link EExpressionType#year_to_month_t}</li>
796  *             <li>left operand:  {@link #getLeftOperand()}</li>
797  *             <li>right operand: N/A </li>
798  *             <li>operator: N/A</li>
799  *             </ul>
800  *         </li>
801 *         </ul>
802 *
803 *     INTERVAL(teradata)
804 *     <ul>
805 *         <li>( date_time_expression date_time_term ) start TO end
806 *         <ul>
807  *             <li>type: {@link EExpressionType#interval_t}</li>
808 *              <li>date_time_expression: {@link #getIntervalExpr()} </li>
809  *             <li>left operand:  N/A</li>
810  *             <li>right operand: N/A </li>
811  *             <li>operator: N/A</li>
812  *             </ul>
813  *         </li>
814 *         </ul>
815 *
816 *     NEW STRUCTURED TYPE
817 *     <ul>
818 *         <li>NEW function_call
819 *         <ul>
820  *             <li>type: {@link EExpressionType#new_structured_type_t}</li>
821 *              <li>function_call: {@link #getFunctionCall()} </li>
822  *             <li>left operand:  N/A</li>
823  *             <li>right operand: N/A </li>
824  *             <li>operator: N/A</li>
825  *             </ul>
826  *         </li>
827 *         </ul>
828 *
829 *     NEW VARIANT_TYPE
830 *     <ul>
831 *         <li>NEW VARIANT_TYPE ( type_argument_list )
832 *         <ul>
833  *             <li>type: {@link EExpressionType#new_variant_type_t}</li>
834 *              <li>type_argument_list: {@link #getNewVariantTypeArgumentList()} </li>
835  *             <li>left operand:  N/A</li>
836  *             <li>right operand: N/A </li>
837  *             <li>operator: N/A</li>
838  *             </ul>
839  *         </li>
840 *         </ul>
841 *
842 *     LDIFF,RDIFF,P_INTERSECT,P_NORMALIZE
843 *     <ul>
844 *         <li> expr1 LDIFF|RDIFF|P_INTERSECT|P_NORMALIZE expr2
845 *         <ul>
846  *             <li>type: {@link EExpressionType#new_variant_type_t}</li>
847 *             <li>left operand:  {@link #getLeftOperand()}</li>
848 *             <li>right operand: {@link #getRightOperand()} </li>
849  *             <li>operator: {@link #getOperatorToken()}</li>
850  *             </ul>
851  *         </li>
852 *         </ul>
853 *
854 *    UNTIL CHANGED
855 *     <ul>
856 *         <li> expr1 IS [NOT] UNTIL_CHANGED
857 *         <ul>
858  *             <li>type: {@link EExpressionType#new_variant_type_t}</li>
859 *             <li>left operand:  {@link #getLeftOperand()}</li>
860 *             <li>right operand: N/A </li>
861  *             <li>operator: {@link #getOperatorToken()}</li>
862 *             <li>NOT keyword: {@link #getNotToken()}</li>
863  *             </ul>
864  *         </li>
865 *         </ul>
866 *
867 *     LEFT SHIFT
868 *     <ul>
869 *         <li><pre>expr1 &lt;&lt; expr2</pre>
870 *         <ul>
871  *             <li>type: {@link EExpressionType#left_shift_t}</li>
872  *             <li>left operand:  {@link #getLeftOperand()}</li>
873  *             <li>right operand: {@link #getRightOperand()} </li>
874  *             <li>operator: {@link #getOperatorToken()} </li>
875  *             </ul>
876  *         </li>
877 *         </ul>
878 *
879 *     RIGHT SHIFT
880 *     <ul>
881 *         <li>expr1 &gt;&gt; expr2
882 *         <ul>
883  *             <li>type: {@link EExpressionType#right_shift_t}</li>
884  *             <li>left operand:  {@link #getLeftOperand()}</li>
885  *             <li>right operand: {@link #getRightOperand()} </li>
886  *             <li>operator: {@link #getOperatorToken()} </li>
887  *             </ul>
888  *         </li>
889 *         </ul>
890 *
891 *    IS DOCUMENT
892 *     <ul>
893 *         <li> expr1 IS [NOT] DOCUMENT
894 *         <ul>
895  *             <li>type: {@link EExpressionType#is_document_t}</li>
896 *             <li>left operand:  {@link #getLeftOperand()}</li>
897 *             <li>right operand: N/A </li>
898  *             <li>operator: {@link #getOperatorToken()}</li>
899 *             <li>NOT keyword: {@link #getNotToken()}</li>
900  *             </ul>
901  *         </li>
902 *         </ul>
903 *
904 *     IS DISTINCT FROM
905 *     <ul>
906 *         <li> expr1 IS [NOT] DISTINCT FROM expr2
907 *         <ul>
908  *             <li>type: {@link EExpressionType#is_distinct_from_t}</li>
909 *             <li>left operand:  {@link #getLeftOperand()}</li>
910 *             <li>right operand: {@link #getRightOperand()} </li>
911  *             <li>operator: {@link #getOperatorToken()}</li>
912 *             <li>NOT keyword: {@link #getNotToken()}</li>
913  *             </ul>
914  *         </li>
915 *         </ul>
916 *
917 *     SQL SERVER left join
918 *     <ul>
919 *         <li> expr1 *= expr2
920 *         <ul>
921  *             <li>type: {@link EExpressionType#left_join_t}</li>
922 *             <li>left operand:  {@link #getLeftOperand()}</li>
923 *             <li>right operand: {@link #getRightOperand()} </li>
924  *            <li>operator: {@link #getOperatorToken()}</li>
925  *             </ul>
926  *         </li>
927 *         </ul>
928 *
929 *     SQL SERVER right join
930 *     <ul>
931 *         <li> expr1 =* expr2
932 *         <ul>
933  *             <li>type: {@link EExpressionType#right_join_t}</li>
934 *             <li>left operand:  {@link #getLeftOperand()}</li>
935 *             <li>right operand: {@link #getRightOperand()} </li>
936  *            <li>operator: {@link #getOperatorToken()}</li>
937  *             </ul>
938  *         </li>
939 *         </ul>
940 *
941 *     COLLATE
942 *     <ul>
943 *         <li> expr1 COLLATE expr2
944 *         <ul>
945  *             <li>type: {@link EExpressionType#collate_t}</li>
946 *             <li>left operand:  {@link #getLeftOperand()}</li>
947 *             <li>right operand: {@link #getRightOperand()} </li>
948  *             <li>operator: {@link #getOperatorToken()}</li>
949 *             <li>NOT keyword: {@link #getNotToken()}</li>
950  *             </ul>
951  *         </li>
952 *         </ul>
953 *
954 *     MEMBER OF
955 *     <ul>
956 *         <li> expr1 MEMBER OF expr2
957 *         <ul>
958  *             <li>type: {@link EExpressionType#member_of_t}</li>
959 *             <li>left operand:  {@link #getLeftOperand()}</li>
960 *             <li>right operand: {@link #getRightOperand()} </li>
961  *             <li>operator: {@link #getOperatorToken()}</li>
962  *             </ul>
963  *         </li>
964 *         </ul>
965 *
966 *     NEXT VALUE FOR
967 *     <ul>
968 *         <li> <pre>NEXT VALUE FOR &lt;sequence name&gt;, or NEXT &lt;integer expression&gt;VALUE FOR &lt;sequence name&gt;</pre></li>
969  *             <li>type: {@link EExpressionType#next_value_for_t}</li>
970 *             <li>sequence name: {@link #getSequenceName()}   </li>
971 *             <li>over_clause : {@link #getOver_clause()}} </li>
972 *             <li>left operand(integer expression):  {@link #getLeftOperand()}</li>
973 *         </ul>
974 *
975 *     REF ARROW(named parameters in function call)
976 *     <ul>
977 *         <li> expr1 =&gt; expr2
978 *         <ul>
979  *             <li>type: {@link EExpressionType#ref_arrow_t}</li>
980  *             <li>left operand:  {@link #getLeftOperand()}</li>
981  *             <li>right operand: {@link #getRightOperand()} </li>
982  *             <li>operator: {@link #getOperatorToken()} </li>
983  *             </ul>
984  *         </li>
985 *         </ul>
986 *
987 *     TYPECAST
988 *     <ul>
989 *         <li> expr1 TYPECAST typename
990 *         <ul>
991  *             <li>type: {@link EExpressionType#typecast_t}</li>
992 *              <li>typename: {@link #getTypeName()}</li>
993  *             <li>left operand:  {@link #getLeftOperand()}</li>
994  *             <li>right operand: N/A </li>
995  *             <li>operator: {@link #getOperatorToken()} </li>
996  *         </ul>
997  *         </li>
998 *     </ul>
999 *
1000 *     MULTISET
1001 *     <ul>
1002 *         <li>MULTISET subquery
1003 *         <ul>
1004  *             <li>type: {@link EExpressionType#multiset_t}</li>
1005 *              <li>subquery: {@link #getSubQuery()}</li>
1006  *             <li>left operand:  N/A</li>
1007  *             <li>right operand: N/A </li>
1008  *             <li>operator: MULTISET can be fetched via {@link #getStartToken()} </li>
1009  *             </ul>
1010  *         </li>
1011 *         </ul>
1012 *
1013 *     FLOATING POINT
1014 *     <ul>
1015 *         <li>expr is [NOT] NAN|INFINITE
1016 *         <ul>
1017  *             <li>type: {@link EExpressionType#floating_point_t}</li>
1018  *             <li>left operand:  {@link #getLeftOperand()}</li>
1019  *             <li>right operand: N/A </li>
1020  *             <li>operator is IS: {@link #getOperatorToken()}</li>
1021 *              <li>NOT keyword: {@link #getNotToken()}</li>
1022  *             </ul>
1023  *         </li>
1024 *         </ul>
1025 *
1026 *     ROW CONSTRUCTOR
1027 *     <ul>
1028 *         <li>ROW ( expr_list )
1029 *         <ul>
1030  *             <li>type: {@link EExpressionType#row_constructor_t}</li>
1031 *              <li>expr_list:  {@link #getExprList()}</li>
1032  *             <li>left operand:  N/A</li>
1033  *             <li>right operand: N/A </li>
1034  *             <li>operator is ROW: {@link #getStartToken()}</li>
1035  *             </ul>
1036  *         </li>
1037 *         </ul>
1038 *
1039 *     IS OF TYPE
1040 *     <ul>
1041 *         <li>expr is of type ( datatype,...)
1042 *         <ul>
1043  *             <li>type: {@link EExpressionType#is_of_type_t}</li>
1044  *             <li>left operand:  {@link #getLeftOperand()}</li>
1045  *             <li>right operand: N/A </li>
1046  *             <li>operator: N/A</li>
1047  *             </ul>
1048  *         </li>
1049 *         </ul>
1050 *
1051 *     PLACE HOLDER
1052 *     <ul>
1053 *         <li>place holder expression
1054 *         <ul>
1055  *             <li>type: {@link EExpressionType#place_holder_t}</li>
1056  *             <li>left operand:  N/A</li>
1057  *             <li>right operand: N/A </li>
1058  *             <li>operator: N/A</li>
1059  *             </ul>
1060  *         </li>
1061 *         </ul>
1062 *
1063 *     TYPE_CONSTRUCTOR_EXPRESSION
1064 *     <ul>
1065 *         <li>[NEW] type_name( expr_list )
1066 *         <ul>
1067  *             <li>type: {@link EExpressionType#type_constructor_t}</li>
1068  *             <li>type_name(expr_list): {@link #getFunctionCall()}</li>
1069  *             <li>left operand:  N/A</li>
1070  *             <li>right operand: N/A </li>
1071  *             <li>operator: N/A</li>
1072  *             </ul>
1073  *         </li>
1074 *         </ul>
1075 *
1076 *     ARRAY ACCESS
1077 *     <ul>
1078 *         <li>array_name(index1)(index2)(index3)
1079 *         <ul>
1080  *             <li>type: {@link EExpressionType#arrayaccess_t}</li>
1081  *             <li>array_name(index1)(index2)(index3): {@link #getArrayAccess()}</li>
1082  *             <li>left operand:  N/A</li>
1083  *             <li>right operand: N/A </li>
1084  *             <li>operator: N/A</li>
1085  *             </ul>
1086  *         </li>
1087 *         </ul>
1088 *
1089 *     OBJECT ACCESS EXPRESSION
1090 *     <ul>
1091 *         <li>objectExpr.[attributes].method()
1092 *         <ul>
1093  *             <li>type: {@link EExpressionType#object_access_t}</li>
1094  *             <li>objectExpr.[attributes].method(): {@link #getObjectAccess()}</li>
1095  *             <li>left operand:  N/A</li>
1096  *             <li>right operand: N/A </li>
1097  *             <li>operator: N/A</li>
1098  *             </ul>
1099  *         </li>
1100 *      </ul>
1101 *
1102 *     Unknown
1103 *     <ul>
1104 *         <li>expr OPERATOR expr, means this expression was not recognized by SQL parser yet.
1105 *         <ul>
1106  *             <li>type: {@link EExpressionType#unknown_t}</li>
1107  *             <li>left operand: {@link #getLeftOperand()}</li>
1108  *             <li>right operand: {@link #getRightOperand()} </li>
1109  *             <li>operator: {@link #getOperatorToken()}</li>
1110  *             </ul>
1111  *         </li>
1112 *         </ul>
1113 *
1114 *     Unknown unary left
1115 *     <ul>
1116 *         <li>OPERATOR expr, means this expression was not recognized by SQL parser yet.
1117 *         <ul>
1118  *             <li>type: {@link EExpressionType#unary_left_unknown_t}</li>
1119  *             <li>left operand: N/A</li>
1120  *             <li>right operand: {@link #getRightOperand()} </li>
1121  *             <li>operator: {@link #getOperatorToken()}</li>
1122  *             </ul>
1123  *         </li>
1124 *         </ul>
1125 *
1126 *     Unknown unary right
1127 *     <ul>
1128 *         <li> expr OPERATOR, means this expression was not recognized by SQL parser yet.
1129 *         <ul>
1130  *             <li>type: {@link EExpressionType#unary_right_unknown_t}</li>
1131  *             <li>left operand: {@link #getLeftOperand()}</li>
1132  *             <li>right operand: N/A </li>
1133  *             <li>operator: {@link #getOperatorToken()}</li>
1134  *             </ul>
1135  *         </li>
1136 *         </ul>
1137 *
1138 *     ARRAY CONSTRUCTOR
1139 *     <ul>
1140 *         <li>
1141 * An array constructor is an expression that builds an array value using values for its member elements.
1142 * <p> like this: ARRAY[1,2,3+4]
1143 * <p> array element values can be accessed via {@link #getExprList()},
1144 * <p> or {@link #getExprList()} can be null when it is: array[]
1145 * <p>
1146 * <p> It is also possible to construct an array from the results of a subquery like this:
1147 * <p> SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
1148 * <p> thus, subquery can be access via {@link #getSubQuery()}
1149 *         <ul>
1150  *             <li>type: {@link EExpressionType#array_constructor_t}</li>
1151 *             <li>array element values: {@link #getExprList()} </li>
1152 *             <li>subquery: {@link #getSubQuery()}</li>
1153  *             <li>left operand:  N/A</li>
1154  *             <li>right operand: N/A </li>
1155  *             <li>operator: N/A</li>
1156  *             </ul>
1157  *         </li>
1158 *         </ul>
1159 *
1160 *     FIELD SELECTION
1161 *     <ul>
1162 *         <li>
1163 * If an expression yields a value of a composite type (row type), then a specific field of the row can be extracted by writing
1164 * <p> expression.fieldname
1165 * <p> In general the row expression must be parenthesized, but the parentheses can be omitted
1166 * <p> when the expression to be selected from is just a table reference or positional parameter.
1167 * <p> For example:
1168 * <p> mytable.mycolumn
1169 * <p> $1.somecolumn
1170 * <p> (rowfunction(a,b)).col3
1171 * <p>
1172 * <p> (Thus, a qualified column reference is actually just a special case of the field selection syntax.) An important special case is extracting a field from a table column that is of a composite type:
1173 * <p> (compositecol).somefield
1174 * <p> (mytable.compositecol).somefield
1175 * <p> The parentheses are required here to show that compositecol is a column name not a table name,
1176 * <p> or that mytable is a table name not a schema name in the second case.
1177 * <p>
1178 * <p> n a select list, you can ask for all fields of a composite value by writing .*:
1179 * <p> (compositecol).*
1180 * <p>
1181 * <p>
1182 * <p> When expression in following syntax, it will be marked as {@link #fieldSelection}, and check {@link #getFieldName()}
1183 * <p> (rowfunction(a,b)).col3
1184 * <p> (compositecol).somefield
1185 * <p> (mytable.compositecol).somefield
1186 * <p> (compositecol).*
1187 * <p>
1188 * <p> Otherwise, it will be marked as {@link #simpleObjectname}:
1189 * <p> mytable.mycolumn
1190 * <p> $1.somecolumn
1191  *         <ul>
1192  *             <li>type: {@link EExpressionType#fieldselection_t}</li>
1193  *             <li>left operand:  N/A</li>
1194  *             <li>right operand: N/A </li>
1195  *             <li>operator: N/A</li>
1196  *         </ul>
1197 *       </li>
1198 *     </ul>
1199 *
1200 *
1201 * HIVE ARRAY ACCESS
1202 *   <ul>
1203 *     <li>  HIVE field expression syntax like fieldexpr[expr_subscript]
1204 *         <ul>
1205 *             <li>type: {@link EExpressionType#array_access_expr_t}</li>
1206 *             <li>fieldexpr:  {@link #getLeftOperand()}</li>
1207 *             <li>expr_subscript: {@link #getRightOperand()} </li>
1208 *             <li>operator: N/A</li>
1209 *         </ul>
1210*       </li>
1211*     </ul>
1212 *
1213 *
1214 * HIVE FIELD ACCESS
1215 *   <ul>
1216 *     <li>  HIVE field access syntax like fieldexpr.identifier.identifier...
1217 *         <ul>
1218 *             <li>type: {@link EExpressionType#object_access_t}</li>
1219 *             <li>fieldexpr:  {@link #getLeftOperand()}</li>
1220 *             <li>identifier.identifier...: {@link #getFieldList()} </li>
1221 *             <li>operator: N/A</li>
1222 *         </ul>
1223*       </li>
1224*    </ul>
1225*
1226 *     JSON Operators (PostgreSQL)
1227 *
1228 *     <ul>
1229 *         <li> expr1 -&gt; expr2
1230 *         <ul>
1231 *             <li>type: {@link EExpressionType#json_get_object}</li>
1232 *             <li>left operand:  {@link #getLeftOperand()}</li>
1233 *             <li>right operand: {@link #getLeftOperand()} </li>
1234 *         </ul>
1235 *         </li>
1236 *         <li> expr1 -&gt;&gt; expr2
1237 *         <ul>
1238 *             <li>type: {@link EExpressionType#json_get_text}</li>
1239 *             <li>left operand:  {@link #getLeftOperand()}</li>
1240 *             <li>right operand: {@link #getLeftOperand()} </li>
1241 *         </ul>
1242 *         </li>
1243 *         <li> expr1 #&gt; expr2
1244 *         <ul>
1245 *             <li>type: {@link EExpressionType#json_get_object_at_path}</li>
1246 *             <li>left operand:  {@link #getLeftOperand()}</li>
1247 *             <li>right operand: {@link #getLeftOperand()} </li>
1248 *         </ul>
1249 *         </li>
1250 *         <li> expr1 #&gt;&gt; expr2
1251 *         <ul>
1252 *             <li>type: {@link EExpressionType#json_get_text_at_path}</li>
1253 *             <li>left operand:  {@link #getLeftOperand()}</li>
1254 *             <li>right operand: {@link #getLeftOperand()} </li>
1255 *         </ul>
1256 *         </li>
1257 *         <li> expr1 @&gt; expr2
1258 *         <ul>
1259 *             <li>type: {@link EExpressionType#json_left_contain}</li>
1260 *             <li>left operand:  {@link #getLeftOperand()}</li>
1261 *             <li>right operand: {@link #getLeftOperand()} </li>
1262 *         </ul>
1263 *         </li>
1264 *         <li> expr1 &gt;@ expr2
1265 *         <ul>
1266 *             <li>type: {@link EExpressionType#json_right_contain}</li>
1267 *             <li>left operand:  {@link #getLeftOperand()}</li>
1268 *             <li>right operand: {@link #getLeftOperand()} </li>
1269 *         </ul>
1270 *         </li>
1271 *         <li> expr1 ? expr2
1272 *         <ul>
1273 *             <li>type: {@link EExpressionType#json_exist}</li>
1274 *             <li>left operand:  {@link #getLeftOperand()}</li>
1275 *             <li>right operand: {@link #getLeftOperand()} </li>
1276 *         </ul>
1277 *         </li>
1278 *         <li> expr1 ?| expr2
1279 *         <ul>
1280 *             <li>type: {@link EExpressionType#json_any_exist}</li>
1281 *             <li>left operand:  {@link #getLeftOperand()}</li>
1282 *             <li>right operand: {@link #getLeftOperand()} </li>
1283 *         </ul>
1284 *         </li>
1285 *         <li> expr1 ?&amp; expr2</li>
1286 *             <li>type: {@link EExpressionType#json_all_exist}</li>
1287 *             <li>left operand:  {@link #getLeftOperand()}</li>
1288 *             <li>right operand: {@link #getLeftOperand()} </li>
1289 *
1290 *     </ul>
1291 *
1292 *      IS [NOT] A SET
1293 *     <ul>
1294 *         <li>Oracle set operator: IS [NOT] A SET
1295 *         <ul>
1296 *             <li>type: {@link EExpressionType#is_a_set_t}</li>
1297 *             <li>left operand:  {@link #getLeftOperand()}</li>
1298 *             <li>operator: N/A</li>
1299 *             </ul>
1300 *         </li>
1301 *         </ul>
1302 *
1303 *      Big Query ARRAY &lt;T&gt;[ expr_list ]
1304 *     <ul>
1305 *         <li>ARRAY &lt;T&gt;[ expr_list ], expr_list maybe empty
1306 *         <ul>
1307 *             <li>type: {@link EExpressionType#array_t}</li>
1308 *             <li>left operand:  {@link #getExprList()}</li>
1309 *             <li>{@link #getTypeName()} returns the T of this Array if specified.</li>
1310 *         </ul>
1311 *         </li>
1312 *      </ul>
1313 */
1314
1315public class TExpression extends TParseTreeNode{
1316
1317    private ArrayList<TObjectName> columnsInsideExpression = null;
1318
1319    public ArrayList<TObjectName> getColumnsInsideExpression(){
1320        if (columnsInsideExpression == null){
1321            columnsInsideExpression = new ArrayList<>();
1322        }
1323        if (!columnsInsideExpression.isEmpty()){
1324            return columnsInsideExpression;
1325        }
1326
1327        columnVisitor visitor = new columnVisitor(columnsInsideExpression);
1328        this.acceptChildren(visitor);
1329        return columnsInsideExpression;
1330    }
1331
1332    /**
1333     *  bigint(expr) in databricks, return EDataType.bigint_t
1334     *
1335     * @return datatype
1336     */
1337    public EDataType getCastDatatype() {
1338        return castDatatype;
1339    }
1340
1341    private EDataType castDatatype;
1342
1343//    public void setBigQueryExceptReplaceClause(TExceptReplaceClause node){
1344//        if (node == null) return;
1345//        this.fieldList = node.getColumnList();
1346//        //this.
1347//
1348//    }
1349
1350    public void setLeftUnary(TSourceToken st){
1351        switch (st.tokencode){
1352            case '+':
1353                this.expressionType = EExpressionType.unary_plus_t;
1354                break;
1355            case '-':
1356                this.expressionType = EExpressionType.unary_minus_t;
1357                break;
1358            case '@':
1359                this.expressionType = EExpressionType.unary_absolutevalue_t;
1360                break;
1361            case '~':
1362                this.expressionType = EExpressionType.unary_bitwise_not_t;
1363                break;
1364            default:
1365                break;
1366        }
1367    }
1368
1369    public void setRightUnary(TSourceToken st){
1370        switch (st.tokencode){
1371            case '!':
1372                this.expressionType = EExpressionType.unary_factorial_t;
1373                break;
1374            default:
1375                break;
1376        }
1377    }
1378
1379    private ArrayList<TDataConversion> dataConversions = null;
1380
1381    public void setDataConversions(ArrayList<TDataConversion> dataConversions) {
1382        this.dataConversions = dataConversions;
1383    }
1384
1385    public ArrayList<TDataConversion> getDataConversions() {
1386        if (this.dataConversions == null){
1387            this.dataConversions = new ArrayList<>();
1388        }
1389        return dataConversions;
1390    }
1391
1392    private String value;
1393
1394    public void setStringValue(String value) {
1395        this.value = value;
1396    }
1397
1398    public String getStringValue() {
1399        return value;
1400    }
1401
1402    private IType dataType = TPrimitiveType.Undefined;
1403
1404    public void setDataType(IType dataType) {
1405        this.dataType = dataType;
1406    }
1407
1408    public IType getDataType() {
1409        return dataType;
1410    }
1411
1412    private TCollectionArray collectionArray;
1413    private TCollectionCondition collectionCondition;
1414
1415    public TCollectionCondition getCollectionCondition() {
1416        return collectionCondition;
1417    }
1418
1419    public TCollectionArray getCollectionArray() {
1420        return collectionArray;
1421    }
1422
1423    private TNamedParameter namedParameter;
1424    private TPositionalParameter positionalParameter;
1425
1426    public TNamedParameter getNamedParameter() {
1427        return namedParameter;
1428    }
1429
1430    public TPositionalParameter getPositionalParameter() {
1431        return positionalParameter;
1432    }
1433
1434    private TObjectConstruct objectConstruct;
1435
1436    public TArrayConstruct getArrayConstruct() {
1437        return arrayConstruct;
1438    }
1439
1440    public TObjectConstruct getObjectConstruct() {
1441        return objectConstruct;
1442    }
1443
1444    private TArrayConstruct arrayConstruct;
1445
1446    private boolean onlyAndOrIsNonLeaf = false;
1447
1448
1449    public void  evaluate(Stack<TFrame> frameStack , TCustomSqlStatement sqlStatement){
1450        calculateExprVisitor cv = new calculateExprVisitor(frameStack, sqlStatement);
1451        this.postOrderTraverse(cv);
1452    }
1453    public Object evaluate(IEvaluationContext context){
1454        TExpressionEvaluator expressionEvaluator = new TExpressionEvaluator(context);
1455        this.postOrderTraverse(expressionEvaluator);
1456        return  this.getStringValue();
1457    }
1458
1459    /**
1460     * @deprecated As of v2.0.5.6, use class ColumnVisitor in package demos.columnInWhereClause instead.
1461     */
1462    public TExpressionList searchColumn(String columnName){
1463        TExpressionList resultList = new TExpressionList();
1464        this.inOrderTraverse(new searchColumnVisitor(columnName,resultList));
1465        return  resultList;
1466    }
1467
1468    private TFlattenVisitor flattenVisitor;
1469
1470    /**
1471     *
1472     * @return AND/OR token before expression when you get flattened expression using {@link #getFlattedAndOrExprs}
1473     */
1474    public TSourceToken getAndOrTokenBeforeExpr(){
1475        TSourceToken lcToken = getStartToken();
1476        if (lcToken == null)  return null;
1477        TSourceToken lcPrevToken = lcToken.prevSolidToken();
1478        if ((lcPrevToken.tokencode == TBaseType.rrw_and)||(lcPrevToken.tokencode == TBaseType.rrw_or)){
1479            return lcPrevToken;
1480        }else{
1481            return  null;
1482        }
1483    }
1484
1485    /**
1486     * Binary tree structure representation of expression makes AND/OR expression nested deeply
1487     * when there are lots of AND/OR condition is used.
1488     * Recursively function call on those nested AND/OR expression will cause stack overflow exception.
1489     * After flatten those expressions. we can iterate those expression in a linear way.
1490     * @return null if this is not AND/OR expression
1491     */
1492    public ArrayList getFlattedAndOrExprs(){
1493        if (!((expressionType == EExpressionType.logical_and_t)||(expressionType == EExpressionType.logical_or_t))){
1494            return  null;
1495        }
1496        if (flattenVisitor.getFlattedAndOrExprs().size() == 0){
1497            onlyAndOrIsNonLeaf = true;
1498            this.inOrderTraverse(flattenVisitor);
1499            onlyAndOrIsNonLeaf = false;
1500        }
1501        return flattenVisitor.getFlattedAndOrExprs();
1502    }
1503
1504//    private int flatAndOrExpr(){
1505//        int ret = 0;
1506//        if (!((expressionType == EExpressionType.logical_and_t)||(expressionType == EExpressionType.logical_or_t))){
1507//            return  0;
1508//        }
1509//        if (getFlattedAndOrExprs().size() > 0){
1510//            //already flatten, just return size
1511//            return  getFlattedAndOrExprs().size();
1512//        }
1513//
1514//        onlyAndOrIsNonLeaf = true;
1515//        this.inOrderTraverse(flattenVisitor);
1516//        onlyAndOrIsNonLeaf = false;
1517//        return  ret;
1518//    }
1519
1520    public void setTokenToIdentifier()
1521    {
1522        if (getExpressionType() == EExpressionType.simple_object_name_t){
1523            if (getObjectOperand().getEndToken() != null){
1524                getObjectOperand().getEndToken().tokencode = TBaseType.ident;
1525                getObjectOperand().getEndToken().tokentype = ETokenType.ttidentifier;
1526            }
1527        }else if (getExpressionType() == EExpressionType.simple_source_token_t){
1528            getSourcetokenOperand().tokencode = TBaseType.ident;
1529            getSourcetokenOperand().tokentype = ETokenType.ttidentifier;
1530        }
1531    }
1532
1533    public void setComparisonType(EComparisonType comparisonType) {
1534        this.comparisonType = comparisonType;
1535    }
1536
1537    static  public  EComparisonType getComparisonType(TSourceToken comparisonOperator){
1538        String tokenStr = comparisonOperator.getAstext();
1539        EComparisonType ret = EComparisonType.equals;
1540        switch (comparisonOperator.tokencode){
1541            case TBaseType.not_equal:
1542                if ((tokenStr.startsWith("!")) && (tokenStr.endsWith("=") )){
1543                    ret = EComparisonType.notEqualToExclamation;
1544                }else if ((tokenStr.startsWith("^")) && (tokenStr.endsWith("=") )){
1545                    ret = EComparisonType.notEqualToCaret;
1546                }else if ((tokenStr.startsWith("<")) && (tokenStr.endsWith(">") )){
1547                    if ((tokenStr.indexOf("=",1) > 0)&&((tokenStr.startsWith("<")) && (tokenStr.endsWith(">") ))) {
1548                        ret = EComparisonType.nullSafeEquals;
1549                    }else{
1550                        ret = EComparisonType.notEqualToBrackets;
1551                    }
1552                }
1553                break;
1554            case TBaseType.great_equal:
1555                ret = EComparisonType.greaterThanOrEqualTo;
1556                break;
1557            case TBaseType.less_equal:
1558                ret = EComparisonType.lessThanOrEqualTo;
1559                break;
1560            case TBaseType.not_great:
1561                ret = EComparisonType.notGreaterThan;
1562                if (tokenStr.startsWith("^")){
1563                    ret = EComparisonType.notGreaterThanToCaret;
1564                }
1565                break;
1566            case TBaseType.not_less:
1567                ret = EComparisonType.notLessThan;
1568                if (tokenStr.startsWith("^")){
1569                    ret = EComparisonType.notLessThanToCaret;
1570                }
1571
1572                break;
1573            case '=':
1574                ret = EComparisonType.equals;
1575                if ((tokenStr.indexOf("=",1) > 0)&&((tokenStr.startsWith("<")) && (tokenStr.endsWith(">") ))) {
1576                  ret = EComparisonType.nullSafeEquals;
1577                }
1578                break;
1579            case '>':
1580                ret = EComparisonType.greaterThan;
1581                break;
1582            case '<':
1583                ret = EComparisonType.lessThan;
1584                break;
1585            default:
1586                if (comparisonOperator.toString().equalsIgnoreCase("includes")){
1587                    ret = EComparisonType.includes;
1588                }else if (comparisonOperator.toString().equalsIgnoreCase("excludes")){
1589                    ret = EComparisonType.excludes;
1590                }else if (comparisonOperator.toString().equalsIgnoreCase("above")){
1591                    ret = EComparisonType.above;
1592                }else if (comparisonOperator.toString().equalsIgnoreCase("at")){
1593                    ret = EComparisonType.at;
1594                }else if (comparisonOperator.toString().equalsIgnoreCase("above_or_below")){
1595                    ret = EComparisonType.above_or_below;
1596                }else if (comparisonOperator.toString().equalsIgnoreCase("below")){
1597                    ret = EComparisonType.below;
1598                }
1599                break;
1600        }
1601        return ret;
1602    }
1603
1604    private TAliasClause exprAlias;
1605
1606    /**
1607     * In Teradata, it is possible there is an alias for expression
1608     * @return expression alias
1609     */
1610    public TAliasClause getExprAlias() {
1611        return exprAlias;
1612    }
1613
1614    public void setExprAlias(TAliasClause exprAlias) {
1615
1616        this.exprAlias = exprAlias;
1617    }
1618
1619    private TPTNodeList <TExplicitDataTypeConversion> dataTypeConversionList = null;
1620
1621    public void setDataTypeConversionList(TPTNodeList<TExplicitDataTypeConversion> dataTypeConversionList) {
1622        this.dataTypeConversionList = dataTypeConversionList;
1623    }
1624
1625    /**
1626     *
1627     * @deprecated since v2.5.3.1, replaced by {@link #getDataConversions()}
1628     */
1629    public TPTNodeList<TExplicitDataTypeConversion> getDataTypeConversionList() {
1630
1631        return dataTypeConversionList;
1632    }
1633
1634    private TExplicitDataTypeConversion dataTypeConversion;
1635
1636    public void setDataTypeConversion(TExplicitDataTypeConversion dataTypeConversion) {
1637        this.dataTypeConversion = dataTypeConversion;
1638    }
1639
1640    /**
1641     *
1642     * @return the first DataTypeConversion in {@link #getDataTypeConversionList}
1643     *
1644     * @deprecated since v2.5.3.1, replaced by {@link #getDataConversions()}
1645     */
1646    public TExplicitDataTypeConversion getDataTypeConversion() {
1647        if (dataTypeConversionList == null) return  null;
1648        return dataTypeConversionList.getElement(0);
1649    }
1650
1651    private TAnalyticFunction over_clause;
1652    private TObjectName sequenceName;
1653
1654    public TObjectName getSequenceName() {
1655        return sequenceName;
1656    }
1657
1658    public TAnalyticFunction getOver_clause() {
1659        return over_clause;
1660    }
1661
1662    public THiveVariable getHive_variable() {
1663        return hive_variable;
1664    }
1665
1666    private THiveVariable hive_variable = null;
1667
1668    public void setHive_variable(THiveVariable hive_variable) {
1669        this.hive_variable = hive_variable;
1670    }
1671
1672    private boolean isSymmetric = false;
1673
1674    public void setSymmetric(boolean symmetric) {
1675        isSymmetric = symmetric;
1676    }
1677
1678    /**
1679     * PostgreSQL
1680     *
1681     * BETWEEN SYMMETRIC is the same as BETWEEN except there is no requirement
1682     * that the argument to the left of AND be less than or equal to the argument
1683     * on the right. If it is not, those two arguments are automatically swapped,
1684     * so that a nonempty range is always implied.
1685     *
1686     * @return true if SYMMETRIC is used
1687     */
1688    public boolean isSymmetric() {
1689
1690        return isSymmetric;
1691    }
1692
1693    private TObjectAccess objectAccess = null;
1694
1695    public void setObjectAccess(TObjectAccess objectAccess) {
1696        this.objectAccess = objectAccess;
1697    }
1698
1699    public TObjectAccess getObjectAccess() {
1700
1701        return objectAccess;
1702    }
1703
1704    private TSourceToken operatorToken = null;
1705    private TSourceToken notToken = null;
1706    private boolean notOperator = false;
1707
1708    public boolean isNotOperator() {
1709        return notOperator;
1710    }
1711
1712    public void setNotToken(TSourceToken notToken) {
1713        this.notToken = notToken;
1714        notOperator = (this.notToken != null);
1715    }
1716
1717    public TSourceToken getNotToken() {
1718
1719        return notToken;
1720    }
1721
1722    private long plainTextLineNo = -1;
1723
1724    public void setPlainTextLineNo(long plainTextLineNo) {
1725        this.plainTextLineNo = plainTextLineNo;
1726    }
1727
1728    public void setPlainTextColumnNo(long plainTextColumnNo) {
1729        this.plainTextColumnNo = plainTextColumnNo;
1730    }
1731
1732    public long getPlainTextLineNo() {
1733        return plainTextLineNo;
1734    }
1735
1736    public long getPlainTextColumnNo() {
1737        return plainTextColumnNo;
1738    }
1739
1740    private  long plainTextColumnNo = -1;
1741
1742    public TExpression(){
1743
1744    }
1745
1746    public TExpression(TObjectName objectOperand){
1747        this.expressionType = EExpressionType.simple_object_name_t;
1748        this.objectOperand = objectOperand;
1749    }
1750
1751    public TExpression(TConstant constantOperand){
1752//        if ((constantOperand != null) && (constantOperand.getLiteralType() == ELiteralType.etFakeDate)){
1753//            this.expressionType = EExpressionType.function_t;
1754//            this.functionCall = new TFunctionCall();
1755//            this.functionCall.setFunctionType(EFunctionType.date_t);
1756//            this.functionCall.setFunctionName(new TObjectName(EDbObjectType.function, constantOperand.getStartToken()));
1757//            this.functionCall.setStartToken(constantOperand.getStartToken());
1758//            this.functionCall.setEndToken(constantOperand.getEndToken());
1759//
1760//        }else{
1761            this.expressionType = EExpressionType.simple_constant_t;
1762            this.constantOperand = constantOperand;
1763//        }
1764    }
1765
1766    public TExpression(TFunctionCall functionCall){
1767        this.expressionType = EExpressionType.function_t;
1768        this.functionCall = functionCall;
1769    }
1770
1771    public void setExecuteSqlNode(TExecuteSqlNode executeSqlNode) {
1772        this.executeSqlNode = executeSqlNode;
1773    }
1774
1775    public TExpression(EExpressionType pExpressionType){
1776        this.expressionType = pExpressionType;
1777    }
1778
1779    public TExpression(EExpressionType pExpressionType, TExpression pLeft, TExpression pRight){
1780        this(pExpressionType);
1781        this.leftOperand = pLeft;
1782        this.rightOperand = pRight;
1783    }
1784
1785    public TExpression(EExpressionType pExpressionType, TExpression pLeft, TExpression pRight, EComparisonType pComparisonType){
1786        this(pExpressionType,pLeft,pRight);
1787        this.comparisonType = pComparisonType;
1788    }
1789
1790    public static TExpression createExpression(EDbVendor dbVendor, TConstant constantOperand){
1791        TExpression expression = new TExpression(EExpressionType.simple_constant_t);
1792        expression.setConstantOperand(constantOperand);
1793        expression.dbvendor = dbVendor;
1794        return expression;
1795
1796    }
1797    public static TExpression createExpression(EDbVendor dbVendor, TObjectName objectOperand){
1798        TExpression expression = new TExpression(EExpressionType.simple_object_name_t);
1799        expression.setObjectOperand(objectOperand);
1800        expression.dbvendor = dbVendor;
1801        return expression;
1802    }
1803    public static TExpression createExpression(EDbVendor dbVendor,EExpressionType pExpressionType, TSourceToken pOperatorToken, TObjectName pLeft, TObjectName pRight){
1804        return TExpression.createExpression(dbVendor, pExpressionType, pOperatorToken
1805                , TExpression.createExpression(dbVendor, pLeft)
1806                , TExpression.createExpression(dbVendor, pRight)
1807        );
1808    }
1809
1810    public static TExpression createExpression(EDbVendor dbVendor,EExpressionType pExpressionType, TSourceToken pOperatorToken, TObjectName pLeft, TConstant pRight){
1811        return TExpression.createExpression(dbVendor, pExpressionType, pOperatorToken
1812                , TExpression.createExpression(dbVendor, pLeft)
1813                , TExpression.createExpression(dbVendor, pRight)
1814        );
1815    }
1816
1817    public static TExpression createExpression(EDbVendor dbVendor,EExpressionType pExpressionType, TSourceToken pOperatorToken, TExpression pLeft, TExpression pRight){
1818        TExpression expression = new TExpression(pExpressionType);
1819        expression.setOperatorToken(pOperatorToken);
1820        expression.setLeftOperand(pLeft);
1821        expression.setRightOperand(pRight);
1822        expression.dbvendor = dbVendor;
1823        return expression;
1824    }
1825
1826    public static TExpression createParenthesisExpression(TExpression pLeft){
1827        TExpression expression = new TExpression(EExpressionType.parenthesis_t);
1828        expression.setLeftOperand(pLeft);
1829        expression.dbvendor = pLeft.dbvendor;
1830        return expression;
1831    }
1832
1833    public void init(Object arg1){
1834        expressionType = (EExpressionType)arg1;
1835        if ((expressionType == EExpressionType.logical_and_t)||(expressionType == EExpressionType.logical_or_t)){
1836            flattenVisitor = new TFlattenVisitor();
1837        }
1838    }
1839    private TSourceToken leadingPrecision;
1840    private TSourceToken fractionalSecondsPrecision;
1841
1842    public void setLeadingPrecision(TSourceToken leadingPrecision) {
1843        this.leadingPrecision = leadingPrecision;
1844    }
1845
1846    public void setFractionalSecondsPrecision(TSourceToken fractionalSecondsPrecision) {
1847        this.fractionalSecondsPrecision = fractionalSecondsPrecision;
1848    }
1849
1850    public TSourceToken getLeadingPrecision() {
1851
1852        return leadingPrecision;
1853    }
1854
1855    public TSourceToken getFractionalSecondsPrecision() {
1856        return fractionalSecondsPrecision;
1857    }
1858
1859    public void init(Object arg1, Object arg2){
1860         init(arg1);
1861         switch (expressionType){
1862             case next_value_for_t:
1863                sequenceName = (TObjectName)arg2;
1864                break;
1865             case array_constructor_t:
1866                 if (arg2 instanceof TSelectSqlNode){
1867                     this.subQueryNode = (TSelectSqlNode)arg2;
1868                 }else if (arg2 instanceof TExpressionList){
1869                     this.exprList = (TExpressionList)arg2;
1870                 }else if (arg2 instanceof TArrayConstruct){
1871                     this.arrayConstruct = (TArrayConstruct)arg2;
1872                 }else if (arg2 instanceof TColumnDefinitionList){
1873                     this.colDefList = (TColumnDefinitionList) arg2;
1874                 }
1875                  break;
1876             case objectConstruct_t:
1877                 objectConstruct = (TObjectConstruct)arg2;
1878                 break;
1879             case namedParameter_t:
1880                 namedParameter = (TNamedParameter)arg2;
1881                 break;
1882             case positionalParameter_t:
1883                 positionalParameter = (TPositionalParameter)arg2;
1884                 break;
1885             case collectionArray_t:
1886                 collectionArray = (TCollectionArray)arg2;
1887                 break;
1888             case collectionCondition_t:
1889                 collectionCondition = (TCollectionCondition)arg2;
1890                 break;
1891             case year_to_month_t:
1892             case day_to_second_t:
1893             case at_local_t:
1894                 leftOperand = (TExpression)arg2;
1895                 break;
1896             case teradata_at_t:
1897                    leftOperand = (TExpression)arg1;
1898                    rightOperand = (TExpression)arg2;
1899                    break;
1900             case unnest_t:
1901                 leftOperand = (TExpression)arg2;
1902                 break;
1903             case list_t:
1904             case collection_constructor_list_t:
1905             case collection_constructor_multiset_t:
1906             case collection_constructor_set_t:
1907                 exprList = (TExpressionList)arg2;
1908                 break;
1909             case json_path_t:
1910                 this.json_path = (ArrayList<TIndices>)arg2;
1911                 break;
1912             case type_constructor_t:
1913                 objectOperand = (TObjectName) arg2;
1914                 break;
1915             case new_structured_type_t:
1916                 exprList = (TExpressionList)arg2;
1917                 break;
1918             default:
1919                 break;
1920         }
1921    }
1922
1923    public void init(Object arg1, Object arg2, Object arg3){
1924         init(arg1);
1925         switch (expressionType){
1926             case next_value_for_t:
1927                sequenceName = (TObjectName)arg2;
1928                 if (arg3 == null){
1929                 }else if (arg3 instanceof TExpression){
1930                     leftOperand = (TExpression)arg3;
1931                 }else if (arg3 instanceof TAnalyticFunction){
1932                    over_clause = (TAnalyticFunction)arg3;
1933                 }
1934                break;
1935             case assignment_t:
1936                 leftOperand = (TExpression)arg2;
1937                 rightOperand   = (TExpression)arg3;
1938                 break;
1939             case typecast_datatype_t:
1940                 //castDatatype = (EDataType)arg2;
1941                 typeName = (TTypeName)arg2;
1942                 leftOperand = (TExpression)arg3;
1943                 break;
1944             case json_access_t:
1945                 leftOperand = (TExpression)arg2;
1946                 rightOperand   = (TExpression)arg3;
1947                     break;
1948             case type_constructor_t:
1949                 objectOperand = (TObjectName) arg2;
1950                 exprList = (TExpressionList)arg3;
1951                 break;
1952             case cursor_attribute_t:
1953                 break;
1954             default:
1955                 leftOperand = (TExpression)arg2;
1956                 rightOperand   = (TExpression)arg3;
1957                 break;
1958         }
1959    }
1960
1961    /**
1962     * initialize a new instance of TExpression.
1963     *
1964     * @param arg1 type of this expression, a value of type {@link EExpressionType}
1965     * @param arg2 operator, a value of {@link TSourceToken}
1966     * @param arg3 left operand, a value of {@link TExpression}
1967     * the meaning of this parameter varies depends on the value of arg1.
1968     * @param arg4 right operand, a value of {@link TExpression}
1969     */
1970    public void init(Object arg1,Object arg2,Object arg3,Object arg4){
1971        init(arg1);
1972        operatorToken = (TSourceToken)arg2;
1973        switch (expressionType){
1974            case simple_object_name_t:
1975                objectOperand = (TObjectName)arg3;
1976                setStartToken(objectOperand);
1977                setEndToken(objectOperand);
1978                break;
1979            case simple_source_token_t:
1980                sourcetokenOperand = (TSourceToken)arg3;
1981                setStartToken(sourcetokenOperand);
1982                setEndToken(sourcetokenOperand);
1983                break;
1984            case simple_constant_t:
1985                constantOperand = (TConstant)arg3;
1986                setStartToken(constantOperand);
1987                setEndToken(constantOperand);
1988                break;
1989            case function_t:
1990                functionCall = (TFunctionCall)arg3;
1991                break;
1992//            case type_constructor_t:
1993//                functionCall = (TFunctionCall)arg3;
1994//                break;
1995            case arrayaccess_t:
1996                arrayAccess = (TArrayAccess)arg3;
1997                break;
1998            case array_access_expr_t:
1999                leftOperand = (TExpression)arg3;
2000                rightOperand   = (TExpression)arg4;
2001                break;
2002            case list_t:
2003            case collection_constructor_list_t:
2004            case collection_constructor_multiset_t:
2005            case collection_constructor_set_t:
2006                exprList = (TExpressionList)arg3;
2007                break;
2008            case field_doubt_t:
2009                TExpression l = (TExpression)arg3;
2010                if (l.getExpressionType() == EExpressionType.simple_object_name_t){
2011                    TObjectName objectName = l.getObjectOperand();
2012                    objectName.setSchemaToken(objectName.getObjectToken());
2013                    objectName.setObjectToken(objectName.getPartToken());
2014                    objectName.setPartToken((TSourceToken)arg4);
2015
2016                    expressionType = EExpressionType.simple_object_name_t;
2017                    this.objectOperand = l.getObjectOperand();
2018                }else {
2019                    expressionType = EExpressionType.field_t;
2020                }
2021                break;
2022            case column_definition_list_t:
2023                colDefList = (TColumnDefinitionList)arg3;
2024                break;
2025            case simple_comparison_t:
2026                leftOperand = (TExpression)arg3;
2027                leftOperand.setParentExpr(this);
2028                rightOperand = (TExpression)arg4;
2029                rightOperand.setParentExpr(this);
2030                comparisonOperator  = operatorToken;
2031                break;
2032            case implicit_datatype_cast_as_t:
2033                leftOperand = (TExpression)arg3;
2034                typeName = (TTypeName)arg4;
2035                break;
2036            default:
2037                if (arg3 != null){
2038                    leftOperand = (TExpression)arg3;
2039                    leftOperand.setParentExpr(this);
2040                }
2041                if (arg4 != null){
2042                    rightOperand = (TExpression)arg4;
2043                    rightOperand.setParentExpr(this);
2044                }
2045                break;
2046        }
2047    }
2048
2049    public void setOperatorToken(TSourceToken operatorToken) {
2050        this.operatorToken = operatorToken;
2051        switch (this.getExpressionType()){
2052            case unknown_t:
2053                switch (this.operatorToken.tokencode){
2054                    case TBaseType.OP_MINUS_GREAT:
2055                        this.expressionType =  EExpressionType.json_get_object;
2056                        break;
2057                    case TBaseType.OP_MINUS_GREAT_GREAT:
2058                        this.expressionType =  EExpressionType.json_get_text;
2059                        break;
2060                    case TBaseType.OP_POUND_GREAT_GREAT:
2061                        this.expressionType =  EExpressionType.json_get_text_at_path;
2062                        break;
2063                    case TBaseType.OP_POUND_GREAT:
2064                        this.expressionType =  EExpressionType.json_get_object_at_path;
2065                        break;
2066                    case TBaseType.OP_AT_GREAT:
2067                        this.expressionType =  EExpressionType.json_left_contain;
2068                        break;
2069                    case TBaseType.OP_LESS_AT:
2070                        this.expressionType =  EExpressionType.json_right_contain;
2071                        break;
2072                    case TBaseType.OP_JSONB_QUESTION: // ?
2073                        this.expressionType =  EExpressionType.json_exist;
2074                        break;
2075                    case TBaseType.OP_QUESTION_BAR:
2076                        this.expressionType =  EExpressionType.json_any_exist;
2077                        break;
2078                    case TBaseType.OP_QUESTION_PUNCTUATION:
2079                        this.expressionType =  EExpressionType.json_all_exist;
2080                        break;
2081                    case TBaseType.OP_TILDE_TILDE:
2082                        this.expressionType =  EExpressionType.pattern_matching_t;
2083                        break;
2084                    case TBaseType.OP_TILDE_TILDE_STAR:
2085                        this.expressionType =  EExpressionType.pattern_matching_t;
2086                        break;
2087                    case TBaseType.OP_EXCLAMATION_TIDLE_TIDLE:
2088                        this.expressionType =  EExpressionType.pattern_matching_t;
2089                        break;
2090                    case TBaseType.OP_EXCLAMATION_TIDLE_TIDLE_STAR:
2091                        this.expressionType =  EExpressionType.pattern_matching_t;
2092                        break;
2093                    case TBaseType.OP_TILDE_STAR:
2094                        this.expressionType =  EExpressionType.pattern_matching_t;
2095                        break;
2096                    case TBaseType.OP_EXCLAMATION_TILDE:
2097                        this.expressionType =  EExpressionType.pattern_matching_t;
2098                        this.setNotToken(operatorToken);
2099                        break;
2100                    case TBaseType.OP_EXCLAMATION_TIDLE_STAR:
2101                        this.expressionType =  EExpressionType.pattern_matching_t;
2102                        break;
2103                    case TBaseType.OP_TILDE_GREAT_TILDE:
2104                    case TBaseType.OP_TILDE_LESS_TILDE:
2105                    case TBaseType.OP_TILDE_GREAT_EQUAL_TILDE:
2106                    case TBaseType.OP_TILDE_LESS_EQUAL_TILDE:
2107                        this.expressionType =  EExpressionType.pattern_matching_t;
2108                        break;
2109                    case '~':
2110                        this.expressionType =  EExpressionType.pattern_matching_t;
2111                        break;
2112                    case TBaseType.OP_AT_MINUS_AT:
2113                    case TBaseType.OP_POUND_POUND:
2114                    case TBaseType.OP_PUNCTUATION_LESS:
2115                    case TBaseType.OP_PUNCTUATION_GREAT:
2116                    case TBaseType.OP_LESS_LESS_BAR:
2117                    case TBaseType.OP_BAR_GREAT_GREAT:
2118                    case TBaseType.OP_PUNCTUATION_LESS_BAR:
2119                    case TBaseType.OP_BAR_PUNCTUATION_GREAT:
2120                    case TBaseType.OP_LESS_CARET:
2121                    case TBaseType.OP_GREAT_CARET:
2122                    case TBaseType.OP_QUESTION_POUND:
2123                    case TBaseType.OP_QUESTION_MINUS:
2124                    case TBaseType.OP_QUESTION_MINUS_BAR:
2125                    case TBaseType.OP_QUESTION_BAR_BAR:
2126                    case TBaseType.OP_TILDE_EQUAL:
2127                    case TBaseType.OP_LESS_PERCENT:
2128                    case TBaseType.OP_GREAT_PERCENT:
2129                        this.expressionType =  EExpressionType.geo_t;
2130                        break;
2131                    case TBaseType.OP_LESS_LESS_EQUAL:
2132                    case TBaseType.OP_GREAT_GREAT_EQUAL:
2133                        this.expressionType =  EExpressionType.network_t;
2134                        break;
2135                    case TBaseType.OP_AT_AT_AT:
2136                    case TBaseType.OP_LESS_MINUS_GREAT:
2137                    case TBaseType.OP_LESS_HASH_GREAT:
2138                    case TBaseType.OP_LESS_EQUAL_GREAT:
2139                    case TBaseType.OP_LESS_PLUS_GREAT:
2140                    case TBaseType.OP_LESS_TILDE_GREAT:
2141                    case TBaseType.OP_LESS_PERCENT_GREAT:
2142                        this.expressionType =  EExpressionType.text_search_t;
2143                        break;
2144                    case TBaseType.OP_MINUS_BAR_MINUS:
2145                        this.expressionType = EExpressionType.range_t;
2146                        break;
2147                    case TBaseType.OP_PUNCTUATION_PUNCTUATION:
2148                        // '&&' — PostgreSQL-family overlaps operator
2149                        // (array/range/geometric), e.g. tags && ARRAY['a','b']
2150                        this.expressionType = EExpressionType.overlaps_t;
2151                        break;
2152                    case TBaseType.rrw_netezza_op_less_less:
2153                        this.expressionType = EExpressionType.left_shift_t;
2154                        break;
2155                    case TBaseType.rrw_netezza_op_great_great:
2156                        this.expressionType = EExpressionType.right_shift_t;
2157                        break;
2158                    case TBaseType.OP_POUND_MINUS:
2159                        this.expressionType = EExpressionType.json_delete_path;
2160                        break;
2161                    case TBaseType.OP_AT_QUESTION:
2162                        this.expressionType = EExpressionType.json_path_exists;
2163                        break;
2164                    case TBaseType.OP_AT_AT:
2165                        this.expressionType = EExpressionType.json_path_match;
2166                        break;
2167                    default:
2168                        break;
2169                }
2170
2171
2172                if (this.getExpressionType() == EExpressionType.unknown_t) {
2173                    if(this.operatorToken.toString().equalsIgnoreCase("%")){
2174                        this.expressionType =  EExpressionType.arithmetic_modulo_t;
2175                    }else if(this.operatorToken.toString().equalsIgnoreCase("&")){
2176                        this.expressionType = EExpressionType.bitwise_and_t;
2177                    }else if(this.operatorToken.toString().equalsIgnoreCase("|")){
2178                        this.expressionType = EExpressionType.bitwise_or_t;
2179                    }else if(this.operatorToken.toString().equalsIgnoreCase("#")){
2180                        this.expressionType = EExpressionType.bitwise_xor_t;
2181                    }else if(this.operatorToken.toString().equalsIgnoreCase("<<")){
2182                        this.expressionType = EExpressionType.left_shift_t;
2183                    }else if(this.operatorToken.toString().equalsIgnoreCase(">>")){
2184                        this.expressionType = EExpressionType.right_shift_t;
2185                    }else if(this.operatorToken.toString().equals("&&")){ // non-identifier-compare: operator token text
2186                        // vendors whose lexers emit '&&' as a generic operator
2187                        // token (e.g. Greenplum) rather than
2188                        // OP_PUNCTUATION_PUNCTUATION (Mantis 4608)
2189                        this.expressionType = EExpressionType.overlaps_t;
2190                    }
2191                }
2192
2193                break;
2194            case unary_left_unknown_t:
2195                if(this.operatorToken.toString().equalsIgnoreCase("|/")){
2196                    this.expressionType = EExpressionType.unary_squareroot_t;
2197                }else if(this.operatorToken.toString().equalsIgnoreCase("||/")){
2198                    this.expressionType = EExpressionType.unary_cuberoot_t;
2199                }else if(this.operatorToken.toString().equalsIgnoreCase("!!")){
2200                    this.expressionType = EExpressionType.unary_factorialprefix_t;
2201                }else if(this.operatorToken.toString().equalsIgnoreCase("@")){
2202                    this.expressionType = EExpressionType.unary_absolutevalue_t;
2203                }else if(this.operatorToken.toString().equalsIgnoreCase("~")){
2204                    this.expressionType = EExpressionType.unary_bitwise_not_t;
2205                }else if(this.operatorToken.toString().equalsIgnoreCase("-")){
2206                    this.expressionType = EExpressionType.unary_minus_t;
2207                }else if(this.operatorToken.toString().equalsIgnoreCase("+")){
2208                    this.expressionType = EExpressionType.unary_plus_t;
2209                }
2210
2211                break;
2212            case unary_right_unknown_t:
2213                if(this.operatorToken.toString().equalsIgnoreCase("!")) {
2214                    this.expressionType = EExpressionType.unary_factorial_t;
2215                }
2216                break;
2217            default:
2218                break;
2219        }
2220
2221    }
2222
2223
2224    private ArrayList<TSourceToken> operatorTokens = null;
2225
2226    /**
2227     * Operator token used in expression which contains multiple operator tokens such as SIMILAR TO , IS DISTINCT FROM and etc
2228     * added since v3.0.8.6
2229     *
2230     * @return operator token list
2231     */
2232    public ArrayList<TSourceToken> getOperatorTokens() {
2233        if (operatorTokens == null){
2234            operatorTokens = new ArrayList<>();
2235        }
2236        return operatorTokens;
2237    }
2238
2239    /**
2240     * Operator token used in expression such as +,-,*,/ and etc
2241     * @return operator token
2242     */
2243    public TSourceToken getOperatorToken() {
2244
2245        return operatorToken;
2246    }
2247
2248    public void setVal(Object val) {
2249        this.val = val;
2250    }
2251
2252    private boolean valPartial = false;
2253
2254    /**
2255     * True when {@link #getVal()} holds a string value that contains
2256     * placeholder identifiers for unknowable parts (unresolved variables,
2257     * function calls), e.g. a concatenation where only some operands are
2258     * string literals. Partially resolved dynamic SQL is still analyzed for
2259     * approximate lineage, but parse failures must not be reported as syntax
2260     * errors because the text was never the real SQL.
2261     */
2262    public boolean isValPartial() {
2263        return valPartial;
2264    }
2265
2266    public void setValPartial(boolean valPartial) {
2267        this.valPartial = valPartial;
2268    }
2269
2270    /**
2271     * value of this expression, valid only after evaluate this expression.
2272     * @return a value object
2273     */
2274    public Object getVal() {
2275
2276        return val;
2277    }
2278
2279    private Object val = null;
2280
2281    // expression type value
2282
2283    // simple expression
2284
2285
2286    public TConstant getConstantOperand() {
2287        return constantOperand;
2288    }
2289
2290
2291    public void setNewVariantTypeArgumentList(TNewVariantTypeArgumentList newVariantTypeArgumentList) {
2292        this.newVariantTypeArgumentList = newVariantTypeArgumentList;
2293    }
2294
2295    public TNewVariantTypeArgumentList getNewVariantTypeArgumentList() {
2296        return newVariantTypeArgumentList;
2297    }
2298
2299    private TNewVariantTypeArgumentList newVariantTypeArgumentList = null;
2300
2301    /**
2302     * PLSQL:
2303     * <p> expr typecast typename
2304     * <p>
2305     * <p> Postgresql
2306     * <p> expr::typename
2307     * <p>
2308     * <p> Informix
2309     * <p> expr::typename
2310     * <p>
2311     * <p> expr can be accessed via {@link #leftOperand}, typename can be accessed via {@link #getTypeName()}
2312     */
2313
2314    private  TTypeName typeName;
2315
2316    public void setTypeName(TTypeName typeName) {
2317        this.typeName = typeName;
2318    }
2319
2320    public TTypeName getTypeName() {
2321
2322        return typeName;
2323    }
2324
2325    /**
2326     * valid when {@link #getExpressionType() } is {@link TExpression#fieldSelection}
2327     * @return field name
2328     */
2329    public TObjectName getFieldName() {
2330        return fieldName;
2331    }
2332
2333    private  TObjectName fieldName;
2334
2335    public void setIndirection(TIndirection indirection) {
2336        if (indirection != null){
2337            if (indirection.isRealIndices()){
2338                this.subscripts = true;
2339            }else{
2340                //this.setExpressionType(TExpression.fieldSelection);
2341                setExpressionType(EExpressionType.fieldselection_t);
2342                this.fieldName = indirection.getIndices().getElement(0).getAttributeName();
2343                //this.fieldName.setObjectType(TObjectName.ttobjFieldName);
2344                this.fieldName.setDbObjectType(EDbObjectType.fieldName);
2345            }
2346            this.indirection = indirection;
2347        }
2348    }
2349
2350    private  boolean  subscripts;
2351
2352    /**
2353     * If an expression yields a value of an array type, then a specific element of the array value can be extracted by writing
2354     * <p> expression[subscript]
2355     * <p> or multiple adjacent elements (an "array slice") can be extracted by writing
2356     * <p> expression[lower_subscript:upper_subscript]
2357     * <p> In general the array expression must be parenthesized, but the parentheses can be omitted when the expression to be subscripted is just a column reference or positional parameter.
2358     * <p> Also, multiple subscripts can be concatenated when the original array is multidimensional. For example:
2359     * <p>
2360     * <p> when sytnax like this:
2361     * <p> mytable.arraycolumn[4]
2362     * <p> mytable.two_d_column[17][34]
2363     * <p> $1[10:42]
2364     * <p>
2365     * <p> check {@link #getObjectOperand()} for more detailed information about subscript.
2366     * <p>
2367     * <p> when syntax like this:
2368     * <p> (arrayfunction(a,b))[42]
2369     * <p>
2370     * <p> check {@link #getIndirection()} when {@link #isSubscripts()} is true.
2371     * @return tells whether it is an expression with subscript.
2372     */
2373    public boolean isSubscripts() {
2374        return subscripts;
2375    }
2376
2377    public ArrayList<TIndices> getJson_path() {
2378        return json_path;
2379    }
2380
2381    private ArrayList<TIndices> json_path;
2382
2383    public TIndirection getIndirection() {
2384        return indirection;
2385    }
2386
2387    private TIndirection indirection;
2388
2389    private boolean notModifier;
2390
2391    /**
2392     * return true for expression like this: <expr> NOT IS NULL, <expr> NOT LIKE <expr> , <expr> NOT BETWEEN <expr> AND <expr>
2393     * and return false for expression like this: <expr> IS NULL, <expr> LIKE <expr> , <expr> BETWEEN <expr> AND <expr>
2394     * @return
2395     */
2396
2397    /**
2398     * @deprecated As of v1.4.3.0, replaced by {@link #getNotToken()}
2399     */
2400    public boolean isNotModifier() {
2401        notModifier = (getOperatorToken() != null);
2402        if (notModifier){
2403            notModifier = (getOperatorToken().tokencode == TBaseType.rrw_not);
2404        }
2405        return notModifier;
2406    }
2407
2408    private  TOutputFormatPhraseList outputFormatPhraseList;
2409
2410    public void setOutputFormatPhraseList(TOutputFormatPhraseList outputFormatPhraseList) {
2411        this.outputFormatPhraseList = outputFormatPhraseList;
2412    }
2413
2414    /**
2415     * teradata:
2416     * <p>column_expr (named alias_name)
2417     * @return (named alias_name) in column_expr
2418     */
2419    public TOutputFormatPhraseList getOutputFormatPhraseList() {
2420
2421        return outputFormatPhraseList;
2422    }
2423
2424    public TExpressionList getExprList() {
2425        return exprList;
2426    }
2427
2428    private TIntervalExpression intervalExpr = null;
2429
2430    public void setIntervalExpr(TIntervalExpression intervalExpr) {
2431        this.intervalExpr = intervalExpr;
2432    }
2433
2434    public TIntervalExpression getIntervalExpr() {
2435
2436        return intervalExpr;
2437    }
2438
2439    private TExpressionList exprList = null;
2440
2441    private TExceptReplaceClause exceptReplaceClause;
2442
2443    public TExceptReplaceClause getExceptReplaceClause() {
2444        if (exceptReplaceClause == null) {
2445            if (this.getObjectOperand()!=null) {
2446                if (this.getObjectOperand().getExceptReplaceClause()!=null) {
2447                    exceptReplaceClause = this.getObjectOperand().getExceptReplaceClause();
2448                }else if (this.getIndirection()!=null) {
2449                    if (this.getIndirection().getIndices()!=null) {
2450                        if (this.getIndirection().getIndices().size()>0) {
2451                            exceptReplaceClause = this.getIndirection().getIndices().getElement(0).getAttributeName().getExceptReplaceClause();
2452                        }
2453                    }
2454                }
2455            }
2456        }
2457        return exceptReplaceClause;
2458    }
2459
2460    public void setExceptReplaceClause(TExceptReplaceClause exceptReplaceClause) {
2461        this.exceptReplaceClause = exceptReplaceClause;
2462    }
2463
2464    private TObjectNameList fieldList;
2465
2466    public void setFieldList(TObjectNameList fieldList) {
2467        this.fieldList = fieldList;
2468    }
2469
2470    public TObjectNameList getFieldList() {
2471
2472        return fieldList;
2473    }
2474
2475    private TInExpr inExpr = null;
2476
2477    public void setInExpr(TInExpr inExpr) {
2478        this.inExpr = inExpr;
2479    }
2480
2481    /**
2482     * @deprecated As of v1.4.3.3, replaced by {@link #getRightOperand()}
2483     */
2484    public TInExpr getInExpr() {
2485        return inExpr;
2486    }
2487
2488
2489    public void setExprList(TExpressionList exprList) {
2490        this.exprList = exprList;
2491    }
2492
2493    public void setOracleOuterJoin(boolean oracleOuterJoin) {
2494        isOracleOuterJoin = oracleOuterJoin;
2495    }
2496
2497    public boolean isOracleOuterJoin() {
2498        return isOracleOuterJoin;
2499    }
2500
2501    /**
2502     *  Proprietary jion syntax of oracle: column(+)
2503     */
2504    private boolean isOracleOuterJoin = false;
2505
2506    /**
2507     * ClickHouse GLOBAL IN / GLOBAL NOT IN modifier.
2508     * When true, indicates the IN operator uses the GLOBAL keyword for distributed query execution.
2509     */
2510    private boolean globalIn = false;
2511
2512    public boolean isGlobalIn() {
2513        return globalIn;
2514    }
2515
2516    public void setGlobalIn(boolean globalIn) {
2517        this.globalIn = globalIn;
2518    }
2519
2520    private TExpression parentExpr;
2521
2522    public TExpression getParentExpr() {
2523        return parentExpr;
2524    }
2525
2526    public void setParentExpr(TExpression parentExpr) {
2527        this.parentExpr = parentExpr;
2528    }
2529
2530    public boolean isLeftOperandOfParent(){
2531        if (this.getParentExpr() == null) return false;
2532        return  (this == this.getParentExpr().getLeftOperand());
2533    }
2534
2535    public boolean isRightOperandOfParent(){
2536        if (this.getParentExpr() == null) return false;
2537        return  (this == this.getParentExpr().getRightOperand());
2538    }
2539
2540    public void setLeftOperand(TExpression leftOperand) {
2541        this.leftOperand = leftOperand;
2542        if (leftOperand != null){
2543            leftOperand.setParentExpr(this);
2544        }
2545
2546//        if (leftOperand == null){
2547//            TParseTreeNode.removeTokensBetweenNodes(this.leftOperand,this.rightOperand);
2548//        }
2549//
2550//        this.setNewSubNode(this.leftOperand,leftOperand,null);
2551//        this.leftOperand = leftOperand;
2552//        if (this.getNodeStatus() == ENodeStatus.nsRemoved){
2553//            // remove this expr cascade due to the left operand was removed
2554//            if (this.getParentExpr() != null){
2555//                if (this == this.getParentExpr().getLeftOperand()){
2556//                    if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
2557//                        this.getParentExpr().refreshAllNodesTokenCount();
2558//                        this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain());
2559//                        this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken());
2560//                    }
2561//                }else{
2562//                    if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
2563//                        this.getParentExpr().refreshAllNodesTokenCount();
2564//                        this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken());
2565//                        this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken());
2566//                    }
2567//                }
2568//            }
2569//            this.setStartTokenDirectly(null);
2570//            this.setEndTokenDirectly(null);
2571//        }
2572//
2573    }
2574
2575    public void setRightOperand(TExpression rightOperand) {
2576
2577        this.rightOperand = rightOperand;
2578        if (rightOperand != null){
2579            rightOperand.setParentExpr(this);
2580        }
2581
2582//        if (rightOperand == null){
2583//            TParseTreeNode.removeTokensBetweenNodes(this.leftOperand,this.rightOperand);
2584//        }
2585//
2586//        this.setNewSubNode(this.rightOperand,rightOperand,null);
2587//        this.rightOperand = rightOperand;
2588//
2589//        if (this.getNodeStatus() == ENodeStatus.nsRemoved){
2590//            // remove this expr cascade due to the left operand was removed
2591//            if (this.getParentExpr() != null){
2592//                if (this == this.getParentExpr().getLeftOperand()){
2593//                    if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
2594//                        this.getParentExpr().refreshAllNodesTokenCount();
2595//                        this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain());
2596//                        this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken());
2597//                    }
2598//                }else{
2599//                    if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
2600//                        this.getParentExpr().refreshAllNodesTokenCount();
2601//                        this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken());
2602//                        this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken());
2603//                    }
2604//                }
2605//            }
2606//            this.setStartTokenDirectly(null);
2607//            this.setEndTokenDirectly(null);
2608//        }
2609//
2610//        if (rightOperand != null){
2611//            rightOperand.setParentExpr(this);
2612//        }
2613    }
2614
2615    private TExpression leftOperand;
2616    private TExpression rightOperand;
2617
2618    private TArrayAccess arrayAccess = null;
2619
2620
2621    /*
2622     *
2623     * @return if leftOperand is not null, then return leftOperand,
2624     * otherwise, check other possible parse tree node that might be in left side of this expression.
2625     * <p>This function was called in preOrderTraverse, inOrderTraverse and postOrderTraverse
2626     * <p>This function is only valid when {@link gudusoft.gsqlparser.nodes.TExpression#isLeaf()} is not true.
2627     *
2628     * <p>take this expression for example:
2629     * <p>f in (1,2,3)
2630     * <p> rightOperand is null, but getRightNode() should return (1,2,3) which is {@link TExpression#exprList}
2631     *
2632    public TParseTreeNode getLeftNode() {
2633        TParseTreeNode ret = this.leftOperand;
2634        if ( ret == null) {
2635            ret = this.leftNode;
2636        }
2637        return ret;
2638    }
2639     */
2640
2641    /*
2642     *
2643     * @return if rightOperand is not null, then return rightOperand,
2644     * otherwise, check other possible parse tree node that might be in right side of this expression.
2645     * <p>This function was called in preOrderTraverse, inOrderTraverse and postOrderTraverse
2646     * <p>This function is only valid when {@link gudusoft.gsqlparser.nodes.TExpression#isLeaf()} is not true.
2647
2648     * <p>take this expression for example:
2649     * <p>f in (1,2,3)
2650     * <p> rightOperand is null, but getRightNode() should return (1,2,3) which is {@link TExpression#exprList}
2651    public TParseTreeNode getRightNode(){
2652        TParseTreeNode ret = this.rightOperand;
2653        if ( ret == null) {
2654            ret = this.rightNode;
2655        }
2656        return ret;
2657    }
2658     */
2659
2660    /**
2661     *
2662     * @return right operand of this expression which should be type of TExpression
2663     */
2664    public TExpression getRightOperand() {
2665        return rightOperand;
2666    }
2667
2668    /**
2669     *
2670     * @return left operand of this expression which should be type of TExpression
2671     */
2672    public TExpression getLeftOperand() {
2673
2674        return leftOperand;
2675    }
2676
2677    public TExpression getLikeEscapeOperand() {
2678        return likeEscapeOperand;
2679    }
2680
2681    public TExpression getBetweenOperand() {
2682        return betweenOperand;
2683    }
2684
2685    public TArrayAccess getArrayAccess() {
2686        return arrayAccess;
2687    }
2688
2689    private EExpressionType expressionType = EExpressionType.not_initialized_yet_t;
2690
2691    /**
2692     * change return type from int to EExpressionType since 1.4.3.0
2693     * @return a value of {@link EExpressionType}
2694     */
2695    public EExpressionType getExpressionType() {
2696        return expressionType;
2697    }
2698
2699    /**
2700     *
2701     * @param exprType type to distinguish expression, change type from int to
2702     * EExpressionType since 1.4.3.0
2703     */
2704    public void setExpressionType(EExpressionType exprType) {
2705        this.expressionType = exprType;
2706    }
2707
2708    //private int expressionType = unknown;
2709
2710    public void setObjectOperand(TObjectName objectOperand) {
2711        this.objectOperand = objectOperand;
2712    }
2713
2714    public TObjectName getObjectOperand() {
2715        return objectOperand;
2716    }
2717
2718    private TObjectName objectOperand;
2719
2720    public void setConstantOperand(TConstant constantOperand) {
2721        this.constantOperand = constantOperand;
2722    }
2723
2724    private TConstant constantOperand;
2725
2726    public TSourceToken getSourcetokenOperand() {
2727        return sourcetokenOperand;
2728    }
2729
2730    public void setSourcetokenOperand(TSourceToken sourcetokenOperand) {
2731        this.sourcetokenOperand = sourcetokenOperand;
2732    }
2733
2734    private TSourceToken sourcetokenOperand;
2735
2736    public void setCaseExpression(TCaseExpression caseExpression) {
2737        this.caseExpression = caseExpression;
2738    }
2739
2740    public TCaseExpression getCaseExpression() {
2741        return caseExpression;
2742    }
2743
2744    private TCaseExpression caseExpression;
2745
2746    /**
2747     * @deprecated As of v1.4.3.3
2748     */
2749    public void setArrayAccess(TArrayAccess arrayAccess) {
2750        this.arrayAccess = arrayAccess;
2751    }
2752
2753    private TExecuteSqlNode executeSqlNode;
2754
2755    public TExecuteSqlNode getExecuteSqlNode() {
2756        return executeSqlNode;
2757    }
2758
2759    private TCallSqlNode callSqlNode;
2760
2761    public TCallSqlNode getCallSqlNode() {
2762        return callSqlNode;
2763    }
2764
2765    public void setCallSqlNode(TCallSqlNode callSqlNode) {
2766        this.callSqlNode = callSqlNode;
2767    }
2768
2769    public void setSubQueryNode(TSelectSqlNode subQueryNode) {
2770        this.subQueryNode = subQueryNode;
2771    }
2772
2773    private TSelectSqlNode subQueryNode = null;
2774
2775    public void setSubQuery(TSelectSqlStatement subQuery) {
2776        this.subQuery = subQuery;
2777    }
2778
2779    public TSelectSqlStatement getSubQuery() {
2780        return subQuery;
2781    }
2782
2783    private TSelectSqlStatement subQuery = null;
2784
2785    public void setSubQueryInStmt(boolean subQueryInStmt) {
2786        isSubQueryInStmt = subQueryInStmt;
2787    }
2788
2789    private boolean isSubQueryInStmt = false;   // plsql, subQuery already was set to TSelectSqlStatement, but not parsed
2790
2791    private TFunctionCall functionCall;
2792
2793    public TFunctionCall getFunctionCall() {
2794        return functionCall;
2795    }
2796
2797    public void setFunctionCall(TFunctionCall functionCall) {
2798        this.functionCall = functionCall;
2799    }
2800
2801    private TDatetimeExpression datetimeExpression;
2802
2803    public void setDatetimeExpression(TDatetimeExpression datetimeExpression) {
2804        this.datetimeExpression = datetimeExpression;
2805    }
2806
2807    private TIntervalExpression intervalExpression;
2808
2809    public void setIntervalExpression(TIntervalExpression intervalExpression) {
2810        this.intervalExpression = intervalExpression;
2811    }
2812
2813    private TExpression betweenOperand;
2814
2815    public void setBetweenOperand(TExpression betweenOperand) {
2816        this.betweenOperand = betweenOperand;
2817    }
2818
2819    private TExpression likeEscapeOperand;
2820
2821    public void setLikeEscapeOperand(TExpression likeEscapeOperand) {
2822        this.likeEscapeOperand = likeEscapeOperand;
2823    }
2824
2825
2826    public void doParse(TCustomSqlStatement psql, ESqlClause plocation){
2827
2828        setLocation(plocation);
2829
2830        switch(expressionType){
2831            case simple_constant_t:
2832                if (this.constantOperand.getStartToken() != null){
2833                    this.constantOperand.getStartToken().location = plocation;
2834                }
2835                break;
2836            case simple_object_name_t:
2837                // target_el_expr -> basic3_expr -> simple_expression
2838                psql.linkColumnReferenceToTable(objectOperand,plocation);
2839                psql.linkColumnToTable(objectOperand,plocation);
2840
2841//                if (plocation == ESqlClause.selectInto){
2842//                    if (this.objectOperand.toString().startsWith("#")){
2843//                        TTable table = new TTable();
2844//                        this.objectOperand.setObjectType(TObjectName.ttobjTable);
2845//                        table.setTableName(this.objectOperand);
2846//                        table.setTableType(ETableSource.objectname);
2847//                        table.setEffectType(ETableEffectType.tetSelectInto);
2848//                        psql.addToTables(table);
2849//                    }else{
2850//                        this.objectOperand.setObjectType(TObjectName.ttobjVariable);
2851//                    }
2852//                }else{
2853//                    psql.linkColumnReferenceToTable(objectOperand,plocation);
2854//                    psql.linkColumnToTable(objectOperand,plocation);
2855//                }
2856                break;
2857            case group_t:
2858                inExpr.doParse(psql,plocation);
2859                break;
2860            case list_t:
2861            case collection_constructor_list_t:
2862            case collection_constructor_multiset_t:
2863            case collection_constructor_set_t:
2864            case new_structured_type_t:
2865                if (exprList != null){
2866                    exprList.doParse(psql,plocation);
2867                }
2868                break;
2869            case function_t:
2870                if (functionCall.getArgs() != null){
2871                    for(int i=0;i<functionCall.getArgs().size();i++){
2872                        functionCall.getArgs().getExpression(i).setParentExpr(this);
2873                    }
2874                }
2875                functionCall.doParse(psql,plocation);
2876                break;
2877
2878            case type_constructor_t:
2879                if (getExprList() != null){
2880                    getExprList().doParse(psql,plocation);
2881                }
2882
2883                break;
2884            case cursor_t:
2885            case subquery_t:
2886            case multiset_t:
2887                if (subQuery == null){
2888                    subQuery = new TSelectSqlStatement(psql.dbvendor);
2889                    subQuery.rootNode = subQueryNode;
2890                }
2891                subQuery.setLocation(plocation);
2892
2893                if (!isSubQueryInStmt){
2894                    subQuery.doParseStatement(psql);
2895                }else{
2896                    // subQuery in plsql
2897                 subQuery.parsestatement(psql,false);
2898                }
2899                break;
2900            case case_t:
2901                caseExpression.doParse(psql,plocation);
2902                break;
2903            case pattern_matching_t:
2904                // leftOperand may be null for dangling predicates in CASE expressions
2905                if (leftOperand != null) {
2906                    leftOperand.doParse(psql,plocation);
2907                }
2908                rightOperand.doParse(psql,plocation);
2909                if (likeEscapeOperand != null){
2910                    likeEscapeOperand.doParse(psql,plocation);
2911                }
2912                break;
2913            case exists_t:
2914                if (subQueryNode != null){
2915                    if (subQuery == null){
2916                        subQuery = new TSelectSqlStatement(psql.dbvendor);
2917                        subQuery.rootNode = subQueryNode;
2918                    }
2919                    if (!isSubQueryInStmt){
2920                        subQuery.doParseStatement(psql);
2921                    }else{
2922                        // subQuery in plsql
2923                        subQuery.parsestatement(psql,false);
2924                    }
2925                }else if (this.leftOperand != null){
2926                    // databricks, exists(expr, func)
2927                }
2928                break;
2929            case new_variant_type_t:
2930                this.newVariantTypeArgumentList.doParse(psql,plocation);
2931                break;
2932            case unary_plus_t:
2933            case unary_minus_t:
2934            case unary_prior_t:
2935                rightOperand.doParse(psql,plocation);
2936                break;
2937            case arithmetic_plus_t:
2938            case arithmetic_minus_t:
2939            case arithmetic_times_t:
2940            case arithmetic_divide_t:
2941            case power_t:
2942            case range_t:
2943            case concatenate_t:
2944            case period_ldiff_t:
2945            case period_rdiff_t:
2946            case period_p_intersect_t:
2947            case period_p_normalize_t:
2948            case contains_t:
2949                doParseLeftChainIterative(psql,plocation);
2950                break;
2951            case assignment_t:
2952                doParseLeftChainIterative(psql,plocation);
2953                break;
2954            case sqlserver_proprietary_column_alias_t:
2955                rightOperand.doParse(psql,plocation);
2956                break;
2957            case arithmetic_modulo_t:
2958            case bitwise_exclusive_or_t:
2959            case bitwise_or_t:
2960            case bitwise_and_t:
2961            case bitwise_xor_t:
2962            case exponentiate_t:
2963            case scope_resolution_t:
2964            case at_time_zone_t:
2965            case member_of_t:
2966            case arithmetic_exponentiation_t:
2967                doParseLeftChainIterative(psql,plocation);
2968                break;
2969            case at_local_t:
2970            case day_to_second_t:
2971            case year_to_month_t:
2972                leftOperand.doParse(psql,plocation);
2973                break;
2974            case teradata_at_t:
2975                doParseLeftChainIterative(psql,plocation);
2976                break;
2977            case parenthesis_t:
2978                leftOperand.doParse(psql,plocation);
2979                break;
2980            case simple_comparison_t:
2981                // leftOperand may be null for dangling predicates in CASE expressions
2982                if (leftOperand != null) {
2983                    leftOperand.doParse(psql,plocation);
2984                }
2985                rightOperand.doParse(psql,plocation);
2986                break;
2987            case is_distinct_from_t:
2988                // a IS [NOT] DISTINCT FROM b; leftOperand may be null in the
2989                // predicate-only form (IS DISTINCT FROM b) inside CASE
2990                if (leftOperand != null) {
2991                    leftOperand.doParse(psql,plocation);
2992                }
2993                if (rightOperand != null) {
2994                    rightOperand.doParse(psql,plocation);
2995                }
2996                break;
2997            case group_comparison_t:
2998                doParseLeftChainIterative(psql,plocation);
2999                break;
3000            case in_t:
3001                // leftOperand may be null for dangling predicates in CASE expressions
3002                if (leftOperand != null) {
3003                    leftOperand.doParse(psql,plocation);
3004                }
3005                rightOperand.doParse(psql,plocation);
3006                break;
3007            case floating_point_t:
3008                leftOperand.doParse(psql,plocation);
3009                break;
3010            case logical_xor_t:
3011            case is_t:
3012                doParseLeftChainIterative(psql,plocation);
3013                break;
3014            case logical_not_t:
3015                rightOperand.doParse(psql,plocation);
3016                break;
3017            case null_t:
3018                if (leftOperand != null) {
3019                    leftOperand.doParse(psql,plocation);
3020                }
3021                break;
3022            case is_not_null_t:
3023            case is_true_t:
3024            case is_false_t:
3025            case is_not_true_t:
3026            case is_not_false_t:
3027                leftOperand.doParse(psql,plocation);
3028                break;
3029            case between_t:
3030                // betweenOperand may be null for dangling predicates in CASE expressions
3031                if (betweenOperand != null) {
3032                    betweenOperand.doParse(psql,plocation);
3033                }
3034                leftOperand.doParse(psql,plocation);
3035                rightOperand.doParse(psql,plocation);
3036                break;
3037            case is_of_type_t:
3038                leftOperand.doParse(psql,plocation);
3039                break;
3040            case collate_t: //sql server,postgresql
3041                doParseLeftChainIterative(psql,plocation);
3042                break;
3043            case left_join_t:
3044            case right_join_t:
3045                doParseLeftChainIterative(psql,plocation);
3046                break;
3047            case ref_arrow_t:
3048                if (leftOperand.getExpressionType() == EExpressionType.simple_object_name_t){
3049                    leftOperand.getObjectOperand().setDbObjectType(EDbObjectType.variable);
3050                }
3051                leftOperand.doParse(psql,plocation);
3052                rightOperand.doParse(psql,plocation);
3053                break;
3054            case typecast_t:
3055                leftOperand.doParse(psql,plocation);
3056                break;
3057            case arrayaccess_t:
3058                arrayAccess.doParse(psql,plocation);
3059                break;
3060            case unary_connect_by_root_t:
3061                rightOperand.doParse(psql,plocation);
3062                break;
3063            case interval_t:
3064                intervalExpr.doParse(psql,plocation);
3065                break;
3066            case unary_binary_operator_t:
3067                rightOperand.doParse(psql,plocation);
3068                break;
3069            case left_shift_t:
3070            case right_shift_t:
3071                 doParseLeftChainIterative(psql,plocation);
3072                 break;
3073            case array_constructor_t:
3074                if ((this.subQueryNode != null)&&(subQuery == null)){
3075                    subQuery = new TSelectSqlStatement(psql.dbvendor);
3076                    subQuery.rootNode = subQueryNode;
3077                    subQuery.doParseStatement(psql);
3078                }else if (exprList != null){
3079                    exprList.doParse(psql,plocation);
3080                }else if (arrayConstruct !=null){
3081                    arrayConstruct.doParse(psql,plocation);
3082                }
3083                break;
3084            case objectConstruct_t:
3085                objectConstruct.doParse(psql,plocation);
3086                break;
3087            case row_constructor_t:
3088                if (exprList != null){
3089                    exprList.doParse(psql,plocation);
3090                }
3091                break;
3092            case namedParameter_t:
3093                namedParameter.doParse(psql,plocation);
3094                break;
3095            case positionalParameter_t:
3096                positionalParameter.doParse(psql,plocation);
3097                break;
3098            case collectionArray_t:
3099                collectionArray.doParse(psql,plocation);
3100                break;
3101            case collectionCondition_t:
3102                collectionCondition.doParse(psql,plocation);
3103                break;
3104            case unary_squareroot_t:
3105            case unary_cuberoot_t:
3106            case unary_factorialprefix_t:
3107            case unary_absolutevalue_t:
3108            case unary_bitwise_not_t:
3109                getRightOperand().doParse(psql,plocation);
3110                break;
3111            case unary_factorial_t:
3112                getLeftOperand().doParse(psql,plocation);
3113                break;
3114            case bitwise_shift_left_t:
3115            case bitwise_shift_right_t:
3116                doParseLeftChainIterative(psql,plocation);
3117                break;
3118            case multiset_union_t:
3119            case multiset_union_distinct_t:
3120            case multiset_intersect_t:
3121            case multiset_intersect_distinct_t:
3122            case multiset_except_t:
3123            case multiset_except_distinct_t:
3124                doParseLeftChainIterative(psql,plocation);
3125                break;
3126            case json_get_text:
3127            case json_get_text_at_path:
3128            case json_get_object:
3129            case json_get_object_at_path:
3130            case json_left_contain:
3131            case json_right_contain:
3132            case json_exist:
3133            case json_any_exist:
3134            case json_all_exist:
3135                doParseLeftChainIterative(psql,plocation);
3136                break;
3137            case interpolate_previous_value_t:
3138                doParseLeftChainIterative(psql,plocation);
3139                break;
3140            case text_search_t:
3141            case geo_t:
3142            case network_t:
3143            case json_delete_path:
3144            case json_path_exists:
3145            case json_path_match:
3146                doParseLeftChainIterative(psql,plocation);
3147                break;
3148            case logical_and_t:
3149            case logical_or_t:
3150                doParseLeftChainIterative(psql,plocation);
3151                break;
3152            case submultiset_t:
3153                doParseLeftChainIterative(psql,plocation);
3154                break;
3155            case overlaps_t:
3156                doParseLeftChainIterative(psql,plocation);
3157                break;
3158            case unknown_t:
3159                // Binary expression whose operator has no dedicated type:
3160                // still parse the operands so subqueries and columns inside
3161                // them are analyzed and visible to visitors and the resolver
3162                // (Mantis 4608)
3163                doParseLeftChainIterative(psql,plocation);
3164                break;
3165            case is_a_set_t:
3166                leftOperand.doParse(psql,plocation);
3167                break;
3168            case unnest_t:
3169                leftOperand.doParse(psql,plocation);
3170                break;
3171            case array_t:
3172                if (objectOperand != null){
3173                    psql.linkColumnToTable(objectOperand,plocation);
3174                }
3175
3176                if (getExprList() != null){
3177                    getExprList().doParse(psql,plocation);
3178                }
3179                break;
3180            case fieldselection_t:
3181                if (getLeftOperand() != null){
3182                    getLeftOperand().doParse(psql,plocation);
3183                }else if (getFunctionCall() != null){
3184                    getFunctionCall().doParse(psql,plocation);
3185                }
3186                break;
3187            case lambda_t:
3188                //getLeftOperand().doParse(psql,plocation);
3189                //getRightOperand().doParse(psql,plocation);
3190                break;
3191            case array_access_expr_t:
3192                doParseLeftChainIterative(psql,plocation);
3193                break;
3194            default:;
3195        }
3196    }
3197
3198    /**
3199     * Check if the expression type is a pure binary type where doParse() only
3200     * calls leftOperand.doParse() + rightOperand.doParse() with no additional logic.
3201     */
3202    public static boolean isPureBinaryForDoParse(EExpressionType type) {
3203        switch (type) {
3204            case arithmetic_plus_t:
3205            case arithmetic_minus_t:
3206            case arithmetic_times_t:
3207            case arithmetic_divide_t:
3208            case power_t:
3209            case range_t:
3210            case concatenate_t:
3211            case period_ldiff_t:
3212            case period_rdiff_t:
3213            case period_p_intersect_t:
3214            case period_p_normalize_t:
3215            case contains_t:
3216            case assignment_t:
3217            case arithmetic_modulo_t:
3218            case bitwise_exclusive_or_t:
3219            case bitwise_or_t:
3220            case bitwise_and_t:
3221            case bitwise_xor_t:
3222            case exponentiate_t:
3223            case scope_resolution_t:
3224            case at_time_zone_t:
3225            case member_of_t:
3226            case arithmetic_exponentiation_t:
3227            case teradata_at_t:
3228            case group_comparison_t:
3229            case logical_and_t:
3230            case logical_or_t:
3231            case logical_xor_t:
3232            case is_t:
3233            case collate_t:
3234            case left_join_t:
3235            case right_join_t:
3236            case left_shift_t:
3237            case right_shift_t:
3238            case bitwise_shift_left_t:
3239            case bitwise_shift_right_t:
3240            case multiset_union_t:
3241            case multiset_union_distinct_t:
3242            case multiset_intersect_t:
3243            case multiset_intersect_distinct_t:
3244            case multiset_except_t:
3245            case multiset_except_distinct_t:
3246            case json_get_text:
3247            case json_get_text_at_path:
3248            case json_get_object:
3249            case json_get_object_at_path:
3250            case json_left_contain:
3251            case json_right_contain:
3252            case json_exist:
3253            case json_any_exist:
3254            case json_all_exist:
3255            case interpolate_previous_value_t:
3256            case submultiset_t:
3257            case overlaps_t:
3258            case array_access_expr_t:
3259            case text_search_t:
3260            case geo_t:
3261            case network_t:
3262            case json_delete_path:
3263            case json_path_exists:
3264            case json_path_match:
3265            case unknown_t:
3266                return true;
3267            default:
3268                return false;
3269        }
3270    }
3271
3272    /**
3273     * Iteratively processes a left-recursive chain of pure binary expressions,
3274     * avoiding deep recursion that would cause StackOverflowError for chains
3275     * with 2000+ operators (e.g., WHERE clauses with 2000+ AND conditions).
3276     *
3277     * Walks the left chain collecting right operands, then processes
3278     * the leftmost leaf and all right operands in left-to-right order.
3279     */
3280    private void doParseLeftChainIterative(TCustomSqlStatement psql, ESqlClause plocation) {
3281        Deque<TExpression> rightChildren = new ArrayDeque<>();
3282        TExpression current = this;
3283        // Descend the left chain while the current node is a pure binary expression
3284        while (current != null && isPureBinaryForDoParse(current.expressionType)) {
3285            current.setLocation(plocation);
3286            if (current.rightOperand != null) {
3287                rightChildren.push(current.rightOperand);
3288            }
3289            current = current.leftOperand;
3290        }
3291        // Process the leftmost non-binary leaf
3292        if (current != null) {
3293            current.doParse(psql, plocation);
3294        }
3295        // Process right children bottom-up (preserves left-to-right order)
3296        while (!rightChildren.isEmpty()) {
3297            rightChildren.pop().doParse(psql, plocation);
3298        }
3299    }
3300
3301    /**
3302     * Iteratively processes a left-recursive chain of pure binary expressions
3303     * for the visitor pattern (acceptChildren), avoiding StackOverflowError.
3304     *
3305     * Preserves the exact preVisit/postVisit ordering of the recursive version:
3306     * preVisit all chain nodes top-down, process leftmost leaf, then bottom-up
3307     * process each right child and call postVisit on the chain node.
3308     *
3309     * Note: preVisit(this) is called by the caller before the switch statement,
3310     * and postVisit(this) is called by the caller after the switch statement.
3311     */
3312    private void acceptChildrenIterativeBinaryChain(TParseTreeVisitor v) {
3313        // Collect the left-recursive chain of pure binary expression nodes
3314        ArrayList<TExpression> chain = new ArrayList<>();
3315        chain.add(this);
3316
3317        TExpression current = this.leftOperand;
3318        while (current != null && isPureBinaryForDoParse(current.expressionType)) {
3319            chain.add(current);
3320            current = current.leftOperand;
3321        }
3322        // `current` is the leftmost non-binary leaf (or null)
3323
3324        // Call preVisit on inner chain nodes top-down (index 0 = this, already preVisited)
3325        for (int i = 1; i < chain.size(); i++) {
3326            v.preVisit(chain.get(i));
3327        }
3328
3329        // Process the leftmost leaf
3330        if (current != null) {
3331            current.acceptChildren(v);
3332        }
3333
3334        // Bottom-up: for each chain node from deepest to shallowest,
3335        // process its right child and call postVisit
3336        for (int i = chain.size() - 1; i >= 1; i--) {
3337            TExpression node = chain.get(i);
3338            if (node.rightOperand != null) {
3339                node.rightOperand.acceptChildren(v);
3340            }
3341            v.postVisit(node);
3342        }
3343
3344        // Process this node's right child
3345        // (postVisit(this) is handled by the caller after the switch)
3346        if (this.rightOperand != null) {
3347            this.rightOperand.acceptChildren(v);
3348        }
3349    }
3350
3351    private EComparisonType comparisonType = EComparisonType.unknown;
3352    private TSourceToken comparisonOperator = null;
3353    private TSourceToken quantifier = null;
3354
3355    public void setQuantifierType(EQuantifierType quantifierType) {
3356        this.quantifierType = quantifierType;
3357    }
3358
3359    public EQuantifierType getQuantifierType() {
3360
3361        return quantifierType;
3362    }
3363
3364    private EQuantifierType quantifierType = EQuantifierType.none;
3365
3366    public EComparisonType getComparisonType() {
3367        return comparisonType;
3368    }
3369
3370    /**
3371     *  one of the following quantifier keywords: SOME, ANY, ALL
3372     * @return SOME, ANY, ALL in group comparison condition.
3373     */
3374    public TSourceToken getQuantifier() {
3375        return quantifier;
3376    }
3377
3378    /**
3379     *
3380     * @return operator used in comparison condition.
3381     */
3382    public TSourceToken getComparisonOperator() {
3383
3384        return comparisonOperator;
3385    }
3386
3387    public void setComparisonOperator(TDummy comparisonOperator) {
3388        if (comparisonOperator == null) return;
3389        for(TSourceToken st : comparisonOperator.tokens){
3390            this.getOperatorTokens().add(st);
3391        }
3392    }
3393
3394    public void setComparisonOperator(TSourceToken comparisonOperator) {
3395        if (comparisonOperator == null) return;
3396        this.comparisonOperator = comparisonOperator;
3397        this.operatorToken = comparisonOperator;
3398        comparisonType = getComparisonType(comparisonOperator);
3399        if ((comparisonOperator.toString().equalsIgnoreCase("="))
3400                && (expressionType == EExpressionType.simple_comparison_t)){
3401            // leftOperand may be null for dangling predicates in CASE expressions
3402            if (leftOperand != null && leftOperand.toString().startsWith("@")){
3403                expressionType = EExpressionType.assignment_t;
3404            }
3405        }
3406    }
3407
3408    public void setQuantifier(TSourceToken quantifier) {
3409        if (quantifier == null) return;
3410        this.quantifier = quantifier;
3411        switch (this.quantifier.tokencode){
3412            case TBaseType.rrw_all:
3413                quantifierType = EQuantifierType.all;
3414                break;
3415            default:
3416                if (this.quantifier.toString().equalsIgnoreCase("any")){
3417                    quantifierType = EQuantifierType.any;
3418                }else if (this.quantifier.toString().equalsIgnoreCase("some")){
3419                    quantifierType = EQuantifierType.some;
3420                }
3421                break;
3422        }
3423    }
3424
3425    public void accept(TParseTreeVisitor v){
3426        v.preVisit(this);
3427        v.postVisit(this);
3428    }
3429
3430    public void acceptChildren(TParseTreeVisitor v){
3431        v.preVisit(this);
3432        switch(expressionType){
3433            case simple_object_name_t:
3434                objectOperand.acceptChildren(v);
3435                break;
3436            case simple_constant_t:
3437                constantOperand.acceptChildren(v);
3438                break;
3439            case list_t:
3440            case collection_constructor_list_t:
3441            case collection_constructor_multiset_t:
3442            case collection_constructor_set_t:
3443            case new_structured_type_t:
3444                if (exprList != null){
3445                    for(int i=0;i<exprList.size();i++){
3446                        exprList.getExpression(i).acceptChildren(v);
3447                    }
3448                }
3449                break;
3450            case function_t:
3451                functionCall.acceptChildren(v);
3452                break;
3453            case type_constructor_t:
3454                if (getExprList() != null){
3455                    getExprList().acceptChildren(v);
3456                }
3457                break;
3458            case cursor_t:
3459            case subquery_t:
3460            case multiset_t:
3461                subQuery.acceptChildren(v);
3462                break;
3463            case case_t:
3464                caseExpression.acceptChildren(v);
3465                break;
3466            case pattern_matching_t:
3467                // leftOperand may be null for dangling predicates in CASE expressions
3468                if (leftOperand != null) {
3469                    leftOperand.acceptChildren(v);
3470                }
3471                rightOperand.acceptChildren(v);
3472                if (likeEscapeOperand != null){
3473                    likeEscapeOperand.acceptChildren(v);
3474                }
3475                break;
3476            case exists_t:
3477                if (subQuery!=null){
3478                    subQuery.acceptChildren(v);
3479                }else{
3480                    // databricks, exists(expr, func)
3481                }
3482
3483                break;
3484            case new_variant_type_t:
3485                newVariantTypeArgumentList.acceptChildren(v);
3486                break;
3487            case unary_plus_t:
3488            case unary_minus_t:
3489            case unary_prior_t:
3490                rightOperand.acceptChildren(v);
3491                break;
3492            case arithmetic_plus_t:
3493            case arithmetic_minus_t:
3494            case arithmetic_times_t:
3495            case arithmetic_divide_t:
3496            case power_t:
3497            case range_t:
3498            case concatenate_t:
3499            case period_ldiff_t:
3500            case period_rdiff_t:
3501            case period_p_intersect_t:
3502            case period_p_normalize_t:
3503            case contains_t:
3504                acceptChildrenIterativeBinaryChain(v);
3505                break;
3506            case assignment_t:
3507                acceptChildrenIterativeBinaryChain(v);
3508                break;
3509            case sqlserver_proprietary_column_alias_t:
3510                rightOperand.acceptChildren(v);
3511                break;
3512            case arithmetic_modulo_t:
3513            case bitwise_exclusive_or_t:
3514            case bitwise_or_t:
3515            case bitwise_and_t:
3516            case bitwise_xor_t:
3517            case exponentiate_t:
3518            case scope_resolution_t:
3519            case at_time_zone_t:
3520            case member_of_t:
3521            case arithmetic_exponentiation_t:
3522                acceptChildrenIterativeBinaryChain(v);
3523                break;
3524            case at_local_t:
3525            case day_to_second_t:
3526            case year_to_month_t:
3527                leftOperand.acceptChildren(v);
3528                break;
3529            case teradata_at_t:
3530                acceptChildrenIterativeBinaryChain(v);
3531                break;
3532            case parenthesis_t:
3533                leftOperand.acceptChildren(v);
3534                break;
3535            case simple_comparison_t:
3536                // leftOperand may be null for dangling predicates in CASE expressions
3537                if (leftOperand != null) {
3538                    leftOperand.acceptChildren(v);
3539                }
3540                rightOperand.acceptChildren(v);
3541                break;
3542            case is_distinct_from_t:
3543                // a IS [NOT] DISTINCT FROM b; leftOperand may be null in the
3544                // predicate-only form (IS DISTINCT FROM b) inside CASE
3545                if (leftOperand != null) {
3546                    leftOperand.acceptChildren(v);
3547                }
3548                if (rightOperand != null) {
3549                    rightOperand.acceptChildren(v);
3550                }
3551                break;
3552            case group_comparison_t:
3553                acceptChildrenIterativeBinaryChain(v);
3554                break;
3555            case in_t:
3556                // leftOperand may be null for dangling predicates in CASE expressions
3557                if (leftOperand != null) {
3558                    leftOperand.acceptChildren(v);
3559                }
3560                rightOperand.acceptChildren(v);
3561                break;
3562            case floating_point_t:
3563                leftOperand.acceptChildren(v);
3564                break;
3565            case logical_and_t:
3566            case logical_or_t:
3567            case logical_xor_t:
3568            case is_t:
3569                acceptChildrenIterativeBinaryChain(v);
3570                break;
3571            case logical_not_t:
3572                rightOperand.acceptChildren(v);
3573                break;
3574            case null_t:
3575            case is_not_null_t:
3576            case is_true_t:
3577            case is_false_t:
3578            case is_not_true_t:
3579            case is_not_false_t:
3580                leftOperand.acceptChildren(v);
3581                break;
3582            case between_t:
3583                if (betweenOperand != null){
3584                    betweenOperand.acceptChildren(v);
3585                }
3586                leftOperand.acceptChildren(v);
3587                rightOperand.acceptChildren(v);
3588                break;
3589            case is_of_type_t:
3590                leftOperand.acceptChildren(v);
3591                break;
3592            case collate_t: //sql server,postgresql
3593                acceptChildrenIterativeBinaryChain(v);
3594                break;
3595            case left_join_t:
3596            case right_join_t:
3597                acceptChildrenIterativeBinaryChain(v);
3598                break;
3599            case ref_arrow_t:
3600                leftOperand.acceptChildren(v);
3601                rightOperand.acceptChildren(v);
3602                break;
3603            case typecast_t:
3604                leftOperand.acceptChildren(v);
3605                break;
3606            case arrayaccess_t:
3607                arrayAccess.acceptChildren(v);
3608                break;
3609            case unary_connect_by_root_t:
3610                rightOperand.acceptChildren(v);
3611                break;
3612            case interval_t:
3613                intervalExpr.acceptChildren(v);
3614                break;
3615            case unary_binary_operator_t:
3616                rightOperand.acceptChildren(v);
3617                break;
3618            case left_shift_t:
3619            case right_shift_t:
3620                acceptChildrenIterativeBinaryChain(v);
3621                break;
3622            case array_constructor_t:
3623                if (subQuery != null){
3624                    subQuery.acceptChildren(v);
3625                }else if (exprList != null){
3626                    exprList.acceptChildren(v);
3627                }else if (arrayConstruct != null){
3628                    arrayConstruct.acceptChildren(v);
3629                }
3630                break;
3631            case row_constructor_t:
3632                if (exprList != null){
3633                    exprList.acceptChildren(v);
3634                }
3635                break;
3636            case unary_squareroot_t:
3637            case unary_cuberoot_t:
3638            case unary_factorialprefix_t:
3639            case unary_absolutevalue_t:
3640            case unary_bitwise_not_t:
3641                getRightOperand().acceptChildren(v);
3642                break;
3643            case unary_factorial_t:
3644                getLeftOperand().acceptChildren(v);
3645                break;
3646            case bitwise_shift_left_t:
3647            case bitwise_shift_right_t:
3648                acceptChildrenIterativeBinaryChain(v);
3649                break;
3650            case multiset_union_t:
3651            case multiset_union_distinct_t:
3652            case multiset_intersect_t:
3653            case multiset_intersect_distinct_t:
3654            case multiset_except_t:
3655            case multiset_except_distinct_t:
3656                acceptChildrenIterativeBinaryChain(v);
3657                break;
3658            case json_get_text:
3659            case json_get_text_at_path:
3660            case json_get_object:
3661            case json_get_object_at_path:
3662            case json_left_contain:
3663            case json_right_contain:
3664            case json_exist:
3665            case json_any_exist:
3666            case json_all_exist:
3667                acceptChildrenIterativeBinaryChain(v);
3668                break;
3669            case interpolate_previous_value_t:
3670                acceptChildrenIterativeBinaryChain(v);
3671                break;
3672            case text_search_t:
3673            case geo_t:
3674            case network_t:
3675            case json_delete_path:
3676            case json_path_exists:
3677            case json_path_match:
3678                acceptChildrenIterativeBinaryChain(v);
3679                break;
3680            case submultiset_t:
3681                acceptChildrenIterativeBinaryChain(v);
3682                break;
3683            case overlaps_t:
3684                acceptChildrenIterativeBinaryChain(v);
3685                break;
3686            case unknown_t:
3687                // keep unmapped binary operators traversable (Mantis 4608)
3688                acceptChildrenIterativeBinaryChain(v);
3689                break;
3690            case is_a_set_t:
3691                leftOperand.acceptChildren(v);
3692                break;
3693            case array_t:
3694                if (getExprList() != null){
3695                    getExprList().acceptChildren(v);
3696                }
3697                break;
3698            case lambda_t:
3699                getLeftOperand().acceptChildren(v);
3700                getRightOperand().acceptChildren(v);
3701                break;
3702            default:;
3703        }
3704
3705        v.postVisit(this);
3706    }
3707
3708    /**
3709     * expression type such as column reference is a leaf expression while subtract expression
3710     * is not a leaf expression. Usually, non-leaf expression should including both {@link #getLeftOperand()}
3711     * and {@link #getRightOperand()}.
3712     * @return leaf expression or not.
3713     */
3714    public boolean isLeaf(){
3715        return isLeafExpr(this);
3716    }
3717
3718
3719    public boolean isLeafExpr(TParseTreeNode pnode){
3720        boolean ret = true;
3721        if (pnode == null) return ret;
3722        if (!(pnode instanceof TExpression)) return ret;
3723        TExpression e = (TExpression)pnode;
3724
3725        if ((onlyAndOrIsNonLeaf) &&(!((e.getExpressionType()==EExpressionType.logical_and_t)||(e.getExpressionType()==EExpressionType.logical_or_t)))) return ret;
3726
3727        switch (e.getExpressionType()){
3728            case case_t:
3729            case simple_object_name_t:
3730            case simple_constant_t:
3731            case simple_source_token_t:
3732            case group_t:
3733            case list_t:
3734            case collection_constructor_list_t:
3735            case collection_constructor_multiset_t:
3736            case collection_constructor_set_t:
3737            case cursor_t:
3738            case function_t:
3739            case type_constructor_t:
3740            case subquery_t:
3741            case multiset_t:
3742            case object_access_t:
3743            case place_holder_t:
3744            case is_of_type_t:
3745            case exists_t:
3746            case arrayaccess_t:
3747            case interval_t:
3748            case new_structured_type_t:
3749            case new_variant_type_t:
3750            case member_of_t:
3751            case submultiset_t:
3752            case execute_stmt_t:
3753            case cursor_attribute_t:
3754                return ret;
3755            default:
3756        }
3757        //if(e.getExpressionType() == TExpression.datetimeExprOperator) return ret;
3758        //if(e.getExpressionType() == TExpression.intervalExprOperator) return ret;
3759        //if(e.getExpressionType() == TExpression.modelExprOperator) return ret;
3760        //if(e.getExpressionType() == TExpression.typeconstructorExprOperator) return ret;
3761        //if(e.getExpressionType() == TExpression.patternMatchingExprOperator) return ret;
3762
3763        if (e.getLeftOperand() != null){
3764            ret = !(e.getLeftOperand() instanceof TExpression);
3765        }
3766        if (e.getRightOperand() != null){
3767            ret = !(e.getRightOperand() instanceof TExpression);
3768        }
3769
3770        return ret;
3771    }
3772
3773    private Stack exprStack = null;
3774
3775    private Stack getExprStack() {
3776        if (exprStack == null){
3777            exprStack = new Stack();
3778        }
3779        return exprStack;
3780    }
3781
3782    // used in  PreOrderTraverse only,  InOrderTraverse  and PostOrderTraverse has already visit subtree.
3783    private boolean visitSubTree = true;
3784
3785
3786    public void setVisitSubTree(boolean visitSubTree) {
3787        this.visitSubTree = visitSubTree;
3788    }
3789
3790    public boolean isVisitSubTree() {
3791
3792        return visitSubTree;
3793    }
3794
3795    private boolean checkIsVisitSubTree(TParseTreeNode node){
3796        boolean ret = !this.isLeafExpr(node);
3797        if (ret){
3798            ret = ((TExpression)node).isVisitSubTree();
3799        }
3800        return ret;
3801    }
3802
3803
3804    public void setWindowSpecification(TWindowDef windowSpecification){
3805        if (this.getExpressionType() != EExpressionType.function_t) return;
3806        this.getFunctionCall().setWindowDef(windowSpecification);
3807
3808    }
3809
3810    /**
3811     * Traverse expression in pre Order.
3812     * @param ev user defined visitor
3813     */
3814    public void preOrderTraverse(IExpressionVisitor ev){
3815
3816
3817        if (this.isLeaf()){
3818            ev.exprVisit(this,true);
3819        }else{
3820            getExprStack().push(this);
3821        }
3822
3823        TParseTreeNode node = null;
3824        while(getExprStack().size() > 0){
3825            node = (TParseTreeNode)getExprStack().peek();
3826
3827            while(node != null){
3828                if (!ev.exprVisit(node,this.isLeafExpr(node))) {
3829                    return;
3830                }
3831
3832                if (this.isLeafExpr(node)) {
3833                    this.getExprStack().push(null);
3834                }else if (!this.checkIsVisitSubTree(node)){
3835                    this.getExprStack().push(null);
3836                }else{
3837                    this.getExprStack().push(((TExpression)node).getLeftOperand());
3838                }
3839                node = (TParseTreeNode)this.getExprStack().peek();
3840            }
3841
3842            // pop up the dummyOperator expression node
3843            this.getExprStack().pop();
3844
3845            if (this.getExprStack().size() > 0){
3846                node = (TParseTreeNode)this.getExprStack().pop();
3847                
3848                if (this.isLeafExpr(node)) {
3849                    this.getExprStack().push(null);
3850                }else if (!this.checkIsVisitSubTree(node)){
3851                    this.getExprStack().push(null);
3852                }else{
3853                    this.getExprStack().push(((TExpression)node).getRightOperand());
3854                }
3855
3856            }
3857
3858        } //while
3859
3860
3861    }
3862
3863    /**
3864     * Traverse expression in In Order.
3865     * @param ev user defined visitor
3866     */
3867    public void inOrderTraverse(IExpressionVisitor ev){
3868
3869        if (this.isLeaf()){
3870            ev.exprVisit(this,true);
3871        }else{
3872            getExprStack().push(this);
3873        }
3874
3875        TParseTreeNode node = null;
3876        while(getExprStack().size() > 0){
3877            node = (TParseTreeNode)getExprStack().peek();
3878
3879            while(node != null){
3880
3881                if (this.isLeafExpr(node)) {
3882                    this.getExprStack().push(null);
3883                }else{
3884                    this.getExprStack().push(((TExpression)node).getLeftOperand());
3885                }
3886                node = (TParseTreeNode)this.getExprStack().peek();
3887            }
3888
3889            // pop up the dummyOperator expression node
3890            this.getExprStack().pop();
3891
3892            if (this.getExprStack().size() > 0){
3893                node = (TParseTreeNode)this.getExprStack().pop();
3894
3895                if (!ev.exprVisit(node,this.isLeafExpr(node))) {
3896                    return;
3897                }
3898
3899                if (this.isLeafExpr(node)) {
3900                    this.getExprStack().push(null);
3901                }else{
3902                    this.getExprStack().push(((TExpression)node).getRightOperand());
3903                }
3904
3905            }
3906
3907        } //while
3908
3909    }
3910
3911    /**
3912     * Traverse expression in post order.
3913     * @param ev user defined visitor
3914     */
3915    public void postOrderTraverse(IExpressionVisitor ev){
3916
3917        final int ctNone = 0;
3918        final int ctL = 1;
3919        final int ctR = 2;
3920
3921        if (this.isLeaf()){
3922            ev.exprVisit(this,true);
3923        }else{
3924            getExprStack().push(this);
3925        }
3926
3927        TParseTreeNode node = null;
3928
3929        while(getExprStack().size() > 0){
3930            node = (TParseTreeNode)getExprStack().peek();
3931
3932            while(node != null){
3933
3934                if (this.isLeafExpr(node)) {
3935                    this.getExprStack().push(null);
3936                }else{
3937                    this.getExprStack().push(((TExpression)node).getLeftOperand());
3938                }
3939                node = (TParseTreeNode)this.getExprStack().peek();
3940                if (node != null){
3941                    node.setDummyTag(ctL);
3942                }
3943            }
3944
3945            // pop up the dummyOperator expression node
3946            this.getExprStack().pop();
3947            node = (TParseTreeNode)this.getExprStack().peek();
3948
3949            while((this.getExprStack().size() > 0) &&(node.getDummyTag() == ctR)){
3950                node = (TParseTreeNode)this.getExprStack().pop();
3951                node.setDummyTag(ctNone); //restore tag so next this expression will be traversed correctly
3952                if (!ev.exprVisit(node,this.isLeafExpr(node))) {
3953                    return;
3954                }
3955
3956                if (this.getExprStack().size() > 0){
3957                    node = (TParseTreeNode)this.getExprStack().peek();
3958                }else{
3959                    break;
3960                }
3961            }
3962
3963            if (this.getExprStack().size() > 0){
3964                node = (TParseTreeNode)this.getExprStack().peek();
3965                node.setDummyTag(ctR);
3966                if (this.isLeafExpr(node)){
3967                    this.getExprStack().push(null);
3968                }else{
3969                 this.getExprStack().push(((TExpression)node).getRightOperand());
3970                }
3971            }
3972
3973        }//while
3974
3975    }
3976
3977    /**
3978     * if original expr is f &gt; 1, and call addANDCondition("f2 &gt; 2")
3979     * expression will be: f &gt; 1 and f2&gt; 2
3980     * @param condition
3981     */
3982    public void addANDCondition(String condition){
3983        //appendString(" and "+condition);
3984        setString("("+this.toString()+") and "+condition);
3985    }
3986
3987    /**
3988     * if original expr is f &gt; 1, and call addORCondition("f2 &gt; 2")
3989     * expression will be: f &gt; 1 or f2 &gt;2
3990     *
3991     * @param condition
3992     */
3993    public void addORCondition(String condition){
3994        //appendString(" or "+condition);
3995        setString("("+this.toString()+") or "+condition);
3996    }
3997
3998
3999    /**
4000     * remove this expression from it's parent expr.
4001     * if itself is the top level expression, then remove it from parse tree
4002     * <p>f1 &gt; 1 and f2 &gt; 2, after remove f2 &gt; 2, parent expression will be changed to: f1 &gt; 1
4003     * <p> If we need to remove condition f &gt; 1 from where clause: where f &gt; 1,
4004     * Here f &gt; 1 is the top level expression, after remove it from where clause, only  WHERE keyword left in where clause.
4005     */
4006
4007    public void removeMe(){
4008        if (this.getExpressionType() == EExpressionType.removed_t) return;
4009        this.setExpressionType(EExpressionType.removed_t);
4010
4011        TExpression parentExpr = this.getParentExpr();
4012        if (parentExpr == null){
4013            this.removeTokens();
4014            return;
4015        }
4016
4017        switch (parentExpr.getExpressionType()){
4018            case list_t: // (1,2,3) in (column1,column2,column3)
4019                // remove column1 will break this expr, so need to remove parent expr of list_t as well.
4020                //if (parentExpr.getParentExpr() != null) removeExpr(parentExpr.getParentExpr());
4021                parentExpr.removeMe();
4022                break;
4023            case parenthesis_t:
4024                parentExpr.removeMe();
4025                break;
4026            case arithmetic_plus_t:
4027            case arithmetic_minus_t:
4028            case arithmetic_times_t:
4029            case arithmetic_divide_t:
4030            case arithmetic_modulo_t:
4031            case bitwise_exclusive_or_t:
4032            case bitwise_or_t:
4033            case bitwise_and_t:
4034            case bitwise_xor_t:
4035            case logical_xor_t:
4036            case concatenate_t:
4037            case logical_and_t:
4038            case logical_or_t:
4039                if (this.getNodeStatus() == ENodeStatus.nsRemoved){
4040                    // this node is removed cascade
4041                    if (this.isLeftOperandOfParent()){
4042                        if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
4043                            this.getParentExpr().refreshAllNodesTokenCount();
4044                            this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain());
4045                            this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken());
4046                        }
4047                    }else if (this.isRightOperandOfParent()){
4048                        if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){
4049                            this.getParentExpr().refreshAllNodesTokenCount();
4050                            this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken());
4051                            this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken());
4052                        }
4053                    }
4054                }else{
4055                    TParseTreeNode.removeTokensBetweenNodes(parentExpr.leftOperand,parentExpr.rightOperand);
4056                }
4057
4058                this.removeTokens();
4059                if (parentExpr.getNodeStatus() == ENodeStatus.nsRemoved){
4060                    parentExpr.removeMe();
4061                }
4062                break;
4063            case simple_comparison_t:
4064            case is_distinct_from_t:
4065            case group_comparison_t:
4066            case in_t:
4067                parentExpr.removeMe();
4068                break;
4069            case between_t:
4070                parentExpr.removeMe();
4071                break;
4072            case unary_plus_t:
4073            case unary_minus_t:
4074            case unary_prior_t:
4075            case pattern_matching_t:
4076            case power_t:
4077            case range_t:
4078            case period_ldiff_t:
4079            case period_rdiff_t:
4080            case period_p_intersect_t:
4081            case period_p_normalize_t:
4082            case contains_t:
4083            case assignment_t:
4084            case sqlserver_proprietary_column_alias_t:
4085            case scope_resolution_t:
4086            case at_time_zone_t:
4087            case member_of_t:
4088            case arithmetic_exponentiation_t:
4089            case submultiset_t:
4090            case overlaps_t:
4091            case at_local_t:
4092            case day_to_second_t:
4093            case year_to_month_t:
4094            case exponentiate_t:
4095            case floating_point_t:
4096            case is_t:
4097            case logical_not_t:
4098            case null_t:
4099            case is_not_null_t:
4100            case is_true_t:
4101            case is_false_t:
4102            case is_not_true_t:
4103            case is_not_false_t:
4104            case is_of_type_t:
4105            case collate_t: //sql server,postgresql
4106            case left_join_t:
4107            case right_join_t:
4108            case ref_arrow_t:
4109            case typecast_t:
4110            case arrayaccess_t:
4111            case unary_connect_by_root_t:
4112            case interval_t:
4113            case unary_binary_operator_t:
4114            case left_shift_t:
4115            case right_shift_t:
4116            case array_constructor_t:
4117            case objectConstruct_t:
4118            case row_constructor_t:
4119            case namedParameter_t:
4120            case positionalParameter_t:
4121            case collectionArray_t:
4122            case collectionCondition_t:
4123            case unary_squareroot_t:
4124            case unary_cuberoot_t:
4125            case unary_factorialprefix_t:
4126            case unary_absolutevalue_t:
4127            case unary_bitwise_not_t:
4128            case unary_factorial_t:
4129            case bitwise_shift_left_t:
4130            case bitwise_shift_right_t:
4131            case multiset_union_t:
4132            case multiset_union_distinct_t:
4133            case multiset_intersect_t:
4134            case multiset_intersect_distinct_t:
4135            case multiset_except_t:
4136            case multiset_except_distinct_t:
4137            case json_get_text:
4138            case json_get_text_at_path:
4139            case json_get_object:
4140            case json_get_object_at_path:
4141            case json_left_contain:
4142            case json_right_contain:
4143            case json_exist:
4144            case json_any_exist:
4145            case json_all_exist:
4146            case interpolate_previous_value_t:
4147            case unnest_t:
4148                if (leftOperand != null){
4149                    leftOperand.removeMe();
4150                }else if (rightOperand != null){
4151                    rightOperand.removeMe();
4152                }
4153
4154                break;
4155            case lambda_t:
4156                leftOperand.removeMe();
4157                rightOperand.removeMe();
4158                break;
4159            case teradata_at_t:
4160                leftOperand.removeMe();
4161                rightOperand.removeMe();
4162                break;
4163            default:
4164                parentExpr.removeMe();
4165                break;
4166        }
4167    }
4168
4169public void remove2(){
4170    if (TParseTreeNode.doubleLinkedTokenListToString){
4171        removeMe();
4172    }else{
4173        if (parentExpr == null){
4174            removeAllMyTokensFromTokenList(null);
4175        }else if ((parentExpr.getExpressionType() == EExpressionType.logical_and_t)
4176                ||(parentExpr.getExpressionType() == EExpressionType.logical_or_t))
4177        {
4178            removeAllMyTokensFromTokenList(parentExpr.getOperatorToken());
4179            if ((parentExpr.getLeftOperand().getStartToken() == null)&&(parentExpr.getRightOperand().getStartToken() == null)){
4180                parentExpr.remove2();
4181            }
4182        }else if (parentExpr.getExpressionType() == EExpressionType.parenthesis_t){
4183            removeAllMyTokensFromTokenList(null);
4184            parentExpr.remove2();
4185        }else{
4186            removeAllMyTokensFromTokenList(null);
4187        }
4188    }
4189}
4190
4191    public void remove(){
4192
4193        if (this.getExpressionType() == EExpressionType.removed_t) return;
4194
4195        this.setExpressionType(EExpressionType.removed_t);
4196        TExpression parentExpr = this.getParentExpr();
4197
4198        if (parentExpr == null) return;
4199
4200        switch (parentExpr.getExpressionType()){
4201            case list_t: // (1,2,3) in (column1,column2,column3)
4202                // remove column1 will break this expr, so need to remove parent expr of list_t as well.
4203                //if (parentExpr.getParentExpr() != null) removeExpr(parentExpr.getParentExpr());
4204                parentExpr.remove();
4205                break;
4206            case pattern_matching_t:
4207                parentExpr.remove();
4208                break;
4209            case unary_plus_t:
4210            case unary_minus_t:
4211            case unary_prior_t:
4212                parentExpr.remove();
4213                break;
4214            case arithmetic_plus_t:
4215            case arithmetic_minus_t:
4216            case arithmetic_times_t:
4217            case arithmetic_divide_t:
4218            case power_t:
4219            case range_t:
4220            case period_ldiff_t:
4221            case period_rdiff_t:
4222            case period_p_intersect_t:
4223            case period_p_normalize_t:
4224            case contains_t:
4225                parentExpr.remove();
4226                break;
4227            case assignment_t:
4228                parentExpr.remove();
4229                break;
4230            case sqlserver_proprietary_column_alias_t:
4231                parentExpr.remove();
4232                break;
4233            case arithmetic_modulo_t:
4234            case bitwise_exclusive_or_t:
4235            case bitwise_or_t:
4236            case bitwise_and_t:
4237            case bitwise_xor_t:
4238            case exponentiate_t:
4239            case scope_resolution_t:
4240            case at_time_zone_t:
4241            case member_of_t:
4242            case arithmetic_exponentiation_t:
4243            case submultiset_t:
4244            case overlaps_t:
4245                parentExpr.remove();
4246                break;
4247            case at_local_t:
4248            case day_to_second_t:
4249            case year_to_month_t:
4250                parentExpr.remove();
4251                break;
4252            case parenthesis_t:
4253                parentExpr.remove();
4254                break;
4255            case simple_comparison_t:
4256            case is_distinct_from_t:
4257                parentExpr.remove();
4258                break;
4259            case group_comparison_t:
4260                parentExpr.remove();
4261                break;
4262            case in_t:
4263                parentExpr.remove();
4264                break;
4265            case floating_point_t:
4266                parentExpr.remove();
4267                break;
4268            case logical_xor_t:
4269            case is_t:
4270                parentExpr.remove();
4271                break;
4272            case logical_not_t:
4273                parentExpr.remove();
4274                break;
4275            case null_t:
4276            case is_not_null_t:
4277            case is_true_t:
4278            case is_false_t:
4279            case is_not_true_t:
4280            case is_not_false_t:
4281                parentExpr.remove();
4282                break;
4283            case between_t:
4284                parentExpr.remove();
4285                break;
4286            case is_of_type_t:
4287                parentExpr.remove();
4288                break;
4289            case collate_t: //sql server,postgresql
4290                parentExpr.remove();
4291                break;
4292            case left_join_t:
4293            case right_join_t:
4294                parentExpr.remove();
4295                break;
4296            case ref_arrow_t:
4297                parentExpr.remove();
4298                break;
4299            case typecast_t:
4300                parentExpr.remove();
4301                break;
4302            case arrayaccess_t:
4303                parentExpr.remove();
4304                break;
4305            case unary_connect_by_root_t:
4306                parentExpr.remove();
4307                break;
4308            case interval_t:
4309                parentExpr.remove();
4310                break;
4311            case unary_binary_operator_t:
4312                parentExpr.remove();
4313                break;
4314            case left_shift_t:
4315            case right_shift_t:
4316                parentExpr.remove();
4317                break;
4318            case array_constructor_t:
4319                parentExpr.remove();
4320                break;
4321            case objectConstruct_t:
4322                parentExpr.remove();
4323                break;
4324            case row_constructor_t:
4325                parentExpr.remove();
4326                break;
4327            case namedParameter_t:
4328                parentExpr.remove();
4329                break;
4330            case positionalParameter_t:
4331                parentExpr.remove();
4332                break;
4333            case collectionArray_t:
4334                parentExpr.remove();
4335                break;
4336            case collectionCondition_t:
4337                parentExpr.remove();
4338                break;
4339            case unary_squareroot_t:
4340            case unary_cuberoot_t:
4341            case unary_factorialprefix_t:
4342            case unary_absolutevalue_t:
4343            case unary_bitwise_not_t:
4344                parentExpr.remove();
4345                break;
4346            case unary_factorial_t:
4347                parentExpr.remove();
4348                break;
4349            case bitwise_shift_left_t:
4350            case bitwise_shift_right_t:
4351                parentExpr.remove();
4352                break;
4353            case multiset_union_t:
4354            case multiset_union_distinct_t:
4355            case multiset_intersect_t:
4356            case multiset_intersect_distinct_t:
4357            case multiset_except_t:
4358            case multiset_except_distinct_t:
4359                parentExpr.remove();
4360                break;
4361            case json_get_text:
4362            case json_get_text_at_path:
4363            case json_get_object:
4364            case json_get_object_at_path:
4365            case json_left_contain:
4366            case json_right_contain:
4367            case json_exist:
4368            case json_any_exist:
4369            case json_all_exist:
4370            case lambda_t:
4371                parentExpr.remove();
4372                break;
4373            case interpolate_previous_value_t:
4374                parentExpr.remove();
4375                break;
4376            case concatenate_t:
4377            case logical_and_t:
4378            case logical_or_t:
4379                if (this == parentExpr.getLeftOperand()){
4380                    parentExpr.getRightOperand().copyTo(parentExpr);
4381                }else if (this == parentExpr.getRightOperand()){
4382                    parentExpr.getLeftOperand().copyTo(parentExpr);
4383                }
4384
4385                break;
4386            case unnest_t:
4387                leftOperand.remove();
4388                break;
4389            default:
4390                parentExpr.remove();
4391                break;
4392        }
4393
4394    }
4395
4396    public void copyTo(TExpression target){
4397        target.setExpressionType(this.getExpressionType());
4398        target.setLeftOperand(this.getLeftOperand());
4399        target.setRightOperand(this.getRightOperand());
4400        target.setObjectOperand(this.getObjectOperand());
4401        target.setFunctionCall(this.getFunctionCall());
4402        target.setSubQuery(this.getSubQuery());
4403        target.setConstantOperand(this.getConstantOperand());
4404        target.setExprList(this.getExprList());
4405        target.setOperatorToken(this.getOperatorToken());
4406        target.setComparisonOperator(this.getComparisonOperator());
4407        target.setBetweenOperand(this.getBetweenOperand());
4408        target.setCaseExpression(this.getCaseExpression());
4409
4410        target.setLikeEscapeOperand(this.getLikeEscapeOperand());
4411        target.setNotToken(this.getNotToken());
4412        target.setQuantifier(this.getQuantifier());
4413        target.setQuantifierType(this.getQuantifierType());
4414
4415    }
4416
4417    public static TExpression mergeObjectNameList(TExpression expr, TObjectNameList objectNameList){
4418        TExpression ret = null;
4419        if (expr.expressionType == EExpressionType.simple_object_name_t){
4420            TObjectName objectName = expr.getObjectOperand();
4421            objectName.appendObjectName(objectNameList.getObjectName(0));
4422            ret = expr;
4423        }
4424        return ret;
4425    }
4426
4427
4428    private TColumnDefinitionList colDefList = null;
4429    public TColumnDefinitionList getcolDefList() {
4430                return colDefList;
4431        }
4432
4433    public final static int  BigAndOrNestLevel = 100;
4434    /**
4435     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#not_initialized_yet_t}
4436     */
4437    public final static int unknown = 0;
4438
4439    /**
4440     * Addition: expr + expr
4441     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4442     */
4443    /**
4444     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_plus_t}
4445     */
4446    public final static int PLUS        = 1;
4447
4448    /**
4449     * syntax: expr - expr
4450     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4451     */
4452    /**
4453     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_minus_t}
4454     */
4455    public final static int MINUS       = 2;
4456
4457    /**
4458     * syntax: expr * expr
4459     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4460     */
4461    /**
4462     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_times_t}
4463     */
4464    public final static int TIMES       = 3;
4465
4466    /**
4467     * syntax: expr / expr
4468     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4469     */
4470    /**
4471     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_divide_t}
4472     */
4473    public final static int DIVIDE      = 4;
4474
4475    /**
4476     * Links two string operands to form a string expression.
4477     * <p>syntax: expr || expr,
4478     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4479     */
4480    /**
4481     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#concatenate_t}
4482     */
4483    public final static int CONCATENATE = 5;
4484
4485    /**
4486     * SQL SERVER,TERADATE(mod)
4487     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4488     */
4489    /**
4490     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_modulo_t}
4491     */
4492    public final static int MODULO = 6; //
4493
4494    /**
4495     * Used in set clause of update statement.
4496     * <p> Or, assign argument in postgresql function argument like this:
4497     * <p> param_name ASSIGN_SIGN basic_expr
4498     * <P> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4499     */
4500    /**
4501     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#assignment_t}
4502     */
4503    public final static int ASSIGNMENT = 7; //
4504
4505    /**
4506     * SQL SERVER, postgresql
4507     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4508     */
4509    /**
4510     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_and_t}
4511     */
4512    public final static int BITWISE_AND = 8;
4513
4514    /**
4515     * SQL SERVER, postgresql
4516     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4517     */
4518    /**
4519     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_or_t}
4520     */
4521    public final static int BITWISE_OR = 9;
4522
4523    /**
4524     * MySQL, postgresql
4525     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4526     */
4527    /**
4528     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_xor_t}
4529     */
4530    public final static int BITWISE_XOR = 10; //
4531
4532    /**
4533     * SQL SERVER
4534     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4535     */
4536    /**
4537     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_exclusive_or_t}
4538     */
4539    public final static int BITWISE_EXCLUSIVE_OR = 11;
4540
4541    /**
4542     * SQL SERVER
4543     * <p>The scope resolution operator :: provides access to static members of a compound data type,
4544     * SELECT @hid = hierarchyid::GetRoot();
4545     * <p>Not implemented yet,
4546     */
4547    /**
4548     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#scope_resolution_t}
4549     */
4550    public final static int SCOPE_RESOLUTION = 12; //
4551
4552    /**
4553     * teradata ** , Postgresql ^
4554     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4555     */
4556    /**
4557     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#exponentiate_t}
4558     */
4559    public final static int  EXPONENTIATE = 13; //
4560
4561    /**
4562     * sql server 2008 +=,-=,*=,/=,%=
4563     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4564     */
4565    /**
4566     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_compound_operator_t}
4567     */
4568    public final static int  compoundAssignment = 14;
4569
4570    /**
4571     * specifies a column, pseudocolumn, sequence number,
4572     * value can be get via {@link #getObjectOperand()} which is type of {@link TObjectName}.
4573     */
4574    /**
4575     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_object_name_t}
4576     */
4577    public final static int simpleObjectname = 15;
4578
4579    /**
4580     * specifies a constant,
4581     * value can be get via {@link #getConstantOperand()}
4582     */
4583    /**
4584     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_constant_t}
4585     */
4586    public final static int simpleConstant = 16;
4587
4588    /**
4589     * specifies a null,
4590     * value can be get via {@link #getSourcetokenOperand()} which is type of {@link TSourceToken}.
4591     */
4592    /**
4593     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_source_token_t}
4594     */
4595    public final static int simpleSourcetoken = 17;
4596
4597    /**
4598     * expression with parenthesis,
4599     * expr can be get via {@link #getLeftOperand()} which is type of {@link TExpression}.
4600     */
4601    /**
4602     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#parenthesis_t}
4603     */
4604    public final static int compoundParenthesis = 18;
4605
4606    /**
4607     * unary plus expression,
4608     * <p>syntax: + expression
4609     * <p>expr can be accessed via {@link #getRightOperand()}
4610     */
4611    /**
4612     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_plus_t}
4613     */
4614    public final static int compoundUnaryPlus = 19;
4615
4616    /**
4617     * unary minus expression,
4618     * <p>syntax: - expression
4619     * <p>expr can be accessed via {@link #getRightOperand()}
4620     */
4621    /**
4622     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_minus_t}
4623     */
4624    public final static int compoundUnaryMinus = 20;
4625
4626    /**
4627     * Oracle prior expression, syntax: PRIOR expr
4628     * value can be accessed via {@link #getRightOperand()} which is type of {@link TExpression}
4629     */
4630    /**
4631     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_prior_t}
4632     */
4633    public final static int compoundPrior = 21;
4634
4635    /**
4636     * CASE expressions let you use IF ... THEN ... ELSE logic in SQL statements without
4637     * having to invoke procedures.
4638     * value can be accessed via {@link #getCaseExpression()} which is type of {@link TCaseExpression}.
4639     */
4640    /**
4641     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#case_t}
4642     */
4643    public final static int caseExprOperator = 22;
4644
4645    /**
4646     * A CURSOR expression returns a nested cursor.
4647     * <p>syntax: CURSOR(subquery ),
4648     * <p>subquery can be accessed via {@link #getSubQuery()} which is type of {@link TSelectSqlStatement}.
4649     */
4650    /**
4651     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#cursor_t}
4652     */
4653    public final static int cursorExprOperator = 23;
4654
4655    /**
4656     * funcation expression,
4657     * <p>value can be get via {@link #getFunctionCall()}
4658    */
4659    /**
4660     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#function_t}
4661     */
4662    public final static int funcationCallOperator = 24;
4663
4664
4665    /**
4666     * datetime expression
4667     * <p>N/A
4668     */
4669    /**
4670     * @deprecated As of v1.4.3.0
4671     */
4672    public final static int datetimeExprOperator = 25;
4673
4674    /**
4675     * interval expression
4676     * <p>N/A
4677     */
4678    /**
4679     * @deprecated As of v1.4.3.0
4680     */
4681    public final static int intervalExprOperator = 26;
4682
4683
4684    /**
4685     * model expression, not implemented yet
4686     * <p>N/A
4687     */
4688    /**
4689     * @deprecated As of v1.4.3.0
4690     */
4691    public final static int modelExprOperator = 27;
4692
4693    /**
4694     * A scalar subquery expression is a subquery that returns exactly one column value
4695     * from one row.
4696     * <br>value can be get via {@link #getSubQuery()} which is type of {@link TSelectSqlStatement}.
4697     */
4698    /**
4699     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#subquery_t}
4700     */
4701    public final static int subqueryExprOperator = 28;
4702
4703    //
4704    /**
4705     * type constructor expression,
4706     * <p>not implemented yet
4707     */
4708    /**
4709     * @deprecated As of v1.4.3.0
4710     */
4711    public final static int typeconstructorExprOperator = 29;
4712
4713
4714    /**
4715     * object access expression, some of those was represented by simpleObjectname expression.
4716     * <p>N/A
4717     */
4718    /**
4719     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#object_access_t}
4720     */
4721    public final static int objectaccessExprOperator = 30;
4722
4723    // model conditions is not implemented yet
4724    // multiset conditions is not implemented yet
4725
4726    /**
4727     * pattern matching conditon support like only, regexp_like was treat as a function
4728     * <p>N/A
4729     */
4730    //public final static int patternMatchingExprOperator = 31;
4731    //xml conditon not implemented here, treat as a function
4732
4733
4734    /**
4735     * place holder expression
4736     */
4737    /**
4738     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#place_holder_t}
4739     */
4740    public final static int placeholderExprOperator = 32;
4741
4742    /**
4743     * IN expr, values can be get via {@link #getInExpr()}
4744     */
4745    /**
4746     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#group_t}
4747     */
4748    public final static int in_expr = 34;
4749
4750    /**
4751     * row descriptor, values can be get via {@link #getExprList()}
4752     */
4753    /**
4754     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#list_t}
4755     */
4756    public final static int expr_list = 35;
4757
4758    // dummy expression operator, used in preOrderTraverse,inOrderTraverse, postOrderTraverse function only.
4759    /**
4760     * @deprecated As of v1.4.3.0
4761     */
4762    public final static int dummyOperator = 37;
4763
4764    /**
4765     * Comparison conditions compare one expression with another.
4766     * The result of such a comparison can be TRUE, FALSE, or NULL.
4767     *
4768     * A simple comparison condition specifies a comparison with expressions or subquery results.
4769     * <p>Syntax: expr EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN expr,
4770     * or, (expr_list) EQUAL|NOT_EQUAL (subquery)
4771     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4772     */
4773    /**
4774     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_comparison_t}
4775     */
4776    public final static int simple_comparison_conditions = 40;
4777
4778    /**
4779     * Comparison conditions compare one expression with another.
4780     * The result of such a comparison can be TRUE, FALSE, or NULL.
4781     *
4782     * <p>A group comparison condition specifies a comparison with any or all members
4783     * in a list or subquery.
4784     * <p>Syntax: expr EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN ANY|SOME|ALL (expr_list|subquery),
4785     * or, (expr_list) EQUAL|NOT_EQUAL ANY|SOME|ALL (expr_list|subquery)
4786     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4787     */
4788    /**
4789     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#group_comparison_t}
4790     */
4791    public final static int group_comparison_conditions = 41;
4792
4793    /**
4794     * An in_condition is a membership condition. It tests a value for membership in a list of values or subquery.
4795     * <p>Syntax: (expr|expr_list) IN|NOT IN (expr_list|subquery).
4796     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4797     * <p>Use {@link #getOperatorToken()} to distinguish in or not in.
4798     */
4799    /**
4800     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#in_t}
4801     */
4802    public final static int in_conditions = 42;
4803
4804    /**
4805     * The ORACLE floating-point conditions let you determine whether an expression is infinite or is the undefined result of an operation (is not a number or NaN).
4806     * <p>Syntax: expr IS|IS NOT (NAM|INFINITE).
4807     * <p>Value can be get via  {@link #getLeftOperand()}
4808     */
4809    /**
4810     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#floating_point_t}
4811     */
4812    public final static int floating_point_conditions = 43;
4813
4814    /**
4815     * The pattern-matching conditions compare character data.
4816     * <p>The LIKE conditions specify a test involving pattern matching.
4817     * <p>Syntax: expr1 LIKE|NOT_LIKE expr1 [ESCAPE expr3],
4818     * <p>expr1 can be get via {@link #getLeftOperand()},
4819     * <p>expr2 can be get via  {@link #getRightOperand()},
4820     * <p>expr3 can be get via  {@link #getLikeEscapeOperand()},
4821     * <p>Use {@link #getOperatorToken()} to distinguish is like or is not like
4822     */
4823    /**
4824     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#pattern_matching_t}
4825     */
4826    public final static int pattern_matching_conditions = 45;
4827
4828    /**
4829     * A NULL condition tests for nulls. This is the only condition that you should use to test for nulls.
4830     * <p>Syntax: expr IS [NOT] null
4831     * <p>expr can be accessed via {@link #getLeftOperand()}
4832     * <p>Use {@link #getOperatorToken()} to distinguish is null or is not null
4833     */
4834    /**
4835     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#null_t}
4836     */
4837    public final static int null_conditions = 46;
4838
4839    /**
4840     * A BETWEEN condition determines whether the value of one expression is in an interval defined by two other expressions.
4841     * <p>Syntax: expr1 [NOT] BETWEEN expr2 AND expr3
4842     * <p>expr1 can be get via {@link #betweenOperand},
4843     * <p>expr2 can be get via {@link #getLeftOperand()}, and expr3 can be get via {@link #getRightOperand()},
4844     * <p>Use {@link #getOperatorToken()} to distinguish is between or is not between
4845     */
4846    /**
4847     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#between_t}
4848     */
4849    public final static int between_conditions = 47;
4850
4851    /**
4852     * An EXISTS condition tests for existence of rows in a subquery.
4853     * <p>Syntax: EXISTS (subquery).
4854     * <p>value of subquery can be get via {@link #getSubQuery()}
4855     */
4856    /**
4857     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#exists_t}
4858     */
4859    public final static int exists_condition = 48;
4860
4861    /**
4862     * <p>expr can be accessed via {@link #getLeftOperand()}
4863     */
4864    /**
4865     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_of_type_t}
4866     */
4867    public final static int isoftype_condition = 49;
4868
4869    /**
4870     * A logical condition combines the results of two component conditions to produce a single result based on them or to invert the result of a single condition.
4871     *<p> Syntax: expr AND expr.
4872     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4873     */
4874    /**
4875     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_and_t}
4876     */
4877    public final static int logical_conditions_and = 50;
4878
4879    /**
4880     * A logical condition combines the results of two component conditions to produce a single result based on them or to invert the result of a single condition.
4881     * <p>Syntax: expr OR expr.
4882     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4883     */
4884    /**
4885     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_or_t}
4886     */
4887    public final static int logical_conditions_or = 51;
4888
4889    /**
4890     * A logical condition combines the results of two component conditions to produce a single result based on them or to invert the result of a single condition.
4891     * <p>Syntax: expr XOR expr.
4892     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4893     */
4894    /**
4895     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_xor_t}
4896     */
4897    public final static int logical_conditions_xor = 52;
4898
4899    /**
4900     * A logical condition combines the results of two component conditions to produce a single result based on them or to invert the result of a single condition.
4901     * <p>Syntax: NOT expr.
4902     * <p>value can be get via {@link #rightOperand},
4903     */
4904    /**
4905     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_not_t}
4906     */
4907    public final static int logical_conditions_not = 53;
4908
4909    /**
4910     * Mdx is logical condition
4911     */
4912    /**
4913     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_t}
4914     */
4915    public final static int logical_conditions_is = 54;
4916
4917
4918    /**
4919     * Mdx range operator :
4920     */
4921    /**
4922     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#range_t}
4923     */
4924    public final static int RANGE = 55;
4925
4926    /**
4927     *   mdx power operator ^
4928     */
4929    /**
4930     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#power_t}
4931     */
4932    public final static int POWER = 56; //
4933
4934    /**
4935     * ORACLE,teradata date time expression, at time zone.
4936     * <p>Syntax: expr1 AT TIME ZONE expr2
4937     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
4938     */
4939    /**
4940     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#at_time_zone_t}
4941     */
4942    public final static int at_time_zone = 100;
4943
4944
4945    /**
4946     * ORACLE,teradata date time expression, at local.
4947     * <p>Syntax: expr AT LOCAL.
4948     * <p>expr can be accessed via {@link #getLeftOperand()}
4949     */
4950    /**
4951     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#at_local_t}
4952     */
4953    public final static int at_local = 101;
4954
4955    /**
4956     * ORACLE date time expression, day to second.
4957     * <p>Syntax: expr DAY [( integer )] TO SECOND [( integer )].
4958     * <p>expr cam be get via {@link #getLeftOperand()}.
4959     * <p>The type of this operand is {@link TExpression}.
4960     */
4961    /**
4962     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#day_to_second_t}
4963     */
4964    public final static int day_to_second = 102;
4965
4966    /**
4967     * ORACLE date time expression, year to month.
4968     *<p> Syntax: expr YEAR [( integer )] TO MONTH.
4969     * <p>expr can be accessed via {@link #getLeftOperand()}
4970     */
4971    /**
4972     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#year_to_month_t}
4973     */
4974    public final static int year_to_month = 103;
4975
4976    /**
4977     * teradata interval expression:
4978     * <p>( date_time_expression date_time_term ) start TO end
4979     * <p>{@link #getIntervalExpr()}
4980     */
4981    /**
4982     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#interval_t}
4983     */
4984    public final static int interval_expression = 104;
4985
4986    /**
4987     * teradata
4988     * Constructs a new instance of a structured type
4989     * and initializes it using the specified constructor method or function.
4990     *<p> object reference {@link TExpression#getFunctionCall()}
4991     */
4992    /**
4993     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#new_structured_type_t}
4994     */
4995    public final static int new_structured_type = 110;
4996
4997    /**
4998     * teradata
4999     * Constructs a new instance of a dynamic or VARIANT_TYPE UDT
5000     * and defines the run time composition of the UDT.
5001     * object reference {@link #getNewVariantTypeArgumentList()}
5002     */
5003    /**
5004     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#new_variant_type_t}
5005     */
5006    public final static int new_variant_type = 111;
5007
5008    /**
5009     * teradata period expression: ldiff
5010     * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5011     */
5012    /**
5013     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_ldiff_t}
5014     */
5015    public final static int period_ldiff = 115;
5016
5017    /**
5018     * teradata period expression: rdiff
5019     * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5020     */
5021    /**
5022     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_rdiff_t}
5023     */
5024    public final static int period_rdiff = 117;
5025
5026    /**
5027     * teradata period expression: p_intersect
5028     * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5029     */
5030    /**
5031     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_p_intersect_t}
5032     */
5033    public final static int period_p_intersect = 119;
5034
5035    /**
5036     * teradata period expression: p_normalize
5037     * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5038     */
5039    /**
5040     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_p_normalize_t}
5041     */
5042    public final static int period_p_normalize = 121;
5043
5044    /**
5045     * teradata until changed condition
5046     * <p> syntax: END(period_value_expression) IS[NOT] UNTIL_CHANGED
5047     * <p> ending bound of a Period value expression can be accessed via {@link #getLeftOperand()}
5048     */
5049    /**
5050     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#until_changed_t}
5051     */
5052    public final static int until_changed = 123;
5053
5054    /**
5055     * Postgresql, is document condition
5056     * <p>expr is [not] document
5057     * <p> expr was set in {@link #leftOperand}.
5058     * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not.
5059     */
5060    /**
5061     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_document_t}
5062     */
5063    public final static int is_document = 133;
5064
5065
5066    /**
5067     * Postgresql,
5068     * <p>expr is [not] distinct from expr
5069     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5070     * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not.
5071     */
5072    /**
5073     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_distinct_from_t}
5074     */
5075    public final static int is_distinct_from = 135;
5076
5077    /**
5078     * Postgresql
5079     * <p> true, false, unknown condition
5080     * <p> expr is [not] true
5081     * <p> expr is [not] false
5082     * <p> expr is [not] unknown
5083     * <p> expr can be accessed via {@link #getLeftOperand()}
5084     * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not.
5085     */
5086    /**
5087     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_true_t},
5088     * {@link EExpressionType#is_false_t},{@link EExpressionType#is_unknown_t}
5089     */
5090    public final static int true_false_unknown = 137;
5091
5092
5093
5094    /**
5095     *  sql server, Is a clause that can be applied to a database definition or a column definition
5096     *  to define the collation, or to a character string expression to apply a collation cast.
5097     *
5098     * postgresql
5099     *
5100     *<p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5101     */
5102    /**
5103     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#collate_t}
5104     */
5105    public final static int COLLATE = 200+23;
5106
5107    /**
5108     * sql server, LEFTJOIN_OP *=
5109     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5110     */
5111    /**
5112     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#left_join_t}
5113     */
5114    public final static int LEFTJOIN_OP = 200+24; //
5115
5116    /**
5117     * sql server, RIGHTJOIN_OP =*
5118     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5119     */
5120    /**
5121     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#right_join_t}
5122     */
5123    public final static int RIGHTJOIN_OP = 200+25; //
5124
5125    /**
5126     * plsql RAISE_APPLICATION_ERROR (num=> -20107,    msg=> 'Duplicate customer or order ID');
5127     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5128     */
5129    /**
5130     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#ref_arrow_t}
5131     */
5132    public final static int ref_arrow = 200+26;//
5133
5134
5135    /**
5136     * plsql
5137     * <p>expr can be accessed via {@link #getLeftOperand()}
5138     */
5139    /**
5140     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#typecast_t}
5141     */
5142    public final static int typecast = 200+27;//
5143    /**
5144     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arrayaccess_t}
5145     */
5146    public final static int arrayaccess = 200+28;//plsql array access
5147
5148    /**
5149     * oracle unary operator connect_by_root is only valid in hierarchical queries
5150     * <p>expr can be accessed via {@link #getRightOperand()}
5151     */
5152    /**
5153     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_connect_by_root_t}
5154     */
5155    public final static int connect_by_root = 200+29; //
5156
5157    /**
5158     * SQL SERVER Proprietary syntax, set alias of a column in select list,
5159     * column expr in rightOperand.
5160     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5161     */
5162    /**
5163     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#sqlserver_proprietary_column_alias_t}
5164     */
5165    public final static int sqlserver_proprietary_column_alias = 200+30; //
5166
5167
5168    /**
5169      MySQL binary operator, select binary 'a' = 'A'
5170     * <p>syntax: binary expr
5171     * <p>expr can be accessed via {@link #getRightOperand()}
5172     */
5173    /**
5174     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_binary_operator_t}
5175     */
5176    public final static int mysql_binary_operator = 300;
5177
5178    /**
5179     * MySQL left shift
5180     * <p>Syntax: expr << expr.
5181     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5182     */
5183    /**
5184     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#left_shift_t}
5185     */
5186    public final static int left_shift = 301;
5187
5188    /**
5189     * MySQL rigth shift
5190     * <p>Syntax: expr >> expr.
5191     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5192     */
5193    /**
5194     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#right_shift_t}
5195     */
5196    public final static int right_shift = 302;
5197
5198    /**
5199     * Oracle MULTISET operator
5200     * <p>Syntax MULTISET (subquery)
5201     * <p> subquery can be get via {@link #getSubQuery()}
5202     */
5203    /**
5204     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#multiset_t}
5205     */
5206    public final static int multisetExprOperator = 310;
5207
5208    /**
5209     * If an expression yields a value of a composite type (row type), then a specific field of the row can be extracted by writing
5210     * <p> expression.fieldname
5211     * <p> In general the row expression must be parenthesized, but the parentheses can be omitted
5212     * <p> when the expression to be selected from is just a table reference or positional parameter.
5213     * <p> For example:
5214     * <p> mytable.mycolumn
5215     * <p> $1.somecolumn
5216     * <p> (rowfunction(a,b)).col3
5217     * <p>
5218     * <p> (Thus, a qualified column reference is actually just a special case of the field selection syntax.) An important special case is extracting a field from a table column that is of a composite type:
5219     * <p> (compositecol).somefield
5220     * <p> (mytable.compositecol).somefield
5221     * <p> The parentheses are required here to show that compositecol is a column name not a table name,
5222     * <p> or that mytable is a table name not a schema name in the second case.
5223     * <p>
5224     * <p> n a select list, you can ask for all fields of a composite value by writing .*:
5225     * <p> (compositecol).*
5226     * <p>
5227     * <p>
5228     * <p> When expression in following syntax, it will be marked as {@link #fieldSelection}, and check {@link #getFieldName()}
5229     * <p> (rowfunction(a,b)).col3
5230     * <p> (compositecol).somefield
5231     * <p> (mytable.compositecol).somefield
5232     * <p> (compositecol).*
5233     * <p>
5234     * <p> Otherwise, it will be marked as {@link #simpleObjectname}:
5235     * <p> mytable.mycolumn
5236     * <p> $1.somecolumn
5237     */
5238    /**
5239     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#fieldselection_t}
5240     */
5241    public final static int fieldSelection = 501;
5242
5243    /**
5244     * An array constructor is an expression that builds an array value using values for its member elements.
5245     * <p> like this: ARRAY[1,2,3+4]
5246     * <p> array element values can be accessed via {@link #getExprList()},
5247     * <p> or {@link #getExprList()} can be null when it is: array[]
5248     * <p>
5249     * <p> It is also possible to construct an array from the results of a subquery like this:
5250     * <p> SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
5251     * <p> thus, subquery can be access via {@link #getSubQuery()}
5252     */
5253    /**
5254     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#array_constructor_t}
5255     */
5256    public final static int arrayConstructor = 505;     //postgresql
5257
5258    /**
5259     * A row constructor is an expression that builds a row value (also called a composite value) using values for its member fields.
5260     * <p> like this: ROW(1,2.5,'this is a test')
5261     * <p> element values can be accessed via {@link #getExprList()},
5262     * <p> or {@link #getExprList()} can be null when it is: row()
5263     */
5264    /**
5265     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#row_constructor_t}
5266     */
5267    public final static int rowConstructor = 509;
5268
5269    /**
5270     * Postgresql factorial:
5271     * <p> expr !
5272     * <p> expr can be accessed via {@link #getLeftOperand()}
5273     */
5274    /**
5275     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_factorial_t}
5276     */
5277    public final static int factorial = 515;
5278
5279    /**
5280     * Postgresql square root
5281     * <p> |/ 25.0
5282     * <p> expr can be accessed via {@link #getRightOperand()}
5283     */
5284    /**
5285     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_squareroot_t}
5286     */
5287    public final static int squareRoot = 517;
5288
5289    /**
5290     * Postgresql cube root
5291     * <p> ||/ 27.0
5292     * <p> expr can be accessed via {@link #getRightOperand()}
5293     */
5294    /**
5295     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_cuberoot_t}
5296     */
5297    public final static int cubeRoot = 519;
5298
5299    /**
5300     * Postgresql factorial (prefix operator):
5301     * <p> !! 5
5302     * <p> expr can be accessed via {@link #getRightOperand()}
5303     */
5304    /**
5305     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_factorialprefix_t}
5306     */
5307    public final static int factorialPrefix = 521;
5308
5309    /**
5310     * Postgresql absolute value
5311     * <p> @ -5.0
5312     * <p> expr can be accessed via {@link #getRightOperand()}
5313     */
5314    /**
5315     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_absolutevalue_t}
5316     */
5317    public final static int absoluteValue = 523;
5318
5319    /**
5320     * Postgresql bitwise shit left
5321     * <p> expr << expr
5322     * <p> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5323     */
5324    /**
5325     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_shift_left_t}
5326     */
5327    public final static int BITWISE_SHIFT_LEFT = 525; //postgresql
5328
5329    /**
5330     * Postgresql bitwise shit right
5331     * <p> expr >> expr
5332     * <p> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5333     */
5334    /**
5335     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_shift_right_t}
5336     */
5337    public final static int BITWISE_SHIFT_RIGHT = 527; //postgresql
5338
5339    /**
5340     * Postgresql bitwise not
5341     * <p> ~expr
5342     * <p> expr can be accessed via {@link #getRightOperand()}
5343     */
5344    /**
5345     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_bitwise_not_t}
5346     */
5347    public final static int BITWISE_NOT = 529; //postgresql
5348
5349    /**
5350     * sql server
5351     * <p>expr can be accessed via {@link #getRightOperand()}
5352     */
5353
5354    /**
5355     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_bitwise_not_t}
5356     */
5357    public final static int compoundUnaryBitwiseNot = 200+22; //
5358
5359    //
5360
5361    /**
5362     * ORACLE
5363     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5364     */
5365    /**
5366     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#member_of_t}
5367     */
5368    public final static int member_of = 541;
5369
5370    /**
5371     * Netezza
5372     * <p>NEXT VALUE FOR <sequence name>
5373     * <p>NEXT <integer expression> VALUE FOR <sequence name>
5374     * <p> integer expression can be accessed via {@link #getLeftOperand()} if any.
5375     * <p> sequence name name can be accessed via {@link #getRightOperand()}
5376     */
5377
5378    /**
5379     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#next_value_for_t}
5380     */
5381    public final static int nextValueOf = 601;
5382
5383    /**
5384     * This UnknownOperator means this expression was not recognized by SQL parser yet.
5385     * <p>In syntax like this:
5386     * <p> expr OPERATOR expr
5387     * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()}
5388     */
5389    /**
5390     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unknown_t}
5391     */
5392    public final static int UnknownOperator = 901;
5393
5394
5395    /**
5396     * This UnknownLeftUnaryOperator means this expression was not recognized by SQL parser yet.
5397     * <p>In syntax like this:
5398     * <p> OPERATOR expr
5399     * <p>expr can be accessed via {@link #getRightOperand()}
5400     */
5401    /**
5402     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_left_unknown_t}
5403     */
5404    public final static int UnknownUnaryOperator = 905;
5405
5406    /**
5407     * This UnknownLeftUnaryOperator means this expression was not recognized by SQL parser yet.
5408     * <p>In syntax like this:
5409     * <p> expr OPERATOR
5410     * <p>expr can be accessed via {@link #getLeftOperand()}
5411     */
5412    /**
5413     * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_right_unknown_t}
5414     */
5415    public final static int UnknownUnaryOperatorRight = 909;
5416
5417
5418}