Skip to content

Commit

Permalink
reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravsnj committed May 17, 2022
1 parent 40b3f89 commit c272165
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.google.cloud.NoCredentials;
import com.google.cloud.spanner.Database;
import com.google.cloud.spanner.Dialect;
import com.google.cloud.spanner.ErrorCode;
import com.google.cloud.spanner.GceTestEnvConfig;
import com.google.cloud.spanner.IntegrationTestEnv;
Expand Down Expand Up @@ -323,7 +322,9 @@ protected boolean tableExists(Connection connection, String table) {
try (ResultSet rs =
connection.executeQuery(
Statement.newBuilder(
String.format("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE UPPER(TABLE_NAME)=UPPER(\'%s\')", table))
String.format(
"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE UPPER(TABLE_NAME)=UPPER(\'%s\')",
table))
.build())) {
while (rs.next()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ public void appendConnectionUri(StringBuilder uri) {
}

@BeforeClass
public static void setupPostgreSQL(){
database = env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList());;
public static void setupPostgreSQL() {
database = env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList());
;
}


@Before
public void createTestTable() {

try (Connection connection = createConnection()) {
connection.setAutocommit(true);
if (!tableExists(connection, "TEST")) {
Expand All @@ -63,21 +62,20 @@ public void createTestTable() {
connection.runBatch();
}
}

}

@Test
public void testExplainStatement() {
try (ITConnection connection = createConnection()) {
connection.bufferedWrite(
Arrays.asList(
Mutation.newInsertBuilder("TEST").set("ID").to(1L).set("NAME").to("TEST-1").build(),
Mutation.newInsertBuilder("TEST").set("ID").to(2L).set("NAME").to("TEST-2").build()));
Mutation.newInsertBuilder("TEST").set("ID").to(3L).set("NAME").to("TEST-3").build(),
Mutation.newInsertBuilder("TEST").set("ID").to(4L).set("NAME").to("TEST-4").build()));
connection.commit();

ResultSet resultSet =
connection.execute(Statement.of("EXPLAIN SELECT * from TEST")).getResultSet();
while(resultSet.next()){
while (resultSet.next()) {
assertNotNull(resultSet.getString("QUERY PLAN"));
}
assertEquals(1, resultSet.getColumnCount());
Expand All @@ -95,12 +93,11 @@ public void testExplainAnalyzeStatement() {

ResultSet resultSet =
connection.execute(Statement.of("EXPLAIN ANALYZE SELECT * from TEST")).getResultSet();
while(resultSet.next()){
while (resultSet.next()) {
assertNotNull(resultSet.getString("QUERY PLAN"));
assertNotNull(resultSet.getString("EXECUTION STATS"));
}
assertEquals(2, resultSet.getColumnCount());
}
}

}

0 comments on commit c272165

Please sign in to comment.