public ExpressionAssembler(PlanContext planContext) {
   this.planContext = planContext;
   if (planContext instanceof ExplainPlanContext)
     explainContext = ((ExplainPlanContext) planContext).getExplainContext();
   else explainContext = null;
   rulesContext = (SchemaRulesContext) planContext.getRulesContext();
   registryService = rulesContext.getTypesRegistry();
   queryContext = planContext.getQueryContext();
 }
 // Changes here probably need reflected in OnlineHelper#buildColumnDefault()
 public TPreparedExpression assembleColumnDefault(Column column, TPreparedExpression expression) {
   return PlanGenerator.generateDefaultExpression(
       column,
       expression,
       registryService,
       rulesContext.getTypesTranslator(),
       planContext.getQueryContext());
 }
Example #3
0
 @Override
 public String generateResult() throws Exception {
   StatementNode stmt = parser.parseStatement(sql);
   binder.bind(stmt);
   stmt = booleanNormalizer.normalize(stmt);
   typeComputer.compute(stmt);
   stmt = subqueryFlattener.flatten((DMLStatementNode) stmt);
   // Turn parsed AST into intermediate form as starting point.
   AST ast = new AST((DMLStatementNode) stmt, parser.getParameterList());
   PlanContext plan = new PlanContext(rules, ast);
   rules.applyRules(plan);
   PlanNode.SummaryConfiguration configuration =
       new PlanNode.SummaryConfiguration(
           Boolean.parseBoolean(properties.getProperty("showRowTypes", "false")),
           Boolean.parseBoolean(properties.getProperty("includeIndexTableNames", "false")));
   String result = plan.planString(configuration);
   if (Boolean.parseBoolean(properties.getProperty("showParameterTypes", "false")))
     result = ast.formatParameterTypes() + result;
   return result;
 }
 public ConstantExpression evalNow(PlanContext planContext, ExpressionNode node) {
   if (node instanceof ConstantExpression) return (ConstantExpression) node;
   TPreparedExpression expr = assembleExpression(node, null, null);
   TPreptimeValue preptimeValue = expr.evaluateConstant(planContext.getQueryContext());
   if (preptimeValue == null)
     throw new AkibanInternalException("required constant expression: " + expr);
   ValueSource valueSource = preptimeValue.value();
   if (valueSource == null)
     throw new AkibanInternalException("required constant expression: " + expr);
   if (node instanceof ConditionExpression) {
     Boolean value = valueSource.isNull() ? null : valueSource.getBoolean();
     return new BooleanConstantExpression(value);
   } else {
     return new ConstantExpression(preptimeValue);
   }
 }