001package gudusoft.gsqlparser.stmt.dax; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.*; 005 006/** 007 * DAX expression statement, syntax like 008 * <pre> 009 * {@code 010 * [VAR][var_name|measure_name] = expr 011 * } 012 * </pre> 013 */ 014public class TDaxExprStmt extends TDaxStmt { 015 public TDaxExprStmt (EDbVendor dbvendor){ 016 super(dbvendor); 017 sqlstatementtype = ESqlStatementType.sstdaxexpr ; 018 } 019 private TObjectName variableName; 020 021 public TObjectName getVariableName() { 022 return variableName; 023 } 024 025 public TObjectName getMeasureName() { 026 return measureName; 027 } 028 029 public TObjectName getColumnName() { 030 return columnName; 031 } 032 033 private TObjectName measureName; 034 private TObjectName columnName; 035 036 037 private TExpression expr; 038 039 public void setExpr(TExpression expr) { 040 this.expr = expr; 041 } 042 043 /** 044 * 045 * @return expression which is type of EExpressionType#function_t, including a DAX function 046 */ 047 public TExpression getExpr() { 048 return expr; 049 } 050 051 public int doParseStatement(TCustomSqlStatement psql) { 052 if (rootNode == null) return -1; 053 super.doParseStatement(psql); 054 TDummy dummy = (TDummy)rootNode; 055 expr = (TExpression)(dummy).node1; 056 057 058 if (dummy.node2 != null){ 059 this.columnName = (TObjectName)(dummy.node2); 060 if (this.columnName.toString().equalsIgnoreCase(":=")){ 061 this.measureName = this.columnName; 062 this.columnName = null; 063 } 064 065 if (this.columnName.toString().indexOf("%")>=0){ 066 this.measureName = this.columnName; 067 this.columnName = null; 068 } 069 } 070 071 if (dummy.node3 != null){ 072 this.variableName = (TObjectName)dummy.node3; 073 } 074 075 expr.doParse(this, ESqlClause.unknown); 076 077 return 0; 078 } 079 080 081 public void accept(TParseTreeVisitor v){ 082 v.preVisit(this); 083 v.postVisit(this); 084 } 085 086 087 public void acceptChildren(TParseTreeVisitor v){ 088 v.preVisit(this); 089 v.postVisit(this); 090 } 091} 092