presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/JdbcMetadata.java/JdbcMetadata/applyLimit
class JdbcMetadata:    @Override
    public Optional<LimitApplicationResult<ConnectorTableHandle>> applyLimit(ConnectorSession session, ConnectorTableHandle table, long limit)
    {
        JdbcTableHandle handle = (JdbcTableHandle) table;

        if (!jdbcClient.supportsLimit()) {
            return Optional.empty();
        }

        if (handle.getLimit().isPresent() && handle.getLimit().getAsLong() <= limit) {
            return Optional.empty();
        }

        handle = new JdbcTableHandle(
                handle.getSchemaTableName(),
                handle.getCatalogName(),
                handle.getSchemaName(),
                handle.getTableName(),
                handle.getConstraint(),
                OptionalLong.of(limit));

        return Optional.of(new LimitApplicationResult<>(handle, jdbcClient.isLimitGuaranteed()));
    }