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