Skip to content

Commit ec1658c

Browse files
chenjian2664ebyhr
authored andcommitted
Remove unnecessary String.format and formatted wrapping
1 parent 4def327 commit ec1658c

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

core/trino-main/src/test/java/io/trino/operator/unnest/TestingUnnesterUtil.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import static com.google.common.base.Verify.verify;
3535
import static io.trino.spi.type.BigintType.BIGINT;
3636
import static java.lang.Math.max;
37-
import static java.lang.String.format;
3837
import static java.util.Objects.requireNonNull;
3938
import static org.assertj.core.api.Assertions.assertThat;
4039

@@ -173,7 +172,7 @@ static Page mergePages(List<Type> types, List<Page> pages)
173172
PageBuilder pageBuilder = new PageBuilder(types);
174173
int totalPositionCount = 0;
175174
for (Page page : pages) {
176-
verify(page.getChannelCount() == types.size(), format("Number of channels in page %d is not equal to number of types %d", page.getChannelCount(), types.size()));
175+
verify(page.getChannelCount() == types.size(), "Number of channels in page %s is not equal to number of types %s", page.getChannelCount(), types.size());
177176

178177
for (int i = 0; i < types.size(); i++) {
179178
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(i);

plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ public ConnectorSplitSource getSplits(ConnectorSession session, JdbcProcedureHan
639639
public Connection getConnection(ConnectorSession session, JdbcSplit split, JdbcTableHandle tableHandle)
640640
throws SQLException
641641
{
642-
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(tableHandle));
642+
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", tableHandle);
643643
return getConnection(session);
644644
}
645645

@@ -673,7 +673,7 @@ public PreparedQuery prepareQuery(
673673
List<JdbcColumnHandle> columns,
674674
Map<String, ParameterizedExpression> columnExpressions)
675675
{
676-
verify(table.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(table));
676+
verify(table.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", table);
677677
try (Connection connection = connectionFactory.openConnection(session)) {
678678
return prepareQuery(session, connection, table, groupingSets, columns, columnExpressions, Optional.empty());
679679
}
@@ -965,7 +965,7 @@ public JdbcOutputTableHandle beginInsertTable(ConnectorSession session, JdbcTabl
965965
SchemaTableName schemaTableName = tableHandle.asPlainTable().getSchemaTableName();
966966
ConnectorIdentity identity = session.getIdentity();
967967

968-
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(tableHandle));
968+
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", tableHandle);
969969
try (Connection connection = connectionFactory.openConnection(session)) {
970970
verify(connection.getAutoCommit());
971971
RemoteIdentifiers remoteIdentifiers = getRemoteIdentifiers(connection);
@@ -1075,7 +1075,7 @@ public void commitCreateTable(ConnectorSession session, JdbcOutputTableHandle ha
10751075
@Override
10761076
public void renameTable(ConnectorSession session, JdbcTableHandle handle, SchemaTableName newTableName)
10771077
{
1078-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1078+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
10791079
RemoteTableName remoteTableName = handle.asPlainTable().getRemoteTableName();
10801080
renameTable(session, remoteTableName.getCatalogName().orElse(null), remoteTableName.getSchemaName().orElse(null), remoteTableName.getTableName(), newTableName);
10811081
}
@@ -1324,7 +1324,7 @@ protected String postProcessInsertTableNameClause(ConnectorSession session, Stri
13241324
@Override
13251325
public void addColumn(ConnectorSession session, JdbcTableHandle handle, ColumnMetadata column, ColumnPosition position)
13261326
{
1327-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1327+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
13281328

13291329
switch (position) {
13301330
case ColumnPosition.First _ -> throw new TrinoException(NOT_SUPPORTED, "This connector does not support adding columns with FIRST clause");
@@ -1364,7 +1364,7 @@ protected void addColumn(ConnectorSession session, Connection connection, Remote
13641364
@Override
13651365
public void renameColumn(ConnectorSession session, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName)
13661366
{
1367-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1367+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
13681368
try (Connection connection = connectionFactory.openConnection(session)) {
13691369
verify(connection.getAutoCommit());
13701370
String newRemoteColumnName = identifierMapping.toRemoteColumnName(getRemoteIdentifiers(connection), newColumnName);
@@ -1389,7 +1389,7 @@ protected void renameColumn(ConnectorSession session, Connection connection, Rem
13891389
@Override
13901390
public void dropColumn(ConnectorSession session, JdbcTableHandle handle, JdbcColumnHandle column)
13911391
{
1392-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1392+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
13931393
try (Connection connection = connectionFactory.openConnection(session)) {
13941394
verify(connection.getAutoCommit());
13951395
String remoteColumnName = identifierMapping.toRemoteColumnName(getRemoteIdentifiers(connection), column.getColumnName());
@@ -1442,7 +1442,7 @@ public void dropNotNullConstraint(ConnectorSession session, JdbcTableHandle hand
14421442
@Override
14431443
public void dropTable(ConnectorSession session, JdbcTableHandle handle)
14441444
{
1445-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1445+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
14461446
dropTable(session, handle.asPlainTable().getRemoteTableName(), false);
14471447
}
14481448

@@ -1537,7 +1537,7 @@ protected String getTableSchemaName(ResultSet resultSet)
15371537
@Override
15381538
public TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle)
15391539
{
1540-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1540+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
15411541
return TableStatistics.empty();
15421542
}
15431543

@@ -1728,7 +1728,7 @@ public String quoted(RemoteTableName remoteTableName)
17281728
@Override
17291729
public Map<String, Object> getTableProperties(ConnectorSession session, JdbcTableHandle tableHandle)
17301730
{
1731-
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(tableHandle));
1731+
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", tableHandle);
17321732
return emptyMap();
17331733
}
17341734

@@ -1739,7 +1739,7 @@ public OptionalLong delete(ConnectorSession session, JdbcTableHandle handle)
17391739
checkArgument(handle.getLimit().isEmpty(), "Unable to delete when limit is set: %s", handle);
17401740
checkArgument(handle.getSortOrder().isEmpty(), "Unable to delete when sort order is set: %s", handle);
17411741
checkArgument(handle.getUpdateAssignments().isEmpty(), "Unable to delete when update assignments are set: %s", handle);
1742-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1742+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
17431743
try (Connection connection = connectionFactory.openConnection(session)) {
17441744
verify(connection.getAutoCommit());
17451745
PreparedQuery preparedQuery = queryBuilder.prepareDeleteQuery(
@@ -1765,7 +1765,7 @@ public OptionalLong update(ConnectorSession session, JdbcTableHandle handle)
17651765
checkArgument(handle.getLimit().isEmpty(), "Unable to update when limit is set: %s", handle);
17661766
checkArgument(handle.getSortOrder().isEmpty(), "Unable to update when sort order is set: %s", handle);
17671767
checkArgument(!handle.getUpdateAssignments().isEmpty(), "Unable to update when update assignments are not set: %s", handle);
1768-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1768+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
17691769
try (Connection connection = connectionFactory.openConnection(session)) {
17701770
verify(connection.getAutoCommit());
17711771
PreparedQuery preparedQuery = queryBuilder.prepareUpdateQuery(
@@ -1788,7 +1788,7 @@ public OptionalLong update(ConnectorSession session, JdbcTableHandle handle)
17881788
@Override
17891789
public void truncateTable(ConnectorSession session, JdbcTableHandle handle)
17901790
{
1791-
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(handle));
1791+
verify(handle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", handle);
17921792
String sql = "TRUNCATE TABLE " + quoted(handle.asPlainTable().getRemoteTableName());
17931793
execute(session, sql);
17941794
}

plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcClient jd
3838
return tableHandle.getColumns().get();
3939
}
4040
checkArgument(tableHandle.isNamedRelation(), "Cannot get columns for %s", tableHandle);
41-
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s".formatted(tableHandle));
41+
verify(tableHandle.getAuthorization().isEmpty(), "Unexpected authorization is required for table: %s", tableHandle);
4242
SchemaTableName schemaTableName = tableHandle.getRequiredNamedRelation().getSchemaTableName();
4343
RemoteTableName remoteTableName = tableHandle.getRequiredNamedRelation().getRemoteTableName();
4444
return jdbcClient.getColumns(session, schemaTableName, remoteTableName);

plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeParquetSchemas.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private static org.apache.parquet.schema.Type buildPrimitiveType(
206206
Type trinoType;
207207
if (primitiveType.startsWith(StandardTypes.DECIMAL)) {
208208
trinoType = typeManager.fromSqlType(primitiveType);
209-
verify(trinoType instanceof DecimalType, "type %s does not map to Trino decimal".formatted(primitiveType));
209+
verify(trinoType instanceof DecimalType, "type %s does not map to Trino decimal", primitiveType);
210210
DecimalType trinoDecimalType = (DecimalType) trinoType;
211211
if (trinoDecimalType.getPrecision() <= 9) {
212212
typeBuilder = Types.primitive(PrimitiveType.PrimitiveTypeName.INT32, repetition);

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ private static List<Integer> applyProjection(ColumnHandle expectedColumnHandle,
783783
private static Integer getIcebergFieldId(OrcColumn column)
784784
{
785785
String icebergId = column.getAttributes().get(ORC_ICEBERG_ID_KEY);
786-
verify(icebergId != null, format("column %s does not have %s property", column, ORC_ICEBERG_ID_KEY));
786+
verify(icebergId != null, "column %s does not have %s property", column, ORC_ICEBERG_ID_KEY);
787787
return Integer.valueOf(icebergId);
788788
}
789789

0 commit comments

Comments
 (0)