Skip to content

Commit

Permalink
Rename methods to clarify their intent
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and hashhar committed Feb 25, 2022
1 parent 0481899 commit 0ab915a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ protected PreparedQuery prepareQuery(
Map<String, String> columnExpressions,
Optional<JdbcSplit> split)
{
return applyQueryTransformations(table, queryBuilder.prepareQuery(
return applyQueryTransformations(table, queryBuilder.prepareSelectQuery(
this,
session,
connection,
Expand Down Expand Up @@ -976,7 +976,7 @@ public OptionalLong delete(ConnectorSession session, JdbcTableHandle handle)
checkArgument(handle.getSortOrder().isEmpty(), "Unable to delete when sort order is set: %s", handle);
try (Connection connection = connectionFactory.openConnection(session)) {
verify(connection.getAutoCommit());
PreparedQuery preparedQuery = queryBuilder.prepareDelete(this, session, connection, handle.getRequiredNamedRelation(), handle.getConstraint());
PreparedQuery preparedQuery = queryBuilder.prepareDeleteQuery(this, session, connection, handle.getRequiredNamedRelation(), handle.getConstraint());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(this, session, connection, preparedQuery)) {
return OptionalLong.of(preparedStatement.executeUpdate());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DefaultQueryBuilder
private static final String ALWAYS_FALSE = "1=0";

@Override
public PreparedQuery prepareQuery(
public PreparedQuery prepareSelectQuery(
JdbcClient client,
ConnectorSession session,
Connection connection,
Expand Down Expand Up @@ -156,7 +156,7 @@ protected static String formatJoinType(JoinType joinType)
}

@Override
public PreparedQuery prepareDelete(
public PreparedQuery prepareDeleteQuery(
JdbcClient client,
ConnectorSession session,
Connection connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public interface QueryBuilder
{
PreparedQuery prepareQuery(
PreparedQuery prepareSelectQuery(
JdbcClient client,
ConnectorSession session,
Connection connection,
Expand All @@ -48,7 +48,7 @@ PreparedQuery prepareJoinQuery(
Map<JdbcColumnHandle, String> leftAssignments,
Map<JdbcColumnHandle, String> rightAssignments);

PreparedQuery prepareDelete(
PreparedQuery prepareDeleteQuery(
JdbcClient client,
ConnectorSession session,
Connection connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void testNormalBuildSql()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -268,7 +268,7 @@ public void testBuildSqlWithDomainComplement()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(
jdbcClient,
SESSION,
connection,
Expand Down Expand Up @@ -309,7 +309,7 @@ public void testBuildSqlWithFloat()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -343,7 +343,7 @@ public void testBuildSqlWithVarchar()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -379,7 +379,7 @@ public void testBuildSqlWithChar()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -420,7 +420,7 @@ public void testBuildSqlWithDateTime()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -461,7 +461,7 @@ public void testBuildSqlWithTimestamp()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -493,7 +493,7 @@ public void testBuildSqlWithLimit()
Connection connection = database.getConnection();
Function<String, String> function = sql -> sql + " LIMIT 10";

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), TupleDomain.all(), Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), TupleDomain.all(), Optional.empty());
preparedQuery = preparedQuery.transformQuery(function);
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
Expand Down Expand Up @@ -521,7 +521,7 @@ public void testEmptyBuildSql()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(jdbcClient, SESSION, connection, TEST_TABLE, Optional.empty(), columns, Map.of(), tupleDomain, Optional.empty());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(jdbcClient, SESSION, connection, preparedQuery)) {
assertThat(preparedQuery.getQuery()).isEqualTo("" +
"SELECT \"col_0\", \"col_1\", \"col_2\", \"col_3\", \"col_4\", \"col_5\", " +
Expand Down Expand Up @@ -549,7 +549,7 @@ public void testAggregation()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(
jdbcClient,
SESSION,
connection,
Expand Down Expand Up @@ -593,7 +593,7 @@ public void testAggregationWithFilter()

Connection connection = database.getConnection();

PreparedQuery preparedQuery = queryBuilder.prepareQuery(
PreparedQuery preparedQuery = queryBuilder.prepareSelectQuery(
jdbcClient,
SESSION,
connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ public OptionalLong delete(ConnectorSession session, JdbcTableHandle handle)
checkArgument(handle.getSortOrder().isEmpty(), "Unable to delete when sort order is set: %s", handle);
try (Connection connection = connectionFactory.openConnection(session)) {
verify(connection.getAutoCommit());
PreparedQuery preparedQuery = queryBuilder.prepareDelete(this, session, connection, handle.getRequiredNamedRelation(), handle.getConstraint());
PreparedQuery preparedQuery = queryBuilder.prepareDeleteQuery(this, session, connection, handle.getRequiredNamedRelation(), handle.getConstraint());
try (PreparedStatement preparedStatement = queryBuilder.prepareStatement(this, session, connection, preparedQuery)) {
int affectedRowsCount = preparedStatement.executeUpdate();
// In getPreparedStatement we set autocommit to false so here we need an explicit commit
Expand Down

0 comments on commit 0ab915a

Please sign in to comment.