@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); }
@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()); }