Skip to content

Commit

Permalink
Merge branch 'kylin.dev.1' of https://github.com/kylinsoong/teiid
Browse files Browse the repository at this point in the history
Conflicts:
	test-integration/common/src/test/resources/TestSystemVirtualModel/testStoredProcedures.expected
  • Loading branch information
shawkins committed Apr 19, 2016
2 parents 0264c26 + 269d80c commit 3fff51b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions engine/src/main/resources/org/teiid/metadata/SYSADMIN.sql
Expand Up @@ -150,6 +150,15 @@ BEGIN
END

DECLARE string statusTable = (SELECT "value" from SYS.Properties WHERE UID = VARIABLES.uid AND Name = '{http://www.teiid.org/ext/relational/2012}MATVIEW_STATUS_TABLE');

/* statusTable is null hints View is Internal Mat View*/
IF (statusTable IS NULL)
BEGIN
DECLARE string interViewName = loadMatView.schemaName || '.' || loadMatView.viewName;
rowsUpdated = (EXECUTE SYSADMIN.refreshMatView(VARIABLES.interViewName, loadMatView.invalidate));
RETURN rowsUpdated;
END

DECLARE string beforeLoadScript = (SELECT "value" from SYS.Properties WHERE UID = VARIABLES.uid AND Name = '{http://www.teiid.org/ext/relational/2012}MATVIEW_BEFORE_LOAD_SCRIPT');
DECLARE string loadScript = (SELECT "value" from SYS.Properties WHERE UID = VARIABLES.uid AND Name = '{http://www.teiid.org/ext/relational/2012}MATVIEW_LOAD_SCRIPT');
DECLARE string afterLoadScript = (SELECT "value" from SYS.Properties WHERE UID = VARIABLES.uid AND Name = '{http://www.teiid.org/ext/relational/2012}MATVIEW_AFTER_LOAD_SCRIPT');
Expand Down
Expand Up @@ -24,6 +24,7 @@

import static org.junit.Assert.*;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -473,6 +474,20 @@ public void run() {
assertEquals("NEEDS_LOADING", rs.getString("LoadState"));
}

@Test
public void testloadMatViewInternal() throws Exception {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.VIRTUAL);
mmd.addSourceMetadata("DDL", "create view T options (materialized true) as select 1");
server.deployVDB("test", mmd);

Connection c = server.getDriver().connect("jdbc:teiid:test", null);
CallableStatement s = c.prepareCall("call sysadmin.loadMatView('x', 'T', true)");
assertFalse(s.execute());
assertEquals(1, s.getInt(1));
}

@Test public void testInternalWithManagement() throws Exception {
ModelMetaData mmd2 = new ModelMetaData();
mmd2.setName("view1");
Expand Down
@@ -1,6 +1,6 @@
string clob
Name Body
loadMatView Clob[8334]
loadMatView Clob[8594]
matViewStatus Clob[2328]
updateMatView Clob[3020]
Row Count : 3
Expand Down

0 comments on commit 3fff51b

Please sign in to comment.