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.getAstext(); 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 case cursor_attribute_t: 1934 break; 1935 default: 1936 leftOperand = (TExpression)arg2; 1937 rightOperand = (TExpression)arg3; 1938 break; 1939 } 1940 } 1941 1942 /** 1943 * initialize a new instance of TExpression. 1944 * 1945 * @param arg1 type of this expression, a value of type {@link EExpressionType} 1946 * @param arg2 operator, a value of {@link TSourceToken} 1947 * @param arg3 left operand, a value of {@link TExpression} 1948 * the meaning of this parameter varies depends on the value of arg1. 1949 * @param arg4 right operand, a value of {@link TExpression} 1950 */ 1951 public void init(Object arg1,Object arg2,Object arg3,Object arg4){ 1952 init(arg1); 1953 operatorToken = (TSourceToken)arg2; 1954 switch (expressionType){ 1955 case simple_object_name_t: 1956 objectOperand = (TObjectName)arg3; 1957 setStartToken(objectOperand); 1958 setEndToken(objectOperand); 1959 break; 1960 case simple_source_token_t: 1961 sourcetokenOperand = (TSourceToken)arg3; 1962 setStartToken(sourcetokenOperand); 1963 setEndToken(sourcetokenOperand); 1964 break; 1965 case simple_constant_t: 1966 constantOperand = (TConstant)arg3; 1967 setStartToken(constantOperand); 1968 setEndToken(constantOperand); 1969 break; 1970 case function_t: 1971 functionCall = (TFunctionCall)arg3; 1972 break; 1973// case type_constructor_t: 1974// functionCall = (TFunctionCall)arg3; 1975// break; 1976 case arrayaccess_t: 1977 arrayAccess = (TArrayAccess)arg3; 1978 break; 1979 case array_access_expr_t: 1980 leftOperand = (TExpression)arg3; 1981 rightOperand = (TExpression)arg4; 1982 break; 1983 case list_t: 1984 case collection_constructor_list_t: 1985 case collection_constructor_multiset_t: 1986 case collection_constructor_set_t: 1987 exprList = (TExpressionList)arg3; 1988 break; 1989 case field_doubt_t: 1990 TExpression l = (TExpression)arg3; 1991 if (l.getExpressionType() == EExpressionType.simple_object_name_t){ 1992 TObjectName objectName = l.getObjectOperand(); 1993 objectName.setSchemaToken(objectName.getObjectToken()); 1994 objectName.setObjectToken(objectName.getPartToken()); 1995 objectName.setPartToken((TSourceToken)arg4); 1996 1997 expressionType = EExpressionType.simple_object_name_t; 1998 this.objectOperand = l.getObjectOperand(); 1999 }else { 2000 expressionType = EExpressionType.field_t; 2001 } 2002 break; 2003 case column_definition_list_t: 2004 colDefList = (TColumnDefinitionList)arg3; 2005 break; 2006 case simple_comparison_t: 2007 leftOperand = (TExpression)arg3; 2008 leftOperand.setParentExpr(this); 2009 rightOperand = (TExpression)arg4; 2010 rightOperand.setParentExpr(this); 2011 comparisonOperator = operatorToken; 2012 break; 2013 case implicit_datatype_cast_as_t: 2014 leftOperand = (TExpression)arg3; 2015 typeName = (TTypeName)arg4; 2016 break; 2017 default: 2018 if (arg3 != null){ 2019 leftOperand = (TExpression)arg3; 2020 leftOperand.setParentExpr(this); 2021 } 2022 if (arg4 != null){ 2023 rightOperand = (TExpression)arg4; 2024 rightOperand.setParentExpr(this); 2025 } 2026 break; 2027 } 2028 } 2029 2030 public void setOperatorToken(TSourceToken operatorToken) { 2031 this.operatorToken = operatorToken; 2032 switch (this.getExpressionType()){ 2033 case unknown_t: 2034 switch (this.operatorToken.tokencode){ 2035 case TBaseType.OP_MINUS_GREAT: 2036 this.expressionType = EExpressionType.json_get_object; 2037 break; 2038 case TBaseType.OP_MINUS_GREAT_GREAT: 2039 this.expressionType = EExpressionType.json_get_text; 2040 break; 2041 case TBaseType.OP_POUND_GREAT_GREAT: 2042 this.expressionType = EExpressionType.json_get_text_at_path; 2043 break; 2044 case TBaseType.OP_POUND_GREAT: 2045 this.expressionType = EExpressionType.json_get_object_at_path; 2046 break; 2047 case TBaseType.OP_AT_GREAT: 2048 this.expressionType = EExpressionType.json_left_contain; 2049 break; 2050 case TBaseType.OP_LESS_AT: 2051 this.expressionType = EExpressionType.json_right_contain; 2052 break; 2053 case TBaseType.OP_JSONB_QUESTION: // ? 2054 this.expressionType = EExpressionType.json_exist; 2055 break; 2056 case TBaseType.OP_QUESTION_BAR: 2057 this.expressionType = EExpressionType.json_any_exist; 2058 break; 2059 case TBaseType.OP_QUESTION_PUNCTUATION: 2060 this.expressionType = EExpressionType.json_all_exist; 2061 break; 2062 case TBaseType.OP_TILDE_TILDE: 2063 this.expressionType = EExpressionType.pattern_matching_t; 2064 break; 2065 case TBaseType.OP_TILDE_TILDE_STAR: 2066 this.expressionType = EExpressionType.pattern_matching_t; 2067 break; 2068 case TBaseType.OP_EXCLAMATION_TIDLE_TIDLE: 2069 this.expressionType = EExpressionType.pattern_matching_t; 2070 break; 2071 case TBaseType.OP_EXCLAMATION_TIDLE_TIDLE_STAR: 2072 this.expressionType = EExpressionType.pattern_matching_t; 2073 break; 2074 case TBaseType.OP_TILDE_STAR: 2075 this.expressionType = EExpressionType.pattern_matching_t; 2076 break; 2077 case TBaseType.OP_EXCLAMATION_TILDE: 2078 this.expressionType = EExpressionType.pattern_matching_t; 2079 this.setNotToken(operatorToken); 2080 break; 2081 case TBaseType.OP_EXCLAMATION_TIDLE_STAR: 2082 this.expressionType = EExpressionType.pattern_matching_t; 2083 break; 2084 case TBaseType.OP_TILDE_GREAT_TILDE: 2085 case TBaseType.OP_TILDE_LESS_TILDE: 2086 case TBaseType.OP_TILDE_GREAT_EQUAL_TILDE: 2087 case TBaseType.OP_TILDE_LESS_EQUAL_TILDE: 2088 this.expressionType = EExpressionType.pattern_matching_t; 2089 break; 2090 case '~': 2091 this.expressionType = EExpressionType.pattern_matching_t; 2092 break; 2093 case TBaseType.OP_AT_MINUS_AT: 2094 case TBaseType.OP_POUND_POUND: 2095 case TBaseType.OP_PUNCTUATION_LESS: 2096 case TBaseType.OP_PUNCTUATION_GREAT: 2097 case TBaseType.OP_LESS_LESS_BAR: 2098 case TBaseType.OP_BAR_GREAT_GREAT: 2099 case TBaseType.OP_PUNCTUATION_LESS_BAR: 2100 case TBaseType.OP_BAR_PUNCTUATION_GREAT: 2101 case TBaseType.OP_LESS_CARET: 2102 case TBaseType.OP_GREAT_CARET: 2103 case TBaseType.OP_QUESTION_POUND: 2104 case TBaseType.OP_QUESTION_MINUS: 2105 case TBaseType.OP_QUESTION_MINUS_BAR: 2106 case TBaseType.OP_QUESTION_BAR_BAR: 2107 case TBaseType.OP_TILDE_EQUAL: 2108 case TBaseType.OP_LESS_PERCENT: 2109 case TBaseType.OP_GREAT_PERCENT: 2110 this.expressionType = EExpressionType.geo_t; 2111 break; 2112 case TBaseType.OP_LESS_LESS_EQUAL: 2113 case TBaseType.OP_GREAT_GREAT_EQUAL: 2114 this.expressionType = EExpressionType.network_t; 2115 break; 2116 case TBaseType.OP_AT_AT_AT: 2117 case TBaseType.OP_LESS_MINUS_GREAT: 2118 this.expressionType = EExpressionType.text_search_t; 2119 break; 2120 case TBaseType.OP_MINUS_BAR_MINUS: 2121 this.expressionType = EExpressionType.range_t; 2122 break; 2123 case TBaseType.rrw_netezza_op_less_less: 2124 this.expressionType = EExpressionType.left_shift_t; 2125 break; 2126 case TBaseType.rrw_netezza_op_great_great: 2127 this.expressionType = EExpressionType.right_shift_t; 2128 break; 2129 case TBaseType.OP_POUND_MINUS: 2130 this.expressionType = EExpressionType.json_delete_path; 2131 break; 2132 case TBaseType.OP_AT_QUESTION: 2133 this.expressionType = EExpressionType.json_path_exists; 2134 break; 2135 case TBaseType.OP_AT_AT: 2136 this.expressionType = EExpressionType.json_path_match; 2137 break; 2138 default: 2139 break; 2140 } 2141 2142 2143 if (this.getExpressionType() == EExpressionType.unknown_t) { 2144 if(this.operatorToken.toString().equalsIgnoreCase("%")){ 2145 this.expressionType = EExpressionType.arithmetic_modulo_t; 2146 }else if(this.operatorToken.toString().equalsIgnoreCase("&")){ 2147 this.expressionType = EExpressionType.bitwise_and_t; 2148 }else if(this.operatorToken.toString().equalsIgnoreCase("|")){ 2149 this.expressionType = EExpressionType.bitwise_or_t; 2150 }else if(this.operatorToken.toString().equalsIgnoreCase("#")){ 2151 this.expressionType = EExpressionType.bitwise_xor_t; 2152 }else if(this.operatorToken.toString().equalsIgnoreCase("<<")){ 2153 this.expressionType = EExpressionType.left_shift_t; 2154 }else if(this.operatorToken.toString().equalsIgnoreCase(">>")){ 2155 this.expressionType = EExpressionType.right_shift_t; 2156 } 2157 } 2158 2159 break; 2160 case unary_left_unknown_t: 2161 if(this.operatorToken.toString().equalsIgnoreCase("|/")){ 2162 this.expressionType = EExpressionType.unary_squareroot_t; 2163 }else if(this.operatorToken.toString().equalsIgnoreCase("||/")){ 2164 this.expressionType = EExpressionType.unary_cuberoot_t; 2165 }else if(this.operatorToken.toString().equalsIgnoreCase("!!")){ 2166 this.expressionType = EExpressionType.unary_factorialprefix_t; 2167 }else if(this.operatorToken.toString().equalsIgnoreCase("@")){ 2168 this.expressionType = EExpressionType.unary_absolutevalue_t; 2169 }else if(this.operatorToken.toString().equalsIgnoreCase("~")){ 2170 this.expressionType = EExpressionType.unary_bitwise_not_t; 2171 }else if(this.operatorToken.toString().equalsIgnoreCase("-")){ 2172 this.expressionType = EExpressionType.unary_minus_t; 2173 }else if(this.operatorToken.toString().equalsIgnoreCase("+")){ 2174 this.expressionType = EExpressionType.unary_plus_t; 2175 } 2176 2177 break; 2178 case unary_right_unknown_t: 2179 if(this.operatorToken.toString().equalsIgnoreCase("!")) { 2180 this.expressionType = EExpressionType.unary_factorial_t; 2181 } 2182 break; 2183 default: 2184 break; 2185 } 2186 2187 } 2188 2189 2190 private ArrayList<TSourceToken> operatorTokens = null; 2191 2192 /** 2193 * Operator token used in expression which contains multiple operator tokens such as SIMILAR TO , IS DISTINCT FROM and etc 2194 * added since v3.0.8.6 2195 * 2196 * @return operator token list 2197 */ 2198 public ArrayList<TSourceToken> getOperatorTokens() { 2199 if (operatorTokens == null){ 2200 operatorTokens = new ArrayList<>(); 2201 } 2202 return operatorTokens; 2203 } 2204 2205 /** 2206 * Operator token used in expression such as +,-,*,/ and etc 2207 * @return operator token 2208 */ 2209 public TSourceToken getOperatorToken() { 2210 2211 return operatorToken; 2212 } 2213 2214 public void setVal(Object val) { 2215 this.val = val; 2216 } 2217 2218 /** 2219 * value of this expression, valid only after evaluate this expression. 2220 * @return a value object 2221 */ 2222 public Object getVal() { 2223 2224 return val; 2225 } 2226 2227 private Object val = null; 2228 2229 // expression type value 2230 2231 // simple expression 2232 2233 2234 public TConstant getConstantOperand() { 2235 return constantOperand; 2236 } 2237 2238 2239 public void setNewVariantTypeArgumentList(TNewVariantTypeArgumentList newVariantTypeArgumentList) { 2240 this.newVariantTypeArgumentList = newVariantTypeArgumentList; 2241 } 2242 2243 public TNewVariantTypeArgumentList getNewVariantTypeArgumentList() { 2244 return newVariantTypeArgumentList; 2245 } 2246 2247 private TNewVariantTypeArgumentList newVariantTypeArgumentList = null; 2248 2249 /** 2250 * PLSQL: 2251 * <p> expr typecast typename 2252 * <p> 2253 * <p> Postgresql 2254 * <p> expr::typename 2255 * <p> 2256 * <p> Informix 2257 * <p> expr::typename 2258 * <p> 2259 * <p> expr can be accessed via {@link #leftOperand}, typename can be accessed via {@link #getTypeName()} 2260 */ 2261 2262 private TTypeName typeName; 2263 2264 public void setTypeName(TTypeName typeName) { 2265 this.typeName = typeName; 2266 } 2267 2268 public TTypeName getTypeName() { 2269 2270 return typeName; 2271 } 2272 2273 /** 2274 * valid when {@link #getExpressionType() } is {@link TExpression#fieldSelection} 2275 * @return field name 2276 */ 2277 public TObjectName getFieldName() { 2278 return fieldName; 2279 } 2280 2281 private TObjectName fieldName; 2282 2283 public void setIndirection(TIndirection indirection) { 2284 if (indirection != null){ 2285 if (indirection.isRealIndices()){ 2286 this.subscripts = true; 2287 }else{ 2288 //this.setExpressionType(TExpression.fieldSelection); 2289 setExpressionType(EExpressionType.fieldselection_t); 2290 this.fieldName = indirection.getIndices().getElement(0).getAttributeName(); 2291 //this.fieldName.setObjectType(TObjectName.ttobjFieldName); 2292 this.fieldName.setDbObjectType(EDbObjectType.fieldName); 2293 } 2294 this.indirection = indirection; 2295 } 2296 } 2297 2298 private boolean subscripts; 2299 2300 /** 2301 * If an expression yields a value of an array type, then a specific element of the array value can be extracted by writing 2302 * <p> expression[subscript] 2303 * <p> or multiple adjacent elements (an "array slice") can be extracted by writing 2304 * <p> expression[lower_subscript:upper_subscript] 2305 * <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. 2306 * <p> Also, multiple subscripts can be concatenated when the original array is multidimensional. For example: 2307 * <p> 2308 * <p> when sytnax like this: 2309 * <p> mytable.arraycolumn[4] 2310 * <p> mytable.two_d_column[17][34] 2311 * <p> $1[10:42] 2312 * <p> 2313 * <p> check {@link #getObjectOperand()} for more detailed information about subscript. 2314 * <p> 2315 * <p> when syntax like this: 2316 * <p> (arrayfunction(a,b))[42] 2317 * <p> 2318 * <p> check {@link #getIndirection()} when {@link #isSubscripts()} is true. 2319 * @return tells whether it is an expression with subscript. 2320 */ 2321 public boolean isSubscripts() { 2322 return subscripts; 2323 } 2324 2325 public ArrayList<TIndices> getJson_path() { 2326 return json_path; 2327 } 2328 2329 private ArrayList<TIndices> json_path; 2330 2331 public TIndirection getIndirection() { 2332 return indirection; 2333 } 2334 2335 private TIndirection indirection; 2336 2337 private boolean notModifier; 2338 2339 /** 2340 * return true for expression like this: <expr> NOT IS NULL, <expr> NOT LIKE <expr> , <expr> NOT BETWEEN <expr> AND <expr> 2341 * and return false for expression like this: <expr> IS NULL, <expr> LIKE <expr> , <expr> BETWEEN <expr> AND <expr> 2342 * @return 2343 */ 2344 2345 /** 2346 * @deprecated As of v1.4.3.0, replaced by {@link #getNotToken()} 2347 */ 2348 public boolean isNotModifier() { 2349 notModifier = (getOperatorToken() != null); 2350 if (notModifier){ 2351 notModifier = (getOperatorToken().tokencode == TBaseType.rrw_not); 2352 } 2353 return notModifier; 2354 } 2355 2356 private TOutputFormatPhraseList outputFormatPhraseList; 2357 2358 public void setOutputFormatPhraseList(TOutputFormatPhraseList outputFormatPhraseList) { 2359 this.outputFormatPhraseList = outputFormatPhraseList; 2360 } 2361 2362 /** 2363 * teradata: 2364 * <p>column_expr (named alias_name) 2365 * @return (named alias_name) in column_expr 2366 */ 2367 public TOutputFormatPhraseList getOutputFormatPhraseList() { 2368 2369 return outputFormatPhraseList; 2370 } 2371 2372 public TExpressionList getExprList() { 2373 return exprList; 2374 } 2375 2376 private TIntervalExpression intervalExpr = null; 2377 2378 public void setIntervalExpr(TIntervalExpression intervalExpr) { 2379 this.intervalExpr = intervalExpr; 2380 } 2381 2382 public TIntervalExpression getIntervalExpr() { 2383 2384 return intervalExpr; 2385 } 2386 2387 private TExpressionList exprList = null; 2388 2389 private TExceptReplaceClause exceptReplaceClause; 2390 2391 public TExceptReplaceClause getExceptReplaceClause() { 2392 if (exceptReplaceClause == null) { 2393 if (this.getObjectOperand()!=null) { 2394 if (this.getObjectOperand().getExceptReplaceClause()!=null) { 2395 exceptReplaceClause = this.getObjectOperand().getExceptReplaceClause(); 2396 }else if (this.getIndirection()!=null) { 2397 if (this.getIndirection().getIndices()!=null) { 2398 if (this.getIndirection().getIndices().size()>0) { 2399 exceptReplaceClause = this.getIndirection().getIndices().getElement(0).getAttributeName().getExceptReplaceClause(); 2400 } 2401 } 2402 } 2403 } 2404 } 2405 return exceptReplaceClause; 2406 } 2407 2408 public void setExceptReplaceClause(TExceptReplaceClause exceptReplaceClause) { 2409 this.exceptReplaceClause = exceptReplaceClause; 2410 } 2411 2412 private TObjectNameList fieldList; 2413 2414 public void setFieldList(TObjectNameList fieldList) { 2415 this.fieldList = fieldList; 2416 } 2417 2418 public TObjectNameList getFieldList() { 2419 2420 return fieldList; 2421 } 2422 2423 private TInExpr inExpr = null; 2424 2425 public void setInExpr(TInExpr inExpr) { 2426 this.inExpr = inExpr; 2427 } 2428 2429 /** 2430 * @deprecated As of v1.4.3.3, replaced by {@link #getRightOperand()} 2431 */ 2432 public TInExpr getInExpr() { 2433 return inExpr; 2434 } 2435 2436 2437 public void setExprList(TExpressionList exprList) { 2438 this.exprList = exprList; 2439 } 2440 2441 public void setOracleOuterJoin(boolean oracleOuterJoin) { 2442 isOracleOuterJoin = oracleOuterJoin; 2443 } 2444 2445 public boolean isOracleOuterJoin() { 2446 return isOracleOuterJoin; 2447 } 2448 2449 /** 2450 * Proprietary jion syntax of oracle: column(+) 2451 */ 2452 private boolean isOracleOuterJoin = false; 2453 2454 private TExpression parentExpr; 2455 2456 public TExpression getParentExpr() { 2457 return parentExpr; 2458 } 2459 2460 public void setParentExpr(TExpression parentExpr) { 2461 this.parentExpr = parentExpr; 2462 } 2463 2464 public boolean isLeftOperandOfParent(){ 2465 if (this.getParentExpr() == null) return false; 2466 return (this == this.getParentExpr().getLeftOperand()); 2467 } 2468 2469 public boolean isRightOperandOfParent(){ 2470 if (this.getParentExpr() == null) return false; 2471 return (this == this.getParentExpr().getRightOperand()); 2472 } 2473 2474 public void setLeftOperand(TExpression leftOperand) { 2475 this.leftOperand = leftOperand; 2476 if (leftOperand != null){ 2477 leftOperand.setParentExpr(this); 2478 } 2479 2480// if (leftOperand == null){ 2481// TParseTreeNode.removeTokensBetweenNodes(this.leftOperand,this.rightOperand); 2482// } 2483// 2484// this.setNewSubNode(this.leftOperand,leftOperand,null); 2485// this.leftOperand = leftOperand; 2486// if (this.getNodeStatus() == ENodeStatus.nsRemoved){ 2487// // remove this expr cascade due to the left operand was removed 2488// if (this.getParentExpr() != null){ 2489// if (this == this.getParentExpr().getLeftOperand()){ 2490// if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 2491// this.getParentExpr().refreshAllNodesTokenCount(); 2492// this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain()); 2493// this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken()); 2494// } 2495// }else{ 2496// if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 2497// this.getParentExpr().refreshAllNodesTokenCount(); 2498// this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken()); 2499// this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken()); 2500// } 2501// } 2502// } 2503// this.setStartTokenDirectly(null); 2504// this.setEndTokenDirectly(null); 2505// } 2506// 2507 } 2508 2509 public void setRightOperand(TExpression rightOperand) { 2510 2511 this.rightOperand = rightOperand; 2512 if (rightOperand != null){ 2513 rightOperand.setParentExpr(this); 2514 } 2515 2516// if (rightOperand == null){ 2517// TParseTreeNode.removeTokensBetweenNodes(this.leftOperand,this.rightOperand); 2518// } 2519// 2520// this.setNewSubNode(this.rightOperand,rightOperand,null); 2521// this.rightOperand = rightOperand; 2522// 2523// if (this.getNodeStatus() == ENodeStatus.nsRemoved){ 2524// // remove this expr cascade due to the left operand was removed 2525// if (this.getParentExpr() != null){ 2526// if (this == this.getParentExpr().getLeftOperand()){ 2527// if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 2528// this.getParentExpr().refreshAllNodesTokenCount(); 2529// this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain()); 2530// this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken()); 2531// } 2532// }else{ 2533// if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 2534// this.getParentExpr().refreshAllNodesTokenCount(); 2535// this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken()); 2536// this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken()); 2537// } 2538// } 2539// } 2540// this.setStartTokenDirectly(null); 2541// this.setEndTokenDirectly(null); 2542// } 2543// 2544// if (rightOperand != null){ 2545// rightOperand.setParentExpr(this); 2546// } 2547 } 2548 2549 private TExpression leftOperand; 2550 private TExpression rightOperand; 2551 2552 private TArrayAccess arrayAccess = null; 2553 2554 2555 /* 2556 * 2557 * @return if leftOperand is not null, then return leftOperand, 2558 * otherwise, check other possible parse tree node that might be in left side of this expression. 2559 * <p>This function was called in preOrderTraverse, inOrderTraverse and postOrderTraverse 2560 * <p>This function is only valid when {@link gudusoft.gsqlparser.nodes.TExpression#isLeaf()} is not true. 2561 * 2562 * <p>take this expression for example: 2563 * <p>f in (1,2,3) 2564 * <p> rightOperand is null, but getRightNode() should return (1,2,3) which is {@link TExpression#exprList} 2565 * 2566 public TParseTreeNode getLeftNode() { 2567 TParseTreeNode ret = this.leftOperand; 2568 if ( ret == null) { 2569 ret = this.leftNode; 2570 } 2571 return ret; 2572 } 2573 */ 2574 2575 /* 2576 * 2577 * @return if rightOperand is not null, then return rightOperand, 2578 * otherwise, check other possible parse tree node that might be in right side of this expression. 2579 * <p>This function was called in preOrderTraverse, inOrderTraverse and postOrderTraverse 2580 * <p>This function is only valid when {@link gudusoft.gsqlparser.nodes.TExpression#isLeaf()} is not true. 2581 2582 * <p>take this expression for example: 2583 * <p>f in (1,2,3) 2584 * <p> rightOperand is null, but getRightNode() should return (1,2,3) which is {@link TExpression#exprList} 2585 public TParseTreeNode getRightNode(){ 2586 TParseTreeNode ret = this.rightOperand; 2587 if ( ret == null) { 2588 ret = this.rightNode; 2589 } 2590 return ret; 2591 } 2592 */ 2593 2594 /** 2595 * 2596 * @return right operand of this expression which should be type of TExpression 2597 */ 2598 public TExpression getRightOperand() { 2599 return rightOperand; 2600 } 2601 2602 /** 2603 * 2604 * @return left operand of this expression which should be type of TExpression 2605 */ 2606 public TExpression getLeftOperand() { 2607 2608 return leftOperand; 2609 } 2610 2611 public TExpression getLikeEscapeOperand() { 2612 return likeEscapeOperand; 2613 } 2614 2615 public TExpression getBetweenOperand() { 2616 return betweenOperand; 2617 } 2618 2619 public TArrayAccess getArrayAccess() { 2620 return arrayAccess; 2621 } 2622 2623 private EExpressionType expressionType = EExpressionType.not_initialized_yet_t; 2624 2625 /** 2626 * change return type from int to EExpressionType since 1.4.3.0 2627 * @return a value of {@link EExpressionType} 2628 */ 2629 public EExpressionType getExpressionType() { 2630 return expressionType; 2631 } 2632 2633 /** 2634 * 2635 * @param exprType type to distinguish expression, change type from int to 2636 * EExpressionType since 1.4.3.0 2637 */ 2638 public void setExpressionType(EExpressionType exprType) { 2639 this.expressionType = exprType; 2640 } 2641 2642 //private int expressionType = unknown; 2643 2644 public void setObjectOperand(TObjectName objectOperand) { 2645 this.objectOperand = objectOperand; 2646 } 2647 2648 public TObjectName getObjectOperand() { 2649 return objectOperand; 2650 } 2651 2652 private TObjectName objectOperand; 2653 2654 public void setConstantOperand(TConstant constantOperand) { 2655 this.constantOperand = constantOperand; 2656 } 2657 2658 private TConstant constantOperand; 2659 2660 public TSourceToken getSourcetokenOperand() { 2661 return sourcetokenOperand; 2662 } 2663 2664 public void setSourcetokenOperand(TSourceToken sourcetokenOperand) { 2665 this.sourcetokenOperand = sourcetokenOperand; 2666 } 2667 2668 private TSourceToken sourcetokenOperand; 2669 2670 public void setCaseExpression(TCaseExpression caseExpression) { 2671 this.caseExpression = caseExpression; 2672 } 2673 2674 public TCaseExpression getCaseExpression() { 2675 return caseExpression; 2676 } 2677 2678 private TCaseExpression caseExpression; 2679 2680 /** 2681 * @deprecated As of v1.4.3.3 2682 */ 2683 public void setArrayAccess(TArrayAccess arrayAccess) { 2684 this.arrayAccess = arrayAccess; 2685 } 2686 2687 private TExecuteSqlNode executeSqlNode; 2688 2689 public TExecuteSqlNode getExecuteSqlNode() { 2690 return executeSqlNode; 2691 } 2692 2693 public void setSubQueryNode(TSelectSqlNode subQueryNode) { 2694 this.subQueryNode = subQueryNode; 2695 } 2696 2697 private TSelectSqlNode subQueryNode = null; 2698 2699 public void setSubQuery(TSelectSqlStatement subQuery) { 2700 this.subQuery = subQuery; 2701 } 2702 2703 public TSelectSqlStatement getSubQuery() { 2704 return subQuery; 2705 } 2706 2707 private TSelectSqlStatement subQuery = null; 2708 2709 public void setSubQueryInStmt(boolean subQueryInStmt) { 2710 isSubQueryInStmt = subQueryInStmt; 2711 } 2712 2713 private boolean isSubQueryInStmt = false; // plsql, subQuery already was set to TSelectSqlStatement, but not parsed 2714 2715 private TFunctionCall functionCall; 2716 2717 public TFunctionCall getFunctionCall() { 2718 return functionCall; 2719 } 2720 2721 public void setFunctionCall(TFunctionCall functionCall) { 2722 this.functionCall = functionCall; 2723 } 2724 2725 private TDatetimeExpression datetimeExpression; 2726 2727 public void setDatetimeExpression(TDatetimeExpression datetimeExpression) { 2728 this.datetimeExpression = datetimeExpression; 2729 } 2730 2731 private TIntervalExpression intervalExpression; 2732 2733 public void setIntervalExpression(TIntervalExpression intervalExpression) { 2734 this.intervalExpression = intervalExpression; 2735 } 2736 2737 private TExpression betweenOperand; 2738 2739 public void setBetweenOperand(TExpression betweenOperand) { 2740 this.betweenOperand = betweenOperand; 2741 } 2742 2743 private TExpression likeEscapeOperand; 2744 2745 public void setLikeEscapeOperand(TExpression likeEscapeOperand) { 2746 this.likeEscapeOperand = likeEscapeOperand; 2747 } 2748 2749 2750 public void doParse(TCustomSqlStatement psql, ESqlClause plocation){ 2751 2752 setLocation(plocation); 2753 2754 switch(expressionType){ 2755 case simple_constant_t: 2756 if (this.constantOperand.getStartToken() != null){ 2757 this.constantOperand.getStartToken().location = plocation; 2758 } 2759 break; 2760 case simple_object_name_t: 2761 // target_el_expr -> basic3_expr -> simple_expression 2762 psql.linkColumnReferenceToTable(objectOperand,plocation); 2763 psql.linkColumnToTable(objectOperand,plocation); 2764 2765// if (plocation == ESqlClause.selectInto){ 2766// if (this.objectOperand.toString().startsWith("#")){ 2767// TTable table = new TTable(); 2768// this.objectOperand.setObjectType(TObjectName.ttobjTable); 2769// table.setTableName(this.objectOperand); 2770// table.setTableType(ETableSource.objectname); 2771// table.setEffectType(ETableEffectType.tetSelectInto); 2772// psql.addToTables(table); 2773// }else{ 2774// this.objectOperand.setObjectType(TObjectName.ttobjVariable); 2775// } 2776// }else{ 2777// psql.linkColumnReferenceToTable(objectOperand,plocation); 2778// psql.linkColumnToTable(objectOperand,plocation); 2779// } 2780 break; 2781 case group_t: 2782 inExpr.doParse(psql,plocation); 2783 break; 2784 case list_t: 2785 case collection_constructor_list_t: 2786 case collection_constructor_multiset_t: 2787 case collection_constructor_set_t: 2788 case new_structured_type_t: 2789 if (exprList != null){ 2790 exprList.doParse(psql,plocation); 2791 } 2792 break; 2793 case function_t: 2794 if (functionCall.getArgs() != null){ 2795 for(int i=0;i<functionCall.getArgs().size();i++){ 2796 functionCall.getArgs().getExpression(i).setParentExpr(this); 2797 } 2798 } 2799 functionCall.doParse(psql,plocation); 2800 break; 2801 2802 case type_constructor_t: 2803 if (getExprList() != null){ 2804 getExprList().doParse(psql,plocation); 2805 } 2806 2807 break; 2808 case cursor_t: 2809 case subquery_t: 2810 case multiset_t: 2811 if (subQuery == null){ 2812 subQuery = new TSelectSqlStatement(psql.dbvendor); 2813 subQuery.rootNode = subQueryNode; 2814 } 2815 subQuery.setLocation(plocation); 2816 2817 if (!isSubQueryInStmt){ 2818 subQuery.doParseStatement(psql); 2819 }else{ 2820 // subQuery in plsql 2821 subQuery.parsestatement(psql,false); 2822 } 2823 break; 2824 case case_t: 2825 caseExpression.doParse(psql,plocation); 2826 break; 2827 case pattern_matching_t: 2828 leftOperand.doParse(psql,plocation); 2829 rightOperand.doParse(psql,plocation); 2830 if (likeEscapeOperand != null){ 2831 likeEscapeOperand.doParse(psql,plocation); 2832 } 2833 break; 2834 case exists_t: 2835 if (subQueryNode != null){ 2836 if (subQuery == null){ 2837 subQuery = new TSelectSqlStatement(psql.dbvendor); 2838 subQuery.rootNode = subQueryNode; 2839 } 2840 if (!isSubQueryInStmt){ 2841 subQuery.doParseStatement(psql); 2842 }else{ 2843 // subQuery in plsql 2844 subQuery.parsestatement(psql,false); 2845 } 2846 }else if (this.leftOperand != null){ 2847 // databricks, exists(expr, func) 2848 } 2849 break; 2850 case new_variant_type_t: 2851 this.newVariantTypeArgumentList.doParse(psql,plocation); 2852 break; 2853 case unary_plus_t: 2854 case unary_minus_t: 2855 case unary_prior_t: 2856 rightOperand.doParse(psql,plocation); 2857 break; 2858 case arithmetic_plus_t: 2859 case arithmetic_minus_t: 2860 case arithmetic_times_t: 2861 case arithmetic_divide_t: 2862 case power_t: 2863 case range_t: 2864 case concatenate_t: 2865 case period_ldiff_t: 2866 case period_rdiff_t: 2867 case period_p_intersect_t: 2868 case period_p_normalize_t: 2869 case contains_t: 2870 leftOperand.doParse(psql,plocation); 2871 rightOperand.doParse(psql,plocation); 2872 break; 2873 case assignment_t: 2874 leftOperand.doParse(psql,plocation); 2875 rightOperand.doParse(psql,plocation); 2876 break; 2877 case sqlserver_proprietary_column_alias_t: 2878 rightOperand.doParse(psql,plocation); 2879 break; 2880 case arithmetic_modulo_t: 2881 case bitwise_exclusive_or_t: 2882 case bitwise_or_t: 2883 case bitwise_and_t: 2884 case bitwise_xor_t: 2885 case exponentiate_t: 2886 case scope_resolution_t: 2887 case at_time_zone_t: 2888 case member_of_t: 2889 case arithmetic_exponentiation_t: 2890 leftOperand.doParse(psql,plocation); 2891 rightOperand.doParse(psql,plocation); 2892 break; 2893 case at_local_t: 2894 case day_to_second_t: 2895 case year_to_month_t: 2896 leftOperand.doParse(psql,plocation); 2897 break; 2898 case teradata_at_t: 2899 leftOperand.doParse(psql,plocation); 2900 rightOperand.doParse(psql,plocation); 2901 break; 2902 case parenthesis_t: 2903 leftOperand.doParse(psql,plocation); 2904 break; 2905 case simple_comparison_t: 2906 leftOperand.doParse(psql,plocation); 2907 rightOperand.doParse(psql,plocation); 2908 break; 2909 case group_comparison_t: 2910 leftOperand.doParse(psql,plocation); 2911 rightOperand.doParse(psql,plocation); 2912 break; 2913 case in_t: 2914 leftOperand.doParse(psql,plocation); 2915 rightOperand.doParse(psql,plocation); 2916 break; 2917 case floating_point_t: 2918 leftOperand.doParse(psql,plocation); 2919 break; 2920 case logical_xor_t: 2921 case is_t: 2922 leftOperand.doParse(psql,plocation); 2923 rightOperand.doParse(psql,plocation); 2924 break; 2925 case logical_not_t: 2926 rightOperand.doParse(psql,plocation); 2927 break; 2928 case null_t: 2929 case is_not_null_t: 2930 case is_true_t: 2931 case is_false_t: 2932 case is_not_true_t: 2933 case is_not_false_t: 2934 leftOperand.doParse(psql,plocation); 2935 break; 2936 case between_t: 2937 betweenOperand.doParse(psql,plocation); 2938 leftOperand.doParse(psql,plocation); 2939 rightOperand.doParse(psql,plocation); 2940 break; 2941 case is_of_type_t: 2942 leftOperand.doParse(psql,plocation); 2943 break; 2944 case collate_t: //sql server,postgresql 2945 leftOperand.doParse(psql,plocation); 2946 rightOperand.doParse(psql,plocation); 2947 break; 2948 case left_join_t: 2949 case right_join_t: 2950 leftOperand.doParse(psql,plocation); 2951 rightOperand.doParse(psql,plocation); 2952 break; 2953 case ref_arrow_t: 2954 if (leftOperand.getExpressionType() == EExpressionType.simple_object_name_t){ 2955 leftOperand.getObjectOperand().setDbObjectType(EDbObjectType.variable); 2956 } 2957 leftOperand.doParse(psql,plocation); 2958 rightOperand.doParse(psql,plocation); 2959 break; 2960 case typecast_t: 2961 leftOperand.doParse(psql,plocation); 2962 break; 2963 case arrayaccess_t: 2964 arrayAccess.doParse(psql,plocation); 2965 break; 2966 case unary_connect_by_root_t: 2967 rightOperand.doParse(psql,plocation); 2968 break; 2969 case interval_t: 2970 intervalExpr.doParse(psql,plocation); 2971 break; 2972 case unary_binary_operator_t: 2973 rightOperand.doParse(psql,plocation); 2974 break; 2975 case left_shift_t: 2976 case right_shift_t: 2977 leftOperand.doParse(psql,plocation); 2978 rightOperand.doParse(psql,plocation); 2979 break; 2980 case array_constructor_t: 2981 if ((this.subQueryNode != null)&&(subQuery == null)){ 2982 subQuery = new TSelectSqlStatement(psql.dbvendor); 2983 subQuery.rootNode = subQueryNode; 2984 subQuery.doParseStatement(psql); 2985 }else if (exprList != null){ 2986 exprList.doParse(psql,plocation); 2987 }else if (arrayConstruct !=null){ 2988 arrayConstruct.doParse(psql,plocation); 2989 } 2990 break; 2991 case objectConstruct_t: 2992 objectConstruct.doParse(psql,plocation); 2993 break; 2994 case row_constructor_t: 2995 if (exprList != null){ 2996 exprList.doParse(psql,plocation); 2997 } 2998 break; 2999 case namedParameter_t: 3000 namedParameter.doParse(psql,plocation); 3001 break; 3002 case positionalParameter_t: 3003 positionalParameter.doParse(psql,plocation); 3004 break; 3005 case collectionArray_t: 3006 collectionArray.doParse(psql,plocation); 3007 break; 3008 case collectionCondition_t: 3009 collectionCondition.doParse(psql,plocation); 3010 break; 3011 case unary_squareroot_t: 3012 case unary_cuberoot_t: 3013 case unary_factorialprefix_t: 3014 case unary_absolutevalue_t: 3015 case unary_bitwise_not_t: 3016 getRightOperand().doParse(psql,plocation); 3017 break; 3018 case unary_factorial_t: 3019 getLeftOperand().doParse(psql,plocation); 3020 break; 3021 case bitwise_shift_left_t: 3022 case bitwise_shift_right_t: 3023 getLeftOperand().doParse(psql,plocation); 3024 getRightOperand().doParse(psql,plocation); 3025 break; 3026 case multiset_union_t: 3027 case multiset_union_distinct_t: 3028 case multiset_intersect_t: 3029 case multiset_intersect_distinct_t: 3030 case multiset_except_t: 3031 case multiset_except_distinct_t: 3032 getLeftOperand().doParse(psql,plocation); 3033 getRightOperand().doParse(psql,plocation); 3034 break; 3035 case json_get_text: 3036 case json_get_text_at_path: 3037 case json_get_object: 3038 case json_get_object_at_path: 3039 case json_left_contain: 3040 case json_right_contain: 3041 case json_exist: 3042 case json_any_exist: 3043 case json_all_exist: 3044 getLeftOperand().doParse(psql,plocation); 3045 getRightOperand().doParse(psql,plocation); 3046 break; 3047 case interpolate_previous_value_t: 3048 getLeftOperand().doParse(psql,plocation); 3049 getRightOperand().doParse(psql,plocation); 3050 break; 3051 case logical_and_t: 3052 case logical_or_t: 3053 if (getFlattedAndOrExprs().size() > TExpression.BigAndOrNestLevel){ 3054 for(int k=0;k<getFlattedAndOrExprs().size();k++){ 3055 TExpression lcExpr = (TExpression)getFlattedAndOrExprs().get(k); 3056 lcExpr.doParse(psql,plocation); 3057 } 3058 }else { 3059 leftOperand.doParse(psql,plocation); 3060 rightOperand.doParse(psql,plocation); 3061 } 3062 break; 3063 case submultiset_t: 3064 leftOperand.doParse(psql,plocation); 3065 rightOperand.doParse(psql,plocation); 3066 break; 3067 case overlaps_t: 3068 leftOperand.doParse(psql,plocation); 3069 rightOperand.doParse(psql,plocation); 3070 break; 3071 case is_a_set_t: 3072 leftOperand.doParse(psql,plocation); 3073 break; 3074 case unnest_t: 3075 leftOperand.doParse(psql,plocation); 3076 break; 3077 case array_t: 3078 if (objectOperand != null){ 3079 psql.linkColumnToTable(objectOperand,plocation); 3080 } 3081 3082 if (getExprList() != null){ 3083 getExprList().doParse(psql,plocation); 3084 } 3085 break; 3086 case fieldselection_t: 3087 if (getLeftOperand() != null){ 3088 getLeftOperand().doParse(psql,plocation); 3089 }else if (getFunctionCall() != null){ 3090 getFunctionCall().doParse(psql,plocation); 3091 } 3092 break; 3093 case lambda_t: 3094 //getLeftOperand().doParse(psql,plocation); 3095 //getRightOperand().doParse(psql,plocation); 3096 break; 3097 case array_access_expr_t: 3098 getLeftOperand().doParse(psql,plocation); 3099 getRightOperand().doParse(psql,plocation); 3100 break; 3101 default:; 3102 } 3103 } 3104 3105 private EComparisonType comparisonType = EComparisonType.unknown; 3106 private TSourceToken comparisonOperator = null; 3107 private TSourceToken quantifier = null; 3108 3109 public void setQuantifierType(EQuantifierType quantifierType) { 3110 this.quantifierType = quantifierType; 3111 } 3112 3113 public EQuantifierType getQuantifierType() { 3114 3115 return quantifierType; 3116 } 3117 3118 private EQuantifierType quantifierType = EQuantifierType.none; 3119 3120 public EComparisonType getComparisonType() { 3121 return comparisonType; 3122 } 3123 3124 /** 3125 * one of the following quantifier keywords: SOME, ANY, ALL 3126 * @return SOME, ANY, ALL in group comparison condition. 3127 */ 3128 public TSourceToken getQuantifier() { 3129 return quantifier; 3130 } 3131 3132 /** 3133 * 3134 * @return operator used in comparison condition. 3135 */ 3136 public TSourceToken getComparisonOperator() { 3137 3138 return comparisonOperator; 3139 } 3140 3141 public void setComparisonOperator(TDummy comparisonOperator) { 3142 if (comparisonOperator == null) return; 3143 for(TSourceToken st : comparisonOperator.tokens){ 3144 this.getOperatorTokens().add(st); 3145 } 3146 } 3147 3148 public void setComparisonOperator(TSourceToken comparisonOperator) { 3149 if (comparisonOperator == null) return; 3150 this.comparisonOperator = comparisonOperator; 3151 this.operatorToken = comparisonOperator; 3152 comparisonType = getComparisonType(comparisonOperator); 3153 if ((comparisonOperator.toString().equalsIgnoreCase("=")) 3154 && (expressionType == EExpressionType.simple_comparison_t)){ 3155 if (leftOperand.toString().startsWith("@")){ 3156 expressionType = EExpressionType.assignment_t; 3157 } 3158 } 3159 } 3160 3161 public void setQuantifier(TSourceToken quantifier) { 3162 if (quantifier == null) return; 3163 this.quantifier = quantifier; 3164 switch (this.quantifier.tokencode){ 3165 case TBaseType.rrw_all: 3166 quantifierType = EQuantifierType.all; 3167 break; 3168 default: 3169 if (this.quantifier.toString().equalsIgnoreCase("any")){ 3170 quantifierType = EQuantifierType.any; 3171 }else if (this.quantifier.toString().equalsIgnoreCase("some")){ 3172 quantifierType = EQuantifierType.some; 3173 } 3174 break; 3175 } 3176 } 3177 3178 public void accept(TParseTreeVisitor v){ 3179 v.preVisit(this); 3180 v.postVisit(this); 3181 } 3182 3183 public void acceptChildren(TParseTreeVisitor v){ 3184 v.preVisit(this); 3185 switch(expressionType){ 3186 case simple_object_name_t: 3187 objectOperand.acceptChildren(v); 3188 break; 3189 case simple_constant_t: 3190 constantOperand.acceptChildren(v); 3191 break; 3192 case list_t: 3193 case collection_constructor_list_t: 3194 case collection_constructor_multiset_t: 3195 case collection_constructor_set_t: 3196 case new_structured_type_t: 3197 if (exprList != null){ 3198 for(int i=0;i<exprList.size();i++){ 3199 exprList.getExpression(i).acceptChildren(v); 3200 } 3201 } 3202 break; 3203 case function_t: 3204 functionCall.acceptChildren(v); 3205 break; 3206 case type_constructor_t: 3207 if (getExprList() != null){ 3208 getExprList().acceptChildren(v); 3209 } 3210 break; 3211 case cursor_t: 3212 case subquery_t: 3213 case multiset_t: 3214 subQuery.acceptChildren(v); 3215 break; 3216 case case_t: 3217 caseExpression.acceptChildren(v); 3218 break; 3219 case pattern_matching_t: 3220 leftOperand.acceptChildren(v); 3221 rightOperand.acceptChildren(v); 3222 if (likeEscapeOperand != null){ 3223 likeEscapeOperand.acceptChildren(v); 3224 } 3225 break; 3226 case exists_t: 3227 if (subQuery!=null){ 3228 subQuery.acceptChildren(v); 3229 }else{ 3230 // databricks, exists(expr, func) 3231 } 3232 3233 break; 3234 case new_variant_type_t: 3235 newVariantTypeArgumentList.acceptChildren(v); 3236 break; 3237 case unary_plus_t: 3238 case unary_minus_t: 3239 case unary_prior_t: 3240 rightOperand.acceptChildren(v); 3241 break; 3242 case arithmetic_plus_t: 3243 case arithmetic_minus_t: 3244 case arithmetic_times_t: 3245 case arithmetic_divide_t: 3246 case power_t: 3247 case range_t: 3248 case concatenate_t: 3249 case period_ldiff_t: 3250 case period_rdiff_t: 3251 case period_p_intersect_t: 3252 case period_p_normalize_t: 3253 case contains_t: 3254 leftOperand.acceptChildren(v); 3255 rightOperand.acceptChildren(v); 3256 break; 3257 case assignment_t: 3258 leftOperand.acceptChildren(v); 3259 rightOperand.acceptChildren(v); 3260 break; 3261 case sqlserver_proprietary_column_alias_t: 3262 rightOperand.acceptChildren(v); 3263 break; 3264 case arithmetic_modulo_t: 3265 case bitwise_exclusive_or_t: 3266 case bitwise_or_t: 3267 case bitwise_and_t: 3268 case bitwise_xor_t: 3269 case exponentiate_t: 3270 case scope_resolution_t: 3271 case at_time_zone_t: 3272 case member_of_t: 3273 case arithmetic_exponentiation_t: 3274 leftOperand.acceptChildren(v); 3275 rightOperand.acceptChildren(v); 3276 break; 3277 case at_local_t: 3278 case day_to_second_t: 3279 case year_to_month_t: 3280 leftOperand.acceptChildren(v); 3281 break; 3282 case teradata_at_t: 3283 leftOperand.acceptChildren(v); 3284 rightOperand.acceptChildren(v); 3285 break; 3286 case parenthesis_t: 3287 leftOperand.acceptChildren(v); 3288 break; 3289 case simple_comparison_t: 3290 leftOperand.acceptChildren(v); 3291 rightOperand.acceptChildren(v); 3292 break; 3293 case group_comparison_t: 3294 leftOperand.acceptChildren(v); 3295 rightOperand.acceptChildren(v); 3296 break; 3297 case in_t: 3298 leftOperand.acceptChildren(v); 3299 rightOperand.acceptChildren(v); 3300 break; 3301 case floating_point_t: 3302 leftOperand.acceptChildren(v); 3303 break; 3304 case logical_and_t: 3305 case logical_or_t: 3306 case logical_xor_t: 3307 case is_t: 3308 leftOperand.acceptChildren(v); 3309 rightOperand.acceptChildren(v); 3310 break; 3311 case logical_not_t: 3312 rightOperand.acceptChildren(v); 3313 break; 3314 case null_t: 3315 case is_not_null_t: 3316 case is_true_t: 3317 case is_false_t: 3318 case is_not_true_t: 3319 case is_not_false_t: 3320 leftOperand.acceptChildren(v); 3321 break; 3322 case between_t: 3323 if (betweenOperand != null){ 3324 betweenOperand.acceptChildren(v); 3325 } 3326 leftOperand.acceptChildren(v); 3327 rightOperand.acceptChildren(v); 3328 break; 3329 case is_of_type_t: 3330 leftOperand.acceptChildren(v); 3331 break; 3332 case collate_t: //sql server,postgresql 3333 leftOperand.acceptChildren(v); 3334 rightOperand.acceptChildren(v); 3335 break; 3336 case left_join_t: 3337 case right_join_t: 3338 leftOperand.acceptChildren(v); 3339 rightOperand.acceptChildren(v); 3340 break; 3341 case ref_arrow_t: 3342 leftOperand.acceptChildren(v); 3343 rightOperand.acceptChildren(v); 3344 break; 3345 case typecast_t: 3346 leftOperand.acceptChildren(v); 3347 break; 3348 case arrayaccess_t: 3349 arrayAccess.acceptChildren(v); 3350 break; 3351 case unary_connect_by_root_t: 3352 rightOperand.acceptChildren(v); 3353 break; 3354 case interval_t: 3355 intervalExpr.acceptChildren(v); 3356 break; 3357 case unary_binary_operator_t: 3358 rightOperand.acceptChildren(v); 3359 break; 3360 case left_shift_t: 3361 case right_shift_t: 3362 leftOperand.acceptChildren(v); 3363 rightOperand.acceptChildren(v); 3364 break; 3365 case array_constructor_t: 3366 if (subQuery != null){ 3367 subQuery.acceptChildren(v); 3368 }else if (exprList != null){ 3369 exprList.acceptChildren(v); 3370 }else if (arrayConstruct != null){ 3371 arrayConstruct.acceptChildren(v); 3372 } 3373 break; 3374 case row_constructor_t: 3375 if (exprList != null){ 3376 exprList.acceptChildren(v); 3377 } 3378 break; 3379 case unary_squareroot_t: 3380 case unary_cuberoot_t: 3381 case unary_factorialprefix_t: 3382 case unary_absolutevalue_t: 3383 case unary_bitwise_not_t: 3384 getRightOperand().acceptChildren(v); 3385 break; 3386 case unary_factorial_t: 3387 getLeftOperand().acceptChildren(v); 3388 break; 3389 case bitwise_shift_left_t: 3390 case bitwise_shift_right_t: 3391 getLeftOperand().acceptChildren(v); 3392 getRightOperand().acceptChildren(v); 3393 break; 3394 case multiset_union_t: 3395 case multiset_union_distinct_t: 3396 case multiset_intersect_t: 3397 case multiset_intersect_distinct_t: 3398 case multiset_except_t: 3399 case multiset_except_distinct_t: 3400 getLeftOperand().acceptChildren(v); 3401 getRightOperand().acceptChildren(v); 3402 break; 3403 case json_get_text: 3404 case json_get_text_at_path: 3405 case json_get_object: 3406 case json_get_object_at_path: 3407 case json_left_contain: 3408 case json_right_contain: 3409 case json_exist: 3410 case json_any_exist: 3411 case json_all_exist: 3412 getLeftOperand().acceptChildren(v); 3413 getRightOperand().acceptChildren(v); 3414 break; 3415 case interpolate_previous_value_t: 3416 getLeftOperand().acceptChildren(v); 3417 getRightOperand().acceptChildren(v); 3418 break; 3419 case submultiset_t: 3420 leftOperand.acceptChildren(v); 3421 rightOperand.acceptChildren(v); 3422 break; 3423 case overlaps_t: 3424 leftOperand.acceptChildren(v); 3425 rightOperand.acceptChildren(v); 3426 break; 3427 case is_a_set_t: 3428 leftOperand.acceptChildren(v); 3429 break; 3430 case array_t: 3431 if (getExprList() != null){ 3432 getExprList().acceptChildren(v); 3433 } 3434 break; 3435 case lambda_t: 3436 getLeftOperand().acceptChildren(v); 3437 getRightOperand().acceptChildren(v); 3438 break; 3439 default:; 3440 } 3441 3442 v.postVisit(this); 3443 } 3444 3445 /** 3446 * expression type such as column reference is a leaf expression while subtract expression 3447 * is not a leaf expression. Usually, non-leaf expression should including both {@link #getLeftOperand()} 3448 * and {@link #getRightOperand()}. 3449 * @return leaf expression or not. 3450 */ 3451 public boolean isLeaf(){ 3452 return isLeafExpr(this); 3453 } 3454 3455 3456 public boolean isLeafExpr(TParseTreeNode pnode){ 3457 boolean ret = true; 3458 if (pnode == null) return ret; 3459 if (!(pnode instanceof TExpression)) return ret; 3460 TExpression e = (TExpression)pnode; 3461 3462 if ((onlyAndOrIsNonLeaf) &&(!((e.getExpressionType()==EExpressionType.logical_and_t)||(e.getExpressionType()==EExpressionType.logical_or_t)))) return ret; 3463 3464 switch (e.getExpressionType()){ 3465 case case_t: 3466 case simple_object_name_t: 3467 case simple_constant_t: 3468 case simple_source_token_t: 3469 case group_t: 3470 case list_t: 3471 case collection_constructor_list_t: 3472 case collection_constructor_multiset_t: 3473 case collection_constructor_set_t: 3474 case cursor_t: 3475 case function_t: 3476 case type_constructor_t: 3477 case subquery_t: 3478 case multiset_t: 3479 case object_access_t: 3480 case place_holder_t: 3481 case is_of_type_t: 3482 case exists_t: 3483 case arrayaccess_t: 3484 case interval_t: 3485 case new_structured_type_t: 3486 case new_variant_type_t: 3487 case member_of_t: 3488 case submultiset_t: 3489 case execute_stmt_t: 3490 case cursor_attribute_t: 3491 return ret; 3492 default: 3493 } 3494 //if(e.getExpressionType() == TExpression.datetimeExprOperator) return ret; 3495 //if(e.getExpressionType() == TExpression.intervalExprOperator) return ret; 3496 //if(e.getExpressionType() == TExpression.modelExprOperator) return ret; 3497 //if(e.getExpressionType() == TExpression.typeconstructorExprOperator) return ret; 3498 //if(e.getExpressionType() == TExpression.patternMatchingExprOperator) return ret; 3499 3500 if (e.getLeftOperand() != null){ 3501 ret = !(e.getLeftOperand() instanceof TExpression); 3502 } 3503 if (e.getRightOperand() != null){ 3504 ret = !(e.getRightOperand() instanceof TExpression); 3505 } 3506 3507 return ret; 3508 } 3509 3510 private Stack exprStack = null; 3511 3512 private Stack getExprStack() { 3513 if (exprStack == null){ 3514 exprStack = new Stack(); 3515 } 3516 return exprStack; 3517 } 3518 3519 // used in PreOrderTraverse only, InOrderTraverse and PostOrderTraverse has already visit subtree. 3520 private boolean visitSubTree = true; 3521 3522 3523 public void setVisitSubTree(boolean visitSubTree) { 3524 this.visitSubTree = visitSubTree; 3525 } 3526 3527 public boolean isVisitSubTree() { 3528 3529 return visitSubTree; 3530 } 3531 3532 private boolean checkIsVisitSubTree(TParseTreeNode node){ 3533 boolean ret = !this.isLeafExpr(node); 3534 if (ret){ 3535 ret = ((TExpression)node).isVisitSubTree(); 3536 } 3537 return ret; 3538 } 3539 3540 3541 public void setWindowSpecification(TWindowDef windowSpecification){ 3542 if (this.getExpressionType() != EExpressionType.function_t) return; 3543 this.getFunctionCall().setWindowDef(windowSpecification); 3544 3545 } 3546 3547 /** 3548 * Traverse expression in pre Order. 3549 * @param ev user defined visitor 3550 */ 3551 public void preOrderTraverse(IExpressionVisitor ev){ 3552 3553 3554 if (this.isLeaf()){ 3555 ev.exprVisit(this,true); 3556 }else{ 3557 getExprStack().push(this); 3558 } 3559 3560 TParseTreeNode node = null; 3561 while(getExprStack().size() > 0){ 3562 node = (TParseTreeNode)getExprStack().peek(); 3563 3564 while(node != null){ 3565 if (!ev.exprVisit(node,this.isLeafExpr(node))) { 3566 return; 3567 } 3568 3569 if (this.isLeafExpr(node)) { 3570 this.getExprStack().push(null); 3571 }else if (!this.checkIsVisitSubTree(node)){ 3572 this.getExprStack().push(null); 3573 }else{ 3574 this.getExprStack().push(((TExpression)node).getLeftOperand()); 3575 } 3576 node = (TParseTreeNode)this.getExprStack().peek(); 3577 } 3578 3579 // pop up the dummyOperator expression node 3580 this.getExprStack().pop(); 3581 3582 if (this.getExprStack().size() > 0){ 3583 node = (TParseTreeNode)this.getExprStack().pop(); 3584 3585 if (this.isLeafExpr(node)) { 3586 this.getExprStack().push(null); 3587 }else if (!this.checkIsVisitSubTree(node)){ 3588 this.getExprStack().push(null); 3589 }else{ 3590 this.getExprStack().push(((TExpression)node).getRightOperand()); 3591 } 3592 3593 } 3594 3595 } //while 3596 3597 3598 } 3599 3600 /** 3601 * Traverse expression in In Order. 3602 * @param ev user defined visitor 3603 */ 3604 public void inOrderTraverse(IExpressionVisitor ev){ 3605 3606 if (this.isLeaf()){ 3607 ev.exprVisit(this,true); 3608 }else{ 3609 getExprStack().push(this); 3610 } 3611 3612 TParseTreeNode node = null; 3613 while(getExprStack().size() > 0){ 3614 node = (TParseTreeNode)getExprStack().peek(); 3615 3616 while(node != null){ 3617 3618 if (this.isLeafExpr(node)) { 3619 this.getExprStack().push(null); 3620 }else{ 3621 this.getExprStack().push(((TExpression)node).getLeftOperand()); 3622 } 3623 node = (TParseTreeNode)this.getExprStack().peek(); 3624 } 3625 3626 // pop up the dummyOperator expression node 3627 this.getExprStack().pop(); 3628 3629 if (this.getExprStack().size() > 0){ 3630 node = (TParseTreeNode)this.getExprStack().pop(); 3631 3632 if (!ev.exprVisit(node,this.isLeafExpr(node))) { 3633 return; 3634 } 3635 3636 if (this.isLeafExpr(node)) { 3637 this.getExprStack().push(null); 3638 }else{ 3639 this.getExprStack().push(((TExpression)node).getRightOperand()); 3640 } 3641 3642 } 3643 3644 } //while 3645 3646 } 3647 3648 /** 3649 * Traverse expression in post order. 3650 * @param ev user defined visitor 3651 */ 3652 public void postOrderTraverse(IExpressionVisitor ev){ 3653 3654 final int ctNone = 0; 3655 final int ctL = 1; 3656 final int ctR = 2; 3657 3658 if (this.isLeaf()){ 3659 ev.exprVisit(this,true); 3660 }else{ 3661 getExprStack().push(this); 3662 } 3663 3664 TParseTreeNode node = null; 3665 3666 while(getExprStack().size() > 0){ 3667 node = (TParseTreeNode)getExprStack().peek(); 3668 3669 while(node != null){ 3670 3671 if (this.isLeafExpr(node)) { 3672 this.getExprStack().push(null); 3673 }else{ 3674 this.getExprStack().push(((TExpression)node).getLeftOperand()); 3675 } 3676 node = (TParseTreeNode)this.getExprStack().peek(); 3677 if (node != null){ 3678 node.setDummyTag(ctL); 3679 } 3680 } 3681 3682 // pop up the dummyOperator expression node 3683 this.getExprStack().pop(); 3684 node = (TParseTreeNode)this.getExprStack().peek(); 3685 3686 while((this.getExprStack().size() > 0) &&(node.getDummyTag() == ctR)){ 3687 node = (TParseTreeNode)this.getExprStack().pop(); 3688 node.setDummyTag(ctNone); //restore tag so next this expression will be traversed correctly 3689 if (!ev.exprVisit(node,this.isLeafExpr(node))) { 3690 return; 3691 } 3692 3693 if (this.getExprStack().size() > 0){ 3694 node = (TParseTreeNode)this.getExprStack().peek(); 3695 }else{ 3696 break; 3697 } 3698 } 3699 3700 if (this.getExprStack().size() > 0){ 3701 node = (TParseTreeNode)this.getExprStack().peek(); 3702 node.setDummyTag(ctR); 3703 if (this.isLeafExpr(node)){ 3704 this.getExprStack().push(null); 3705 }else{ 3706 this.getExprStack().push(((TExpression)node).getRightOperand()); 3707 } 3708 } 3709 3710 }//while 3711 3712 } 3713 3714 /** 3715 * if original expr is f > 1, and call addANDCondition("f2 > 2") 3716 * expression will be: f > 1 and f2> 2 3717 * @param condition 3718 */ 3719 public void addANDCondition(String condition){ 3720 //appendString(" and "+condition); 3721 setString("("+this.toString()+") and "+condition); 3722 } 3723 3724 /** 3725 * if original expr is f > 1, and call addORCondition("f2 > 2") 3726 * expression will be: f > 1 or f2 >2 3727 * 3728 * @param condition 3729 */ 3730 public void addORCondition(String condition){ 3731 //appendString(" or "+condition); 3732 setString("("+this.toString()+") or "+condition); 3733 } 3734 3735 3736 /** 3737 * remove this expression from it's parent expr. 3738 * if itself is the top level expression, then remove it from parse tree 3739 * <p>f1 > 1 and f2 > 2, after remove f2 > 2, parent expression will be changed to: f1 > 1 3740 * <p> If we need to remove condition f > 1 from where clause: where f > 1, 3741 * Here f > 1 is the top level expression, after remove it from where clause, only WHERE keyword left in where clause. 3742 */ 3743 3744 public void removeMe(){ 3745 if (this.getExpressionType() == EExpressionType.removed_t) return; 3746 this.setExpressionType(EExpressionType.removed_t); 3747 3748 TExpression parentExpr = this.getParentExpr(); 3749 if (parentExpr == null){ 3750 this.removeTokens(); 3751 return; 3752 } 3753 3754 switch (parentExpr.getExpressionType()){ 3755 case list_t: // (1,2,3) in (column1,column2,column3) 3756 // remove column1 will break this expr, so need to remove parent expr of list_t as well. 3757 //if (parentExpr.getParentExpr() != null) removeExpr(parentExpr.getParentExpr()); 3758 parentExpr.removeMe(); 3759 break; 3760 case parenthesis_t: 3761 parentExpr.removeMe(); 3762 break; 3763 case arithmetic_plus_t: 3764 case arithmetic_minus_t: 3765 case arithmetic_times_t: 3766 case arithmetic_divide_t: 3767 case arithmetic_modulo_t: 3768 case bitwise_exclusive_or_t: 3769 case bitwise_or_t: 3770 case bitwise_and_t: 3771 case bitwise_xor_t: 3772 case logical_xor_t: 3773 case concatenate_t: 3774 case logical_and_t: 3775 case logical_or_t: 3776 if (this.getNodeStatus() == ENodeStatus.nsRemoved){ 3777 // this node is removed cascade 3778 if (this.isLeftOperandOfParent()){ 3779 if ((this.getParentExpr().getRightOperand() != null)&&(this.getParentExpr().getRightOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 3780 this.getParentExpr().refreshAllNodesTokenCount(); 3781 this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getStartToken(),this.getParentExpr().getRightOperand().getStartToken().getPrevTokenInChain()); 3782 this.getParentExpr().updateNodeWithTheSameStartToken(TParseTreeNode.nodeChangeStartToken ,this.getParentExpr().getRightOperand().getStartToken()); 3783 } 3784 }else if (this.isRightOperandOfParent()){ 3785 if ((this.getParentExpr().getLeftOperand() != null)&&(this.getParentExpr().getLeftOperand().getNodeStatus() != ENodeStatus.nsRemoved)){ 3786 this.getParentExpr().refreshAllNodesTokenCount(); 3787 this.getParentExpr().removeTokensBetweenToken(this.getParentExpr().getLeftOperand().getEndToken().getNextTokenInChain(),this.getParentExpr().getEndToken()); 3788 this.getParentExpr().updateMeNodeWithTheSameEndToken(TParseTreeNode.nodeChangeEndToken ,this.getParentExpr().getLeftOperand().getEndToken()); 3789 } 3790 } 3791 }else{ 3792 TParseTreeNode.removeTokensBetweenNodes(parentExpr.leftOperand,parentExpr.rightOperand); 3793 } 3794 3795 this.removeTokens(); 3796 if (parentExpr.getNodeStatus() == ENodeStatus.nsRemoved){ 3797 parentExpr.removeMe(); 3798 } 3799 break; 3800 case simple_comparison_t: 3801 case group_comparison_t: 3802 case in_t: 3803 parentExpr.removeMe(); 3804 break; 3805 case between_t: 3806 parentExpr.removeMe(); 3807 break; 3808 case unary_plus_t: 3809 case unary_minus_t: 3810 case unary_prior_t: 3811 case pattern_matching_t: 3812 case power_t: 3813 case range_t: 3814 case period_ldiff_t: 3815 case period_rdiff_t: 3816 case period_p_intersect_t: 3817 case period_p_normalize_t: 3818 case contains_t: 3819 case assignment_t: 3820 case sqlserver_proprietary_column_alias_t: 3821 case scope_resolution_t: 3822 case at_time_zone_t: 3823 case member_of_t: 3824 case arithmetic_exponentiation_t: 3825 case submultiset_t: 3826 case overlaps_t: 3827 case at_local_t: 3828 case day_to_second_t: 3829 case year_to_month_t: 3830 case exponentiate_t: 3831 case floating_point_t: 3832 case is_t: 3833 case logical_not_t: 3834 case null_t: 3835 case is_not_null_t: 3836 case is_true_t: 3837 case is_false_t: 3838 case is_not_true_t: 3839 case is_not_false_t: 3840 case is_of_type_t: 3841 case collate_t: //sql server,postgresql 3842 case left_join_t: 3843 case right_join_t: 3844 case ref_arrow_t: 3845 case typecast_t: 3846 case arrayaccess_t: 3847 case unary_connect_by_root_t: 3848 case interval_t: 3849 case unary_binary_operator_t: 3850 case left_shift_t: 3851 case right_shift_t: 3852 case array_constructor_t: 3853 case objectConstruct_t: 3854 case row_constructor_t: 3855 case namedParameter_t: 3856 case positionalParameter_t: 3857 case collectionArray_t: 3858 case collectionCondition_t: 3859 case unary_squareroot_t: 3860 case unary_cuberoot_t: 3861 case unary_factorialprefix_t: 3862 case unary_absolutevalue_t: 3863 case unary_bitwise_not_t: 3864 case unary_factorial_t: 3865 case bitwise_shift_left_t: 3866 case bitwise_shift_right_t: 3867 case multiset_union_t: 3868 case multiset_union_distinct_t: 3869 case multiset_intersect_t: 3870 case multiset_intersect_distinct_t: 3871 case multiset_except_t: 3872 case multiset_except_distinct_t: 3873 case json_get_text: 3874 case json_get_text_at_path: 3875 case json_get_object: 3876 case json_get_object_at_path: 3877 case json_left_contain: 3878 case json_right_contain: 3879 case json_exist: 3880 case json_any_exist: 3881 case json_all_exist: 3882 case interpolate_previous_value_t: 3883 case unnest_t: 3884 if (leftOperand != null){ 3885 leftOperand.removeMe(); 3886 }else if (rightOperand != null){ 3887 rightOperand.removeMe(); 3888 } 3889 3890 break; 3891 case lambda_t: 3892 leftOperand.removeMe(); 3893 rightOperand.removeMe(); 3894 break; 3895 case teradata_at_t: 3896 leftOperand.removeMe(); 3897 rightOperand.removeMe(); 3898 break; 3899 default: 3900 parentExpr.removeMe(); 3901 break; 3902 } 3903 } 3904 3905public void remove2(){ 3906 if (TParseTreeNode.doubleLinkedTokenListToString){ 3907 removeMe(); 3908 }else{ 3909 if (parentExpr == null){ 3910 removeAllMyTokensFromTokenList(null); 3911 }else if ((parentExpr.getExpressionType() == EExpressionType.logical_and_t) 3912 ||(parentExpr.getExpressionType() == EExpressionType.logical_or_t)) 3913 { 3914 removeAllMyTokensFromTokenList(parentExpr.getOperatorToken()); 3915 if ((parentExpr.getLeftOperand().getStartToken() == null)&&(parentExpr.getRightOperand().getStartToken() == null)){ 3916 parentExpr.remove2(); 3917 } 3918 }else if (parentExpr.getExpressionType() == EExpressionType.parenthesis_t){ 3919 removeAllMyTokensFromTokenList(null); 3920 parentExpr.remove2(); 3921 }else{ 3922 removeAllMyTokensFromTokenList(null); 3923 } 3924 } 3925} 3926 3927 public void remove(){ 3928 3929 if (this.getExpressionType() == EExpressionType.removed_t) return; 3930 3931 this.setExpressionType(EExpressionType.removed_t); 3932 TExpression parentExpr = this.getParentExpr(); 3933 3934 if (parentExpr == null) return; 3935 3936 switch (parentExpr.getExpressionType()){ 3937 case list_t: // (1,2,3) in (column1,column2,column3) 3938 // remove column1 will break this expr, so need to remove parent expr of list_t as well. 3939 //if (parentExpr.getParentExpr() != null) removeExpr(parentExpr.getParentExpr()); 3940 parentExpr.remove(); 3941 break; 3942 case pattern_matching_t: 3943 parentExpr.remove(); 3944 break; 3945 case unary_plus_t: 3946 case unary_minus_t: 3947 case unary_prior_t: 3948 parentExpr.remove(); 3949 break; 3950 case arithmetic_plus_t: 3951 case arithmetic_minus_t: 3952 case arithmetic_times_t: 3953 case arithmetic_divide_t: 3954 case power_t: 3955 case range_t: 3956 case period_ldiff_t: 3957 case period_rdiff_t: 3958 case period_p_intersect_t: 3959 case period_p_normalize_t: 3960 case contains_t: 3961 parentExpr.remove(); 3962 break; 3963 case assignment_t: 3964 parentExpr.remove(); 3965 break; 3966 case sqlserver_proprietary_column_alias_t: 3967 parentExpr.remove(); 3968 break; 3969 case arithmetic_modulo_t: 3970 case bitwise_exclusive_or_t: 3971 case bitwise_or_t: 3972 case bitwise_and_t: 3973 case bitwise_xor_t: 3974 case exponentiate_t: 3975 case scope_resolution_t: 3976 case at_time_zone_t: 3977 case member_of_t: 3978 case arithmetic_exponentiation_t: 3979 case submultiset_t: 3980 case overlaps_t: 3981 parentExpr.remove(); 3982 break; 3983 case at_local_t: 3984 case day_to_second_t: 3985 case year_to_month_t: 3986 parentExpr.remove(); 3987 break; 3988 case parenthesis_t: 3989 parentExpr.remove(); 3990 break; 3991 case simple_comparison_t: 3992 parentExpr.remove(); 3993 break; 3994 case group_comparison_t: 3995 parentExpr.remove(); 3996 break; 3997 case in_t: 3998 parentExpr.remove(); 3999 break; 4000 case floating_point_t: 4001 parentExpr.remove(); 4002 break; 4003 case logical_xor_t: 4004 case is_t: 4005 parentExpr.remove(); 4006 break; 4007 case logical_not_t: 4008 parentExpr.remove(); 4009 break; 4010 case null_t: 4011 case is_not_null_t: 4012 case is_true_t: 4013 case is_false_t: 4014 case is_not_true_t: 4015 case is_not_false_t: 4016 parentExpr.remove(); 4017 break; 4018 case between_t: 4019 parentExpr.remove(); 4020 break; 4021 case is_of_type_t: 4022 parentExpr.remove(); 4023 break; 4024 case collate_t: //sql server,postgresql 4025 parentExpr.remove(); 4026 break; 4027 case left_join_t: 4028 case right_join_t: 4029 parentExpr.remove(); 4030 break; 4031 case ref_arrow_t: 4032 parentExpr.remove(); 4033 break; 4034 case typecast_t: 4035 parentExpr.remove(); 4036 break; 4037 case arrayaccess_t: 4038 parentExpr.remove(); 4039 break; 4040 case unary_connect_by_root_t: 4041 parentExpr.remove(); 4042 break; 4043 case interval_t: 4044 parentExpr.remove(); 4045 break; 4046 case unary_binary_operator_t: 4047 parentExpr.remove(); 4048 break; 4049 case left_shift_t: 4050 case right_shift_t: 4051 parentExpr.remove(); 4052 break; 4053 case array_constructor_t: 4054 parentExpr.remove(); 4055 break; 4056 case objectConstruct_t: 4057 parentExpr.remove(); 4058 break; 4059 case row_constructor_t: 4060 parentExpr.remove(); 4061 break; 4062 case namedParameter_t: 4063 parentExpr.remove(); 4064 break; 4065 case positionalParameter_t: 4066 parentExpr.remove(); 4067 break; 4068 case collectionArray_t: 4069 parentExpr.remove(); 4070 break; 4071 case collectionCondition_t: 4072 parentExpr.remove(); 4073 break; 4074 case unary_squareroot_t: 4075 case unary_cuberoot_t: 4076 case unary_factorialprefix_t: 4077 case unary_absolutevalue_t: 4078 case unary_bitwise_not_t: 4079 parentExpr.remove(); 4080 break; 4081 case unary_factorial_t: 4082 parentExpr.remove(); 4083 break; 4084 case bitwise_shift_left_t: 4085 case bitwise_shift_right_t: 4086 parentExpr.remove(); 4087 break; 4088 case multiset_union_t: 4089 case multiset_union_distinct_t: 4090 case multiset_intersect_t: 4091 case multiset_intersect_distinct_t: 4092 case multiset_except_t: 4093 case multiset_except_distinct_t: 4094 parentExpr.remove(); 4095 break; 4096 case json_get_text: 4097 case json_get_text_at_path: 4098 case json_get_object: 4099 case json_get_object_at_path: 4100 case json_left_contain: 4101 case json_right_contain: 4102 case json_exist: 4103 case json_any_exist: 4104 case json_all_exist: 4105 case lambda_t: 4106 parentExpr.remove(); 4107 break; 4108 case interpolate_previous_value_t: 4109 parentExpr.remove(); 4110 break; 4111 case concatenate_t: 4112 case logical_and_t: 4113 case logical_or_t: 4114 if (this == parentExpr.getLeftOperand()){ 4115 parentExpr.getRightOperand().copyTo(parentExpr); 4116 }else if (this == parentExpr.getRightOperand()){ 4117 parentExpr.getLeftOperand().copyTo(parentExpr); 4118 } 4119 4120 break; 4121 case unnest_t: 4122 leftOperand.remove(); 4123 break; 4124 default: 4125 parentExpr.remove(); 4126 break; 4127 } 4128 4129 } 4130 4131 public void copyTo(TExpression target){ 4132 target.setExpressionType(this.getExpressionType()); 4133 target.setLeftOperand(this.getLeftOperand()); 4134 target.setRightOperand(this.getRightOperand()); 4135 target.setObjectOperand(this.getObjectOperand()); 4136 target.setFunctionCall(this.getFunctionCall()); 4137 target.setSubQuery(this.getSubQuery()); 4138 target.setConstantOperand(this.getConstantOperand()); 4139 target.setExprList(this.getExprList()); 4140 target.setOperatorToken(this.getOperatorToken()); 4141 target.setComparisonOperator(this.getComparisonOperator()); 4142 target.setBetweenOperand(this.getBetweenOperand()); 4143 target.setCaseExpression(this.getCaseExpression()); 4144 4145 target.setLikeEscapeOperand(this.getLikeEscapeOperand()); 4146 target.setNotToken(this.getNotToken()); 4147 target.setQuantifier(this.getQuantifier()); 4148 target.setQuantifierType(this.getQuantifierType()); 4149 4150 } 4151 4152 public static TExpression mergeObjectNameList(TExpression expr, TObjectNameList objectNameList){ 4153 TExpression ret = null; 4154 if (expr.expressionType == EExpressionType.simple_object_name_t){ 4155 TObjectName objectName = expr.getObjectOperand(); 4156 objectName.appendObjectName(objectNameList.getObjectName(0)); 4157 ret = expr; 4158 } 4159 return ret; 4160 } 4161 4162 4163 private TColumnDefinitionList colDefList = null; 4164 public TColumnDefinitionList getcolDefList() { 4165 return colDefList; 4166 } 4167 4168 public final static int BigAndOrNestLevel = 100; 4169 /** 4170 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#not_initialized_yet_t} 4171 */ 4172 public final static int unknown = 0; 4173 4174 /** 4175 * Addition: expr + expr 4176 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4177 */ 4178 /** 4179 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_plus_t} 4180 */ 4181 public final static int PLUS = 1; 4182 4183 /** 4184 * syntax: expr - expr 4185 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4186 */ 4187 /** 4188 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_minus_t} 4189 */ 4190 public final static int MINUS = 2; 4191 4192 /** 4193 * syntax: expr * expr 4194 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4195 */ 4196 /** 4197 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_times_t} 4198 */ 4199 public final static int TIMES = 3; 4200 4201 /** 4202 * syntax: expr / expr 4203 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4204 */ 4205 /** 4206 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_divide_t} 4207 */ 4208 public final static int DIVIDE = 4; 4209 4210 /** 4211 * Links two string operands to form a string expression. 4212 * <p>syntax: expr || expr, 4213 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4214 */ 4215 /** 4216 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#concatenate_t} 4217 */ 4218 public final static int CONCATENATE = 5; 4219 4220 /** 4221 * SQL SERVER,TERADATE(mod) 4222 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4223 */ 4224 /** 4225 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_modulo_t} 4226 */ 4227 public final static int MODULO = 6; // 4228 4229 /** 4230 * Used in set clause of update statement. 4231 * <p> Or, assign argument in postgresql function argument like this: 4232 * <p> param_name ASSIGN_SIGN basic_expr 4233 * <P> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4234 */ 4235 /** 4236 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#assignment_t} 4237 */ 4238 public final static int ASSIGNMENT = 7; // 4239 4240 /** 4241 * SQL SERVER, postgresql 4242 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4243 */ 4244 /** 4245 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_and_t} 4246 */ 4247 public final static int BITWISE_AND = 8; 4248 4249 /** 4250 * SQL SERVER, postgresql 4251 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4252 */ 4253 /** 4254 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_or_t} 4255 */ 4256 public final static int BITWISE_OR = 9; 4257 4258 /** 4259 * MySQL, postgresql 4260 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4261 */ 4262 /** 4263 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_xor_t} 4264 */ 4265 public final static int BITWISE_XOR = 10; // 4266 4267 /** 4268 * SQL SERVER 4269 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4270 */ 4271 /** 4272 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_exclusive_or_t} 4273 */ 4274 public final static int BITWISE_EXCLUSIVE_OR = 11; 4275 4276 /** 4277 * SQL SERVER 4278 * <p>The scope resolution operator :: provides access to static members of a compound data type, 4279 * SELECT @hid = hierarchyid::GetRoot(); 4280 * <p>Not implemented yet, 4281 */ 4282 /** 4283 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#scope_resolution_t} 4284 */ 4285 public final static int SCOPE_RESOLUTION = 12; // 4286 4287 /** 4288 * teradata ** , Postgresql ^ 4289 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4290 */ 4291 /** 4292 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#exponentiate_t} 4293 */ 4294 public final static int EXPONENTIATE = 13; // 4295 4296 /** 4297 * sql server 2008 +=,-=,*=,/=,%= 4298 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4299 */ 4300 /** 4301 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arithmetic_compound_operator_t} 4302 */ 4303 public final static int compoundAssignment = 14; 4304 4305 /** 4306 * specifies a column, pseudocolumn, sequence number, 4307 * value can be get via {@link #getObjectOperand()} which is type of {@link TObjectName}. 4308 */ 4309 /** 4310 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_object_name_t} 4311 */ 4312 public final static int simpleObjectname = 15; 4313 4314 /** 4315 * specifies a constant, 4316 * value can be get via {@link #getConstantOperand()} 4317 */ 4318 /** 4319 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_constant_t} 4320 */ 4321 public final static int simpleConstant = 16; 4322 4323 /** 4324 * specifies a null, 4325 * value can be get via {@link #getSourcetokenOperand()} which is type of {@link TSourceToken}. 4326 */ 4327 /** 4328 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_source_token_t} 4329 */ 4330 public final static int simpleSourcetoken = 17; 4331 4332 /** 4333 * expression with parenthesis, 4334 * expr can be get via {@link #getLeftOperand()} which is type of {@link TExpression}. 4335 */ 4336 /** 4337 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#parenthesis_t} 4338 */ 4339 public final static int compoundParenthesis = 18; 4340 4341 /** 4342 * unary plus expression, 4343 * <p>syntax: + expression 4344 * <p>expr can be accessed via {@link #getRightOperand()} 4345 */ 4346 /** 4347 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_plus_t} 4348 */ 4349 public final static int compoundUnaryPlus = 19; 4350 4351 /** 4352 * unary minus expression, 4353 * <p>syntax: - expression 4354 * <p>expr can be accessed via {@link #getRightOperand()} 4355 */ 4356 /** 4357 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_minus_t} 4358 */ 4359 public final static int compoundUnaryMinus = 20; 4360 4361 /** 4362 * Oracle prior expression, syntax: PRIOR expr 4363 * value can be accessed via {@link #getRightOperand()} which is type of {@link TExpression} 4364 */ 4365 /** 4366 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_prior_t} 4367 */ 4368 public final static int compoundPrior = 21; 4369 4370 /** 4371 * CASE expressions let you use IF ... THEN ... ELSE logic in SQL statements without 4372 * having to invoke procedures. 4373 * value can be accessed via {@link #getCaseExpression()} which is type of {@link TCaseExpression}. 4374 */ 4375 /** 4376 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#case_t} 4377 */ 4378 public final static int caseExprOperator = 22; 4379 4380 /** 4381 * A CURSOR expression returns a nested cursor. 4382 * <p>syntax: CURSOR(subquery ), 4383 * <p>subquery can be accessed via {@link #getSubQuery()} which is type of {@link TSelectSqlStatement}. 4384 */ 4385 /** 4386 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#cursor_t} 4387 */ 4388 public final static int cursorExprOperator = 23; 4389 4390 /** 4391 * funcation expression, 4392 * <p>value can be get via {@link #getFunctionCall()} 4393 */ 4394 /** 4395 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#function_t} 4396 */ 4397 public final static int funcationCallOperator = 24; 4398 4399 4400 /** 4401 * datetime expression 4402 * <p>N/A 4403 */ 4404 /** 4405 * @deprecated As of v1.4.3.0 4406 */ 4407 public final static int datetimeExprOperator = 25; 4408 4409 /** 4410 * interval expression 4411 * <p>N/A 4412 */ 4413 /** 4414 * @deprecated As of v1.4.3.0 4415 */ 4416 public final static int intervalExprOperator = 26; 4417 4418 4419 /** 4420 * model expression, not implemented yet 4421 * <p>N/A 4422 */ 4423 /** 4424 * @deprecated As of v1.4.3.0 4425 */ 4426 public final static int modelExprOperator = 27; 4427 4428 /** 4429 * A scalar subquery expression is a subquery that returns exactly one column value 4430 * from one row. 4431 * <br>value can be get via {@link #getSubQuery()} which is type of {@link TSelectSqlStatement}. 4432 */ 4433 /** 4434 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#subquery_t} 4435 */ 4436 public final static int subqueryExprOperator = 28; 4437 4438 // 4439 /** 4440 * type constructor expression, 4441 * <p>not implemented yet 4442 */ 4443 /** 4444 * @deprecated As of v1.4.3.0 4445 */ 4446 public final static int typeconstructorExprOperator = 29; 4447 4448 4449 /** 4450 * object access expression, some of those was represented by simpleObjectname expression. 4451 * <p>N/A 4452 */ 4453 /** 4454 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#object_access_t} 4455 */ 4456 public final static int objectaccessExprOperator = 30; 4457 4458 // model conditions is not implemented yet 4459 // multiset conditions is not implemented yet 4460 4461 /** 4462 * pattern matching conditon support like only, regexp_like was treat as a function 4463 * <p>N/A 4464 */ 4465 //public final static int patternMatchingExprOperator = 31; 4466 //xml conditon not implemented here, treat as a function 4467 4468 4469 /** 4470 * place holder expression 4471 */ 4472 /** 4473 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#place_holder_t} 4474 */ 4475 public final static int placeholderExprOperator = 32; 4476 4477 /** 4478 * IN expr, values can be get via {@link #getInExpr()} 4479 */ 4480 /** 4481 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#group_t} 4482 */ 4483 public final static int in_expr = 34; 4484 4485 /** 4486 * row descriptor, values can be get via {@link #getExprList()} 4487 */ 4488 /** 4489 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#list_t} 4490 */ 4491 public final static int expr_list = 35; 4492 4493 // dummy expression operator, used in preOrderTraverse,inOrderTraverse, postOrderTraverse function only. 4494 /** 4495 * @deprecated As of v1.4.3.0 4496 */ 4497 public final static int dummyOperator = 37; 4498 4499 /** 4500 * Comparison conditions compare one expression with another. 4501 * The result of such a comparison can be TRUE, FALSE, or NULL. 4502 * 4503 * A simple comparison condition specifies a comparison with expressions or subquery results. 4504 * <p>Syntax: expr EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN expr, 4505 * or, (expr_list) EQUAL|NOT_EQUAL (subquery) 4506 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4507 */ 4508 /** 4509 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#simple_comparison_t} 4510 */ 4511 public final static int simple_comparison_conditions = 40; 4512 4513 /** 4514 * Comparison conditions compare one expression with another. 4515 * The result of such a comparison can be TRUE, FALSE, or NULL. 4516 * 4517 * <p>A group comparison condition specifies a comparison with any or all members 4518 * in a list or subquery. 4519 * <p>Syntax: expr EQUAL|NOT_EQUAL|LESS_THAN|GRREAT_THAN|LESS_EQUAL_THAN|GREATE_EQUAL_THAN ANY|SOME|ALL (expr_list|subquery), 4520 * or, (expr_list) EQUAL|NOT_EQUAL ANY|SOME|ALL (expr_list|subquery) 4521 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4522 */ 4523 /** 4524 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#group_comparison_t} 4525 */ 4526 public final static int group_comparison_conditions = 41; 4527 4528 /** 4529 * An in_condition is a membership condition. It tests a value for membership in a list of values or subquery. 4530 * <p>Syntax: (expr|expr_list) IN|NOT IN (expr_list|subquery). 4531 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4532 * <p>Use {@link #getOperatorToken()} to distinguish in or not in. 4533 */ 4534 /** 4535 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#in_t} 4536 */ 4537 public final static int in_conditions = 42; 4538 4539 /** 4540 * 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). 4541 * <p>Syntax: expr IS|IS NOT (NAM|INFINITE). 4542 * <p>Value can be get via {@link #getLeftOperand()} 4543 */ 4544 /** 4545 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#floating_point_t} 4546 */ 4547 public final static int floating_point_conditions = 43; 4548 4549 /** 4550 * The pattern-matching conditions compare character data. 4551 * <p>The LIKE conditions specify a test involving pattern matching. 4552 * <p>Syntax: expr1 LIKE|NOT_LIKE expr1 [ESCAPE expr3], 4553 * <p>expr1 can be get via {@link #getLeftOperand()}, 4554 * <p>expr2 can be get via {@link #getRightOperand()}, 4555 * <p>expr3 can be get via {@link #getLikeEscapeOperand()}, 4556 * <p>Use {@link #getOperatorToken()} to distinguish is like or is not like 4557 */ 4558 /** 4559 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#pattern_matching_t} 4560 */ 4561 public final static int pattern_matching_conditions = 45; 4562 4563 /** 4564 * A NULL condition tests for nulls. This is the only condition that you should use to test for nulls. 4565 * <p>Syntax: expr IS [NOT] null 4566 * <p>expr can be accessed via {@link #getLeftOperand()} 4567 * <p>Use {@link #getOperatorToken()} to distinguish is null or is not null 4568 */ 4569 /** 4570 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#null_t} 4571 */ 4572 public final static int null_conditions = 46; 4573 4574 /** 4575 * A BETWEEN condition determines whether the value of one expression is in an interval defined by two other expressions. 4576 * <p>Syntax: expr1 [NOT] BETWEEN expr2 AND expr3 4577 * <p>expr1 can be get via {@link #betweenOperand}, 4578 * <p>expr2 can be get via {@link #getLeftOperand()}, and expr3 can be get via {@link #getRightOperand()}, 4579 * <p>Use {@link #getOperatorToken()} to distinguish is between or is not between 4580 */ 4581 /** 4582 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#between_t} 4583 */ 4584 public final static int between_conditions = 47; 4585 4586 /** 4587 * An EXISTS condition tests for existence of rows in a subquery. 4588 * <p>Syntax: EXISTS (subquery). 4589 * <p>value of subquery can be get via {@link #getSubQuery()} 4590 */ 4591 /** 4592 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#exists_t} 4593 */ 4594 public final static int exists_condition = 48; 4595 4596 /** 4597 * <p>expr can be accessed via {@link #getLeftOperand()} 4598 */ 4599 /** 4600 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_of_type_t} 4601 */ 4602 public final static int isoftype_condition = 49; 4603 4604 /** 4605 * 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. 4606 *<p> Syntax: expr AND expr. 4607 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4608 */ 4609 /** 4610 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_and_t} 4611 */ 4612 public final static int logical_conditions_and = 50; 4613 4614 /** 4615 * 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. 4616 * <p>Syntax: expr OR expr. 4617 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4618 */ 4619 /** 4620 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_or_t} 4621 */ 4622 public final static int logical_conditions_or = 51; 4623 4624 /** 4625 * 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. 4626 * <p>Syntax: expr XOR expr. 4627 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4628 */ 4629 /** 4630 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_xor_t} 4631 */ 4632 public final static int logical_conditions_xor = 52; 4633 4634 /** 4635 * 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. 4636 * <p>Syntax: NOT expr. 4637 * <p>value can be get via {@link #rightOperand}, 4638 */ 4639 /** 4640 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#logical_not_t} 4641 */ 4642 public final static int logical_conditions_not = 53; 4643 4644 /** 4645 * Mdx is logical condition 4646 */ 4647 /** 4648 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_t} 4649 */ 4650 public final static int logical_conditions_is = 54; 4651 4652 4653 /** 4654 * Mdx range operator : 4655 */ 4656 /** 4657 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#range_t} 4658 */ 4659 public final static int RANGE = 55; 4660 4661 /** 4662 * mdx power operator ^ 4663 */ 4664 /** 4665 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#power_t} 4666 */ 4667 public final static int POWER = 56; // 4668 4669 /** 4670 * ORACLE,teradata date time expression, at time zone. 4671 * <p>Syntax: expr1 AT TIME ZONE expr2 4672 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4673 */ 4674 /** 4675 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#at_time_zone_t} 4676 */ 4677 public final static int at_time_zone = 100; 4678 4679 4680 /** 4681 * ORACLE,teradata date time expression, at local. 4682 * <p>Syntax: expr AT LOCAL. 4683 * <p>expr can be accessed via {@link #getLeftOperand()} 4684 */ 4685 /** 4686 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#at_local_t} 4687 */ 4688 public final static int at_local = 101; 4689 4690 /** 4691 * ORACLE date time expression, day to second. 4692 * <p>Syntax: expr DAY [( integer )] TO SECOND [( integer )]. 4693 * <p>expr cam be get via {@link #getLeftOperand()}. 4694 * <p>The type of this operand is {@link TExpression}. 4695 */ 4696 /** 4697 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#day_to_second_t} 4698 */ 4699 public final static int day_to_second = 102; 4700 4701 /** 4702 * ORACLE date time expression, year to month. 4703 *<p> Syntax: expr YEAR [( integer )] TO MONTH. 4704 * <p>expr can be accessed via {@link #getLeftOperand()} 4705 */ 4706 /** 4707 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#year_to_month_t} 4708 */ 4709 public final static int year_to_month = 103; 4710 4711 /** 4712 * teradata interval expression: 4713 * <p>( date_time_expression date_time_term ) start TO end 4714 * <p>{@link #getIntervalExpr()} 4715 */ 4716 /** 4717 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#interval_t} 4718 */ 4719 public final static int interval_expression = 104; 4720 4721 /** 4722 * teradata 4723 * Constructs a new instance of a structured type 4724 * and initializes it using the specified constructor method or function. 4725 *<p> object reference {@link TExpression#getFunctionCall()} 4726 */ 4727 /** 4728 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#new_structured_type_t} 4729 */ 4730 public final static int new_structured_type = 110; 4731 4732 /** 4733 * teradata 4734 * Constructs a new instance of a dynamic or VARIANT_TYPE UDT 4735 * and defines the run time composition of the UDT. 4736 * object reference {@link #getNewVariantTypeArgumentList()} 4737 */ 4738 /** 4739 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#new_variant_type_t} 4740 */ 4741 public final static int new_variant_type = 111; 4742 4743 /** 4744 * teradata period expression: ldiff 4745 * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4746 */ 4747 /** 4748 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_ldiff_t} 4749 */ 4750 public final static int period_ldiff = 115; 4751 4752 /** 4753 * teradata period expression: rdiff 4754 * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4755 */ 4756 /** 4757 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_rdiff_t} 4758 */ 4759 public final static int period_rdiff = 117; 4760 4761 /** 4762 * teradata period expression: p_intersect 4763 * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4764 */ 4765 /** 4766 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_p_intersect_t} 4767 */ 4768 public final static int period_p_intersect = 119; 4769 4770 /** 4771 * teradata period expression: p_normalize 4772 * <p> expression can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4773 */ 4774 /** 4775 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#period_p_normalize_t} 4776 */ 4777 public final static int period_p_normalize = 121; 4778 4779 /** 4780 * teradata until changed condition 4781 * <p> syntax: END(period_value_expression) IS[NOT] UNTIL_CHANGED 4782 * <p> ending bound of a Period value expression can be accessed via {@link #getLeftOperand()} 4783 */ 4784 /** 4785 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#until_changed_t} 4786 */ 4787 public final static int until_changed = 123; 4788 4789 /** 4790 * Postgresql, is document condition 4791 * <p>expr is [not] document 4792 * <p> expr was set in {@link #leftOperand}. 4793 * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not. 4794 */ 4795 /** 4796 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_document_t} 4797 */ 4798 public final static int is_document = 133; 4799 4800 4801 /** 4802 * Postgresql, 4803 * <p>expr is [not] distinct from expr 4804 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4805 * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not. 4806 */ 4807 /** 4808 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_distinct_from_t} 4809 */ 4810 public final static int is_distinct_from = 135; 4811 4812 /** 4813 * Postgresql 4814 * <p> true, false, unknown condition 4815 * <p> expr is [not] true 4816 * <p> expr is [not] false 4817 * <p> expr is [not] unknown 4818 * <p> expr can be accessed via {@link #getLeftOperand()} 4819 * <p> {@link #getOperatorToken()} can be used to check whether NOT keyword was used or not. 4820 */ 4821 /** 4822 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#is_true_t}, 4823 * {@link EExpressionType#is_false_t},{@link EExpressionType#is_unknown_t} 4824 */ 4825 public final static int true_false_unknown = 137; 4826 4827 4828 4829 /** 4830 * sql server, Is a clause that can be applied to a database definition or a column definition 4831 * to define the collation, or to a character string expression to apply a collation cast. 4832 * 4833 * postgresql 4834 * 4835 *<p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4836 */ 4837 /** 4838 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#collate_t} 4839 */ 4840 public final static int COLLATE = 200+23; 4841 4842 /** 4843 * sql server, LEFTJOIN_OP *= 4844 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4845 */ 4846 /** 4847 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#left_join_t} 4848 */ 4849 public final static int LEFTJOIN_OP = 200+24; // 4850 4851 /** 4852 * sql server, RIGHTJOIN_OP =* 4853 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4854 */ 4855 /** 4856 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#right_join_t} 4857 */ 4858 public final static int RIGHTJOIN_OP = 200+25; // 4859 4860 /** 4861 * plsql RAISE_APPLICATION_ERROR (num=> -20107, msg=> 'Duplicate customer or order ID'); 4862 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4863 */ 4864 /** 4865 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#ref_arrow_t} 4866 */ 4867 public final static int ref_arrow = 200+26;// 4868 4869 4870 /** 4871 * plsql 4872 * <p>expr can be accessed via {@link #getLeftOperand()} 4873 */ 4874 /** 4875 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#typecast_t} 4876 */ 4877 public final static int typecast = 200+27;// 4878 /** 4879 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#arrayaccess_t} 4880 */ 4881 public final static int arrayaccess = 200+28;//plsql array access 4882 4883 /** 4884 * oracle unary operator connect_by_root is only valid in hierarchical queries 4885 * <p>expr can be accessed via {@link #getRightOperand()} 4886 */ 4887 /** 4888 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_connect_by_root_t} 4889 */ 4890 public final static int connect_by_root = 200+29; // 4891 4892 /** 4893 * SQL SERVER Proprietary syntax, set alias of a column in select list, 4894 * column expr in rightOperand. 4895 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4896 */ 4897 /** 4898 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#sqlserver_proprietary_column_alias_t} 4899 */ 4900 public final static int sqlserver_proprietary_column_alias = 200+30; // 4901 4902 4903 /** 4904 MySQL binary operator, select binary 'a' = 'A' 4905 * <p>syntax: binary expr 4906 * <p>expr can be accessed via {@link #getRightOperand()} 4907 */ 4908 /** 4909 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_binary_operator_t} 4910 */ 4911 public final static int mysql_binary_operator = 300; 4912 4913 /** 4914 * MySQL left shift 4915 * <p>Syntax: expr << expr. 4916 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4917 */ 4918 /** 4919 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#left_shift_t} 4920 */ 4921 public final static int left_shift = 301; 4922 4923 /** 4924 * MySQL rigth shift 4925 * <p>Syntax: expr >> expr. 4926 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 4927 */ 4928 /** 4929 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#right_shift_t} 4930 */ 4931 public final static int right_shift = 302; 4932 4933 /** 4934 * Oracle MULTISET operator 4935 * <p>Syntax MULTISET (subquery) 4936 * <p> subquery can be get via {@link #getSubQuery()} 4937 */ 4938 /** 4939 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#multiset_t} 4940 */ 4941 public final static int multisetExprOperator = 310; 4942 4943 /** 4944 * If an expression yields a value of a composite type (row type), then a specific field of the row can be extracted by writing 4945 * <p> expression.fieldname 4946 * <p> In general the row expression must be parenthesized, but the parentheses can be omitted 4947 * <p> when the expression to be selected from is just a table reference or positional parameter. 4948 * <p> For example: 4949 * <p> mytable.mycolumn 4950 * <p> $1.somecolumn 4951 * <p> (rowfunction(a,b)).col3 4952 * <p> 4953 * <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: 4954 * <p> (compositecol).somefield 4955 * <p> (mytable.compositecol).somefield 4956 * <p> The parentheses are required here to show that compositecol is a column name not a table name, 4957 * <p> or that mytable is a table name not a schema name in the second case. 4958 * <p> 4959 * <p> n a select list, you can ask for all fields of a composite value by writing .*: 4960 * <p> (compositecol).* 4961 * <p> 4962 * <p> 4963 * <p> When expression in following syntax, it will be marked as {@link #fieldSelection}, and check {@link #getFieldName()} 4964 * <p> (rowfunction(a,b)).col3 4965 * <p> (compositecol).somefield 4966 * <p> (mytable.compositecol).somefield 4967 * <p> (compositecol).* 4968 * <p> 4969 * <p> Otherwise, it will be marked as {@link #simpleObjectname}: 4970 * <p> mytable.mycolumn 4971 * <p> $1.somecolumn 4972 */ 4973 /** 4974 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#fieldselection_t} 4975 */ 4976 public final static int fieldSelection = 501; 4977 4978 /** 4979 * An array constructor is an expression that builds an array value using values for its member elements. 4980 * <p> like this: ARRAY[1,2,3+4] 4981 * <p> array element values can be accessed via {@link #getExprList()}, 4982 * <p> or {@link #getExprList()} can be null when it is: array[] 4983 * <p> 4984 * <p> It is also possible to construct an array from the results of a subquery like this: 4985 * <p> SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%'); 4986 * <p> thus, subquery can be access via {@link #getSubQuery()} 4987 */ 4988 /** 4989 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#array_constructor_t} 4990 */ 4991 public final static int arrayConstructor = 505; //postgresql 4992 4993 /** 4994 * A row constructor is an expression that builds a row value (also called a composite value) using values for its member fields. 4995 * <p> like this: ROW(1,2.5,'this is a test') 4996 * <p> element values can be accessed via {@link #getExprList()}, 4997 * <p> or {@link #getExprList()} can be null when it is: row() 4998 */ 4999 /** 5000 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#row_constructor_t} 5001 */ 5002 public final static int rowConstructor = 509; 5003 5004 /** 5005 * Postgresql factorial: 5006 * <p> expr ! 5007 * <p> expr can be accessed via {@link #getLeftOperand()} 5008 */ 5009 /** 5010 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_factorial_t} 5011 */ 5012 public final static int factorial = 515; 5013 5014 /** 5015 * Postgresql square root 5016 * <p> |/ 25.0 5017 * <p> expr can be accessed via {@link #getRightOperand()} 5018 */ 5019 /** 5020 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_squareroot_t} 5021 */ 5022 public final static int squareRoot = 517; 5023 5024 /** 5025 * Postgresql cube root 5026 * <p> ||/ 27.0 5027 * <p> expr can be accessed via {@link #getRightOperand()} 5028 */ 5029 /** 5030 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_cuberoot_t} 5031 */ 5032 public final static int cubeRoot = 519; 5033 5034 /** 5035 * Postgresql factorial (prefix operator): 5036 * <p> !! 5 5037 * <p> expr can be accessed via {@link #getRightOperand()} 5038 */ 5039 /** 5040 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_factorialprefix_t} 5041 */ 5042 public final static int factorialPrefix = 521; 5043 5044 /** 5045 * Postgresql absolute value 5046 * <p> @ -5.0 5047 * <p> expr can be accessed via {@link #getRightOperand()} 5048 */ 5049 /** 5050 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_absolutevalue_t} 5051 */ 5052 public final static int absoluteValue = 523; 5053 5054 /** 5055 * Postgresql bitwise shit left 5056 * <p> expr << expr 5057 * <p> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 5058 */ 5059 /** 5060 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_shift_left_t} 5061 */ 5062 public final static int BITWISE_SHIFT_LEFT = 525; //postgresql 5063 5064 /** 5065 * Postgresql bitwise shit right 5066 * <p> expr >> expr 5067 * <p> expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 5068 */ 5069 /** 5070 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#bitwise_shift_right_t} 5071 */ 5072 public final static int BITWISE_SHIFT_RIGHT = 527; //postgresql 5073 5074 /** 5075 * Postgresql bitwise not 5076 * <p> ~expr 5077 * <p> expr can be accessed via {@link #getRightOperand()} 5078 */ 5079 /** 5080 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_bitwise_not_t} 5081 */ 5082 public final static int BITWISE_NOT = 529; //postgresql 5083 5084 /** 5085 * sql server 5086 * <p>expr can be accessed via {@link #getRightOperand()} 5087 */ 5088 5089 /** 5090 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_bitwise_not_t} 5091 */ 5092 public final static int compoundUnaryBitwiseNot = 200+22; // 5093 5094 // 5095 5096 /** 5097 * ORACLE 5098 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 5099 */ 5100 /** 5101 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#member_of_t} 5102 */ 5103 public final static int member_of = 541; 5104 5105 /** 5106 * Netezza 5107 * <p>NEXT VALUE FOR <sequence name> 5108 * <p>NEXT <integer expression> VALUE FOR <sequence name> 5109 * <p> integer expression can be accessed via {@link #getLeftOperand()} if any. 5110 * <p> sequence name name can be accessed via {@link #getRightOperand()} 5111 */ 5112 5113 /** 5114 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#next_value_for_t} 5115 */ 5116 public final static int nextValueOf = 601; 5117 5118 /** 5119 * This UnknownOperator means this expression was not recognized by SQL parser yet. 5120 * <p>In syntax like this: 5121 * <p> expr OPERATOR expr 5122 * <p>expr can be accessed via {@link #getLeftOperand()} and {@link #getRightOperand()} 5123 */ 5124 /** 5125 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unknown_t} 5126 */ 5127 public final static int UnknownOperator = 901; 5128 5129 5130 /** 5131 * This UnknownLeftUnaryOperator means this expression was not recognized by SQL parser yet. 5132 * <p>In syntax like this: 5133 * <p> OPERATOR expr 5134 * <p>expr can be accessed via {@link #getRightOperand()} 5135 */ 5136 /** 5137 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_left_unknown_t} 5138 */ 5139 public final static int UnknownUnaryOperator = 905; 5140 5141 /** 5142 * This UnknownLeftUnaryOperator means this expression was not recognized by SQL parser yet. 5143 * <p>In syntax like this: 5144 * <p> expr OPERATOR 5145 * <p>expr can be accessed via {@link #getLeftOperand()} 5146 */ 5147 /** 5148 * @deprecated As of v1.4.3.0, replaced by {@link EExpressionType#unary_right_unknown_t} 5149 */ 5150 public final static int UnknownUnaryOperatorRight = 909; 5151 5152 5153}