Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected String getRelation(RemoteTableName remoteTableName)
protected String getProjection(List<JdbcColumnHandle> columns)
{
if (columns.isEmpty()) {
return "1";
return "1 x";
}
return columns.stream()
.map(jdbcColumnHandle -> format("%s AS %s", jdbcColumnHandle.toSqlExpression(client::quoted), client.quoted(jdbcColumnHandle.getColumnName())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import java.util.Optional;
import java.util.function.BiFunction;

import static com.google.common.base.Preconditions.checkArgument;
import static com.microsoft.sqlserver.jdbc.SQLServerConnection.TRANSACTION_SNAPSHOT;
import static io.airlift.slice.Slices.wrappedBuffer;
import static io.trino.plugin.jdbc.JdbcErrorCode.JDBC_ERROR;
Expand Down Expand Up @@ -348,11 +347,7 @@ private static Optional<JdbcTypeHandle> toTypeHandle(DecimalType decimalType)
@Override
protected Optional<BiFunction<String, Long, String>> limitFunction()
{
return Optional.of((sql, limit) -> {
String start = "SELECT ";
checkArgument(sql.startsWith(start));
return "SELECT TOP " + limit + " " + sql.substring(start.length());
});
return Optional.of((sql, limit) -> format("SELECT TOP %s * FROM (%s) o", limit, sql));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : Since limit is a long , so can we provide proper format specifier for the same ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i use (we use?) %s for simplicity, unless i want to have type-specific formatting.

}

@Override
Expand Down