@Override public void visit(DeclareStatement obj) { preVisitVisitor(obj); visitNode(obj.getVariable()); visitNode(obj.getExpression()); postVisitVisitor(obj); }
private void collectDeclareVariable( DeclareStatement obj, GroupSymbol variables, TempMetadataAdapter metadata, GroupContext externalGroups) throws QueryResolverException, TeiidComponentException { ElementSymbol variable = obj.getVariable(); String typeName = obj.getVariableType(); GroupSymbol gs = variable.getGroupSymbol(); if (gs == null) { String outputName = variable.getShortName(); variable.setGroupSymbol(new GroupSymbol(ProcedureReservedWords.VARIABLES)); variable.setOutputName(outputName); } else { if (gs.getSchema() != null || !gs.getShortName().equalsIgnoreCase(ProcedureReservedWords.VARIABLES)) { handleUnresolvableDeclaration( variable, QueryPlugin.Util.getString( "ERR.015.010.0031", new Object[] {ProcedureReservedWords.VARIABLES, variable})); // $NON-NLS-1$ } } boolean exists = false; try { ResolverVisitor.resolveLanguageObject(variable, null, externalGroups, metadata); exists = true; } catch (QueryResolverException e) { // ignore, not already defined } if (exists) { handleUnresolvableDeclaration( variable, QueryPlugin.Util.getString("ERR.015.010.0032", variable.getOutputName())); // $NON-NLS-1$ } variable.setType(DataTypeManager.getDataTypeClass(typeName)); variable.setGroupSymbol(variables); TempMetadataID id = new TempMetadataID( variable.getName(), typeName.equalsIgnoreCase(SQLConstants.NonReserved.EXCEPTION) ? Exception.class : variable.getType()); id.setUpdatable(true); variable.setMetadataID(id); // TODO: this will cause the variables group to loose it's cache of resolved symbols metadata .getMetadataStore() .addElementToTempGroup(ProcedureReservedWords.VARIABLES, variable.clone()); }