@Override public EvalNode visitUnaryEval(LogicalPlanner.PlanContext context, UnaryEval unaryEval, Stack<EvalNode> stack) { stack.push(unaryEval); EvalNode child = visit(context, unaryEval.getChild(), stack); stack.pop(); unaryEval.setChild(child); if (child.getType() == EvalType.CONST) { // session's time zone String timezoneId = context.getQueryContext().get(SessionVars.TIMEZONE); EvalContext evalContext = new EvalContext(); evalContext.setTimeZone(TimeZone.getTimeZone(timezoneId)); unaryEval.bind(evalContext, null); return new ConstEval(unaryEval.eval(null)); } return unaryEval; }
@Override public EvalNode visitUnaryEval(LogicalPlanner.PlanContext context, UnaryEval unaryEval, Stack<EvalNode> stack) { stack.push(unaryEval); EvalNode child = visit(context, unaryEval.getChild(), stack); stack.pop(); unaryEval.setChild(child); if (child.getType() == EvalType.CONST) { // session's time zone String timezoneId = context.getQueryContext().get(SessionVars.TIMEZONE); EvalContext evalContext = new EvalContext(); evalContext.setTimeZone(TimeZone.getTimeZone(timezoneId)); unaryEval.bind(evalContext, null); return new ConstEval(unaryEval.eval(null)); } return unaryEval; }
} else { qualifier = IdentifierUtil.buildFQName( ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), asteriskExpr.getQualifier());
CatalogUtil.newDefaultProperty(createTableNode.getStorageType(), context.getQueryContext().getConf()));
CatalogUtil.newDefaultProperty(createTableNode.getStorageType(), context.getQueryContext().getConf()));
} else { qualifier = CatalogUtil.buildFQName( ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), asteriskExpr.getQualifier());
EvalContext evalContext = new EvalContext(); String timezoneId = context.getQueryContext().get(SessionVars.TIMEZONE); evalContext.setTimeZone(TimeZone.getTimeZone(timezoneId)); TajoScriptEngine executor = new PythonScriptEngine(evalNode.getFuncDesc()); try { executor.start(context.getQueryContext().getConf()); evalContext.addScriptEngine(evalNode, executor); evalNode.bind(evalContext, null);
EvalContext evalContext = new EvalContext(); String timezoneId = context.getQueryContext().get(SessionVars.TIMEZONE); evalContext.setTimeZone(TimeZone.getTimeZone(timezoneId)); TajoScriptEngine executor = new PythonScriptEngine(evalNode.getFuncDesc()); try { executor.start(context.getQueryContext().getConf()); evalContext.addScriptEngine(evalNode, executor); evalNode.bind(evalContext, null);
targetUri = URI.create(context.getQueryContext().get(QueryVars.DEFAULT_SPACE_ROOT_URI) + "/" + targetUri);
targetUri = URI.create(context.getQueryContext().get(QueryVars.DEFAULT_SPACE_ROOT_URI) + "/" + targetUri);
@Override public LogicalNode visitSimpleTableSubquery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SimpleTableSubquery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitSimpleTableSubquery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), ctx.generateUniqueSubQueryName()), child); ctx.getQueryBlock().addRelation(node); if (stack.peek().getType() == OpType.InPredicate) { // In-subquery and scalar subquery cannot be the base for name resolution. node.setNameResolveBase(false); } return node; }
@Override public LogicalNode visitRelation(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Relation relation) throws TajoException { String actualRelationName; if (CatalogUtil.isFQTableName(relation.getName())) { actualRelationName = relation.getName(); } else { actualRelationName = CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), relation.getName()); } TableDesc desc = catalog.getTableDesc(actualRelationName); ScanNode scanNode = ctx.getPlan().createNode(ScanNode.class); if (relation.hasAlias()) { scanNode.init(desc, relation.getAlias()); } else { scanNode.init(desc); } TablePropertyUtil.setTableProperty(ctx.getQueryContext(), scanNode); ctx.getQueryBlock().addRelation(scanNode); return scanNode; }
@Override public LogicalNode visitSimpleTableSubquery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, SimpleTableSubquery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitSimpleTableSubquery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), ctx.generateUniqueSubQueryName()), child); ctx.getQueryBlock().addRelation(node); if (stack.peek().getType() == OpType.InPredicate) { // In-subquery and scalar subquery cannot be the base for name resolution. node.setNameResolveBase(false); } return node; }
@Override public LogicalNode visitRelation(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, Relation relation) throws TajoException { String actualRelationName; if (IdentifierUtil.isFQTableName(relation.getName())) { actualRelationName = relation.getName(); } else { actualRelationName = IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), relation.getName()); } TableDesc desc = catalog.getTableDesc(actualRelationName); ScanNode scanNode = ctx.getPlan().createNode(ScanNode.class); if (relation.hasAlias()) { scanNode.init(desc, relation.getAlias()); } else { scanNode.init(desc); } TablePropertyUtil.setTableProperty(ctx.getQueryContext(), scanNode); ctx.getQueryBlock().addRelation(scanNode); return scanNode; }
@Override public LogicalNode visitTableSubQuery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, TablePrimarySubQuery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitTableSubQuery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(IdentifierUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), expr.getName()), child); ctx.getQueryBlock().addRelation(node); return node; }
@Override public LogicalNode visitTableSubQuery(LogicalPlanner.PlanContext ctx, Stack<Expr> stack, TablePrimarySubQuery expr) throws TajoException { LogicalPlanner.PlanContext newContext; // Note: TableSubQuery always has a table name. // SELECT .... FROM (SELECT ...) TB_NAME <- QueryBlock queryBlock = ctx.getPlan().newQueryBlock(); newContext = new LogicalPlanner.PlanContext(ctx, queryBlock); LogicalNode child = super.visitTableSubQuery(newContext, stack, expr); queryBlock.setRoot(child); // a table subquery should be dealt as a relation. TableSubQueryNode node = ctx.getPlan().createNode(TableSubQueryNode.class); node.init(CatalogUtil.buildFQName(ctx.getQueryContext().get(SessionVars.CURRENT_DATABASE), expr.getName()), child); ctx.getQueryBlock().addRelation(node); return node; }
private static String getQualifiedName(PlanContext context, String simpleName) { return CatalogUtil.isFQTableName(simpleName) ? simpleName : CatalogUtil.buildFQName(context.getQueryContext().get(SessionVars.CURRENT_DATABASE), simpleName); }
private static String getQualifiedName(PlanContext context, String simpleName) { return IdentifierUtil.isFQTableName(simpleName) ? simpleName : IdentifierUtil.buildFQName(context.getQueryContext().get(SessionVars.CURRENT_DATABASE), simpleName); }