@Override protected NavigableMap<String, Procedure> getChildren(Schema s, TransformationMetadata metadata) { return s.getProcedures(); } }
@Override protected NavigableMap<String, Procedure> getChildren(Schema s, TransformationMetadata metadata) { return s.getProcedures(); } }
@Override protected NavigableMap<String, Procedure> getChildren(Schema s, TransformationMetadata metadata) { return s.getProcedures(); } }
public Collection<Procedure> getStoredProcedure(String name) throws TeiidComponentException, QueryMetadataException { List<Procedure> result = new LinkedList<Procedure>(); int index = name.indexOf(TransformationMetadata.DELIMITER_STRING); if (index > -1) { String schemaName = name.substring(0, index); Schema schema = getSchema(schemaName); if (schema != null ) { Procedure proc = schema.getProcedures().get(name.substring(index + 1)); if (proc != null) { result.add(proc); return result; } } } //assume it's a partial name for (Schema schema : getSchemas().values()) { for (Procedure p : schema.getProcedures().values()) { if (matchesPartialName(name, p.getName(), schema)) { result.add(p); } } } return result; }
public Collection<Procedure> getStoredProcedure(String name) throws TeiidComponentException, QueryMetadataException { List<Procedure> result = new LinkedList<Procedure>(); int index = name.indexOf(TransformationMetadata.DELIMITER_STRING); if (index > -1) { String schemaName = name.substring(0, index); Schema schema = getSchema(schemaName); if (schema != null ) { Procedure proc = schema.getProcedures().get(name.substring(index + 1)); if (proc != null) { result.add(proc); return result; } } } //assume it's a partial name for (Schema schema : getSchemas().values()) { for (Procedure p : schema.getProcedures().values()) { if (matchesPartialName(name, p.getName(), schema)) { result.add(p); } } } return result; }
@Override public void setProcedureDefinition(String vdbName, String vdbVersion,String schema, String procName, String definition) { Schema s = getSchema(vdbName, vdbVersion, schema); if (s == null) { return; } Procedure p = s.getProcedures().get(procName); if (p == null) { return; } DdlPlan.alterProcedureDefinition(getVdbRepository().getLiveVDB(vdbName, vdbVersion), p, definition, true); }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
private void addProc(TransformationMetadata metadata, String name, String query, String[] rsCols, String[] rsTypes, String[] params, String[] paramTypes) { Schema pm1 = metadata.getMetadataStore().getSchema("PM1"); //$NON-NLS-1$ pm1.getProcedures().remove(name.toUpperCase()); ColumnSet<Procedure> rs2 = RealMetadataFactory.createResultSet("rs1", rsCols, rsTypes); QueryNode sq2n1 = new QueryNode(query); //$NON-NLS-1$ ArrayList<ProcedureParameter> procParams = new ArrayList<ProcedureParameter>(params.length); for (int i = 0; i < params.length; i++) { procParams.add(RealMetadataFactory.createParameter(params[i], SPParameter.IN, paramTypes[i])); } Procedure sq1 = RealMetadataFactory.createVirtualProcedure(name, pm1, procParams, sq2n1); //$NON-NLS-1$ sq1.setResultSet(rs2); }
public static FunctionTree getFunctionProcedures(Schema schema) { UDFSource dummySource = new UDFSource(Collections.EMPTY_LIST); FunctionTree ft = null; for (Procedure p : schema.getProcedures().values()) { if (p.isFunction() && p.getQueryPlan() != null) { if (ft == null) { ft = new FunctionTree(schema.getName(), dummySource, false); } FunctionMethod fm = SQLParserUtil.createFunctionMethod(p); FunctionDescriptor fd = ft.addFunction(schema.getName(), dummySource, fm, false); fd.setProcedure(p); } } return ft; }
/** * To be called if the MetadataFactory is deserialized to set the canonical system * type value. * @param dt * @param builtin */ public void correctDatatypes(Map<String, Datatype> dt) { this.dataTypes = dt; for (Table t : this.schema.getTables().values()) { correctDataTypes(t.getColumns()); } for (Procedure p : this.schema.getProcedures().values()) { correctDataTypes(p.getParameters()); if (p.getResultSet() != null) { correctDataTypes(p.getResultSet().getColumns()); } } for (FunctionMethod p : this.schema.getFunctions().values()) { correctDataTypes(p.getInputParameters()); } }
public static FunctionTree getFunctionProcedures(Schema schema) { UDFSource dummySource = new UDFSource(Collections.EMPTY_LIST); FunctionTree ft = null; for (Procedure p : schema.getProcedures().values()) { if (p.isFunction() && p.getQueryPlan() != null) { if (ft == null) { ft = new FunctionTree(schema.getName(), dummySource, false); } FunctionMethod fm = SQLParserUtil.createFunctionMethod(p); FunctionDescriptor fd = ft.addFunction(schema.getName(), dummySource, fm, false); fd.setProcedure(p); } } return ft; }
public static FunctionTree getFunctionProcedures(Schema schema) { UDFSource dummySource = new UDFSource(Collections.EMPTY_LIST); FunctionTree ft = null; for (Procedure p : schema.getProcedures().values()) { if (p.isFunction() && p.getQueryPlan() != null) { if (ft == null) { ft = new FunctionTree(schema.getName(), dummySource, false); } FunctionMethod fm = SQLParserUtil.createFunctionMethod(p); FunctionDescriptor fd = ft.addFunction(schema.getName(), dummySource, fm, false); fd.setProcedure(p); } } return ft; }
public void getConnectorMetadata(Connection conn, MetadataFactory metadataFactory) throws SQLException { super.getConnectorMetadata(conn, metadataFactory); for (String name:metadataFactory.getSchema().getTables().keySet()) { if (name.startsWith("ft_")) { Table table = metadataFactory.getSchema().getTable(name); table.setProperty(TVF, "true"); } } for (String name:metadataFactory.getSchema().getProcedures().keySet()) { Procedure proc = metadataFactory.getSchema().getProcedure(name); proc.setProperty(TVF, "true"); } } }
@Test public void testMultipleCommands2() throws Exception { String ddl = " CREATE VIRTUAL PROCEDURE getTweets(query varchar) RETURNS (created_on varchar(25), from_user varchar(25), to_user varchar(25), \n" + " profile_image_url varchar(25), source varchar(25), text varchar(140)) AS \n" + " select tweet.* from \n" + " (call twitter.invokeHTTP(action => 'GET', endpoint =>querystring('',query as \"q\"))) w, \n" + " XMLTABLE('results' passing JSONTOXML('myxml', w.result) columns \n" + " created_on string PATH 'created_at', \n" + " from_user string PATH 'from_user',\n" + " to_user string PATH 'to_user', \n" + " profile_image_url string PATH 'profile_image_url', \n" + " source string PATH 'source', \n" + " text string PATH 'text') tweet;" + " CREATE VIEW Tweet AS select * FROM twitterview.getTweets;"; Schema s = helpParse(ddl, "model").getSchema(); Map<String, Table> tableMap = s.getTables(); Table table = tableMap.get("Tweet"); assertNotNull(table); Map<String, Procedure> procedureMap = s.getProcedures(); Procedure p = procedureMap.get("getTweets"); assertNotNull(p); }
private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) { addOid(schema, map); for (Table table : schema.getTables().values()) { addOid(table, map); addOids(table.getColumns(), map); addOids(table.getAllKeys(), map); } for (Procedure proc : schema.getProcedures().values()) { addOid(proc, map); addOids(proc.getParameters(), map); if (proc.getResultSet() != null) { addOids(proc.getResultSet().getColumns(), map); } } for (FunctionMethod func : schema.getFunctions().values()) { addOid(func, map); addOids(func.getInputParameters(), map); addOid(func.getOutputParameter(), map); } }
private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) { addOid(schema, map); for (Table table : schema.getTables().values()) { addOid(table, map); addOids(table.getColumns(), map); addOids(table.getAllKeys(), map); } for (Procedure proc : schema.getProcedures().values()) { addOid(proc, map); addOids(proc.getParameters(), map); if (proc.getResultSet() != null) { addOids(proc.getResultSet().getColumns(), map); } } for (FunctionMethod func : schema.getFunctions().values()) { addOid(func, map); addOids(func.getInputParameters(), map); addOid(func.getOutputParameter(), map); } }
private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) { addOid(schema, map); for (Table table : schema.getTables().values()) { addOid(table, map); addOids(table.getColumns(), map); addOids(table.getAllKeys(), map); } for (Procedure proc : schema.getProcedures().values()) { addOid(proc, map); addOids(proc.getParameters(), map); if (proc.getResultSet() != null) { addOids(proc.getResultSet().getColumns(), map); } } for (FunctionMethod func : schema.getFunctions().values()) { addOid(func, map); addOids(func.getInputParameters(), map); addOid(func.getOutputParameter(), map); } }
@Test public void testMultipleCommands() throws Exception { String ddl = "CREATE VIEW V1 AS SELECT * FROM PM1.G1; " + "CREATE PROCEDURE FOO(P1 integer) RETURNS (e1 integer, e2 varchar) AS SELECT * FROM PM1.G1;"; Schema s = helpParse(ddl, "model").getSchema(); Map<String, Table> tableMap = s.getTables(); Table table = tableMap.get("V1"); assertNotNull(table); assertEquals("SELECT * FROM PM1.G1", table.getSelectTransformation()); Map<String, Procedure> procedureMap = s.getProcedures(); Procedure p = procedureMap.get("FOO"); assertNotNull(p); assertEquals("SELECT * FROM PM1.G1;", p.getQueryPlan()); }