Java Code Examples for org.apache.flink.table.client.gateway.Executor#listDatabases()

The following examples show how to use org.apache.flink.table.client.gateway.Executor#listDatabases() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDropDatabase() throws Exception {
	final Executor executor = createDefaultExecutor(clusterClient);
	final SessionContext session = new SessionContext("test-session", new Environment());
	String sessionId = executor.openSession(session);
	assertEquals("test-session", sessionId);

	executor.executeUpdate(sessionId, "create database db1");

	List<String> actualDatabases = executor.listDatabases(sessionId);
	List<String> expectedDatabases = Arrays.asList("default_database", "db1");
	assertEquals(expectedDatabases, actualDatabases);

	executor.executeUpdate(sessionId, "drop database if exists db1");

	actualDatabases = executor.listDatabases(sessionId);
	expectedDatabases = Arrays.asList("default_database");
	assertEquals(expectedDatabases, actualDatabases);

	executor.closeSession(sessionId);
}
 
Example 2
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testAlterDatabase() throws Exception {
	final Executor executor = createDefaultExecutor(clusterClient);
	final SessionContext session = new SessionContext("test-session", new Environment());
	String sessionId = executor.openSession(session);
	assertEquals("test-session", sessionId);

	executor.executeUpdate(sessionId, "create database db1 comment 'db1_comment' with ('k1' = 'v1')");

	executor.executeUpdate(sessionId, "alter database db1 set ('k1' = 'a', 'k2' = 'b')");

	final List<String> actualDatabases = executor.listDatabases(sessionId);
	final List<String> expectedDatabases = Arrays.asList("default_database", "db1");
	assertEquals(expectedDatabases, actualDatabases);
	//todo: we should compare the new db1 properties after we support describe database in LocalExecutor.

	executor.closeSession(sessionId);
}
 
Example 3
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testListDatabases() throws Exception {
	final Executor executor = createDefaultExecutor(clusterClient);
	final SessionContext session = new SessionContext("test-session", new Environment());

	final List<String> actualDatabases = executor.listDatabases(session);

	final List<String> expectedDatabases = Collections.singletonList("default_database");
	assertEquals(expectedDatabases, actualDatabases);
}
 
Example 4
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testListDatabases() throws Exception {
	final Executor executor = createDefaultExecutor(clusterClient);
	final SessionContext session = new SessionContext("test-session", new Environment());
	String sessionId = executor.openSession(session);
	assertEquals("test-session", sessionId);

	final List<String> actualDatabases = executor.listDatabases(sessionId);

	final List<String> expectedDatabases = Collections.singletonList("default_database");
	assertEquals(expectedDatabases, actualDatabases);

	executor.closeSession(sessionId);
}
 
Example 5
Source File: LocalExecutorITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateDatabase() throws Exception {
	final Executor executor = createDefaultExecutor(clusterClient);
	final SessionContext session = new SessionContext("test-session", new Environment());
	String sessionId = executor.openSession(session);
	assertEquals("test-session", sessionId);

	executor.executeUpdate(sessionId, "create database db1");

	final List<String> actualDatabases = executor.listDatabases(sessionId);
	final List<String> expectedDatabases = Arrays.asList("default_database", "db1");
	assertEquals(expectedDatabases, actualDatabases);

	executor.closeSession(sessionId);
}