internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ibis-project/ibis

Issue:
docs: update links to duckdb csv parameters
### Please describe the issue

There are two locations in docstrings where Ibis links to https://duckdb.org/docs/data/csv#parameters. 

- `ibis/expr/api.py`
- `ibis/backends/duckdb/__init__.py`

If you visit this URL in a browser, you get redirected to https://duckdb.org/docs/data/csv/overview.html but are missing the #parameters fragment so you aren't scrolled to the intended section of the page, https://duckdb.org/docs/data/csv/overview.html#parameters. This is because DuckDB changed this URL at some point and, when they set up the redirect, they didn't set it up in such a way as to preserve fragments.

I'll put up a PR in a sec to change the URLs.

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
docs: update links to duckdb csv parameters
### Please describe the issue

There are two locations in docstrings where Ibis links to https://duckdb.org/docs/data/csv#parameters. 

- `ibis/expr/api.py`
- `ibis/backends/duckdb/__init__.py`

If you visit this URL in a browser, you get redirected to https://duckdb.org/docs/data/csv/overview.html but are missing the #parameters fragment so you aren't scrolled to the intended section of the page, https://duckdb.org/docs/data/csv/overview.html#parameters. This is because DuckDB changed this URL at some point and, when they set up the redirect, they didn't set it up in such a way as to preserve fragments.

I'll put up a PR in a sec to change the URLs.

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:

Resolving patch:
diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py
--- a/ibis/backends/duckdb/__init__.py
+++ b/ibis/backends/duckdb/__init__.py
@@ -1364,7 +1364,7 @@ def to_csv(
         header
             Whether to write the column names as the first line of the CSV file.
         **kwargs
-            DuckDB CSV writer arguments. https://duckdb.org/docs/data/csv.html#parameters
+            DuckDB CSV writer arguments. https://duckdb.org/docs/data/csv/overview.html#parameters
 
         """
         self._run_pre_execute_hooks(expr)
diff --git a/ibis/expr/api.py b/ibis/expr/api.py
--- a/ibis/expr/api.py
+++ b/ibis/expr/api.py
@@ -1347,7 +1347,7 @@ def read_csv(
         Backend-specific keyword arguments for the file type. For the DuckDB
         backend used by default, please refer to:
 
-        * CSV/TSV: https://duckdb.org/docs/data/csv#parameters.
+        * CSV/TSV: https://duckdb.org/docs/data/csv/overview.html#parameters.
 
     Returns
     -------


Test patch:
Repository: ibis-project/ibis

Issue:
feat: support empty URL for local backends in ibis.connect()
### Is your feature request related to a problem?

often when testing against multiple backends, myself or a user will do something like:

```python

backend = "polars"

if backend == "polars":
    con = ibis.polars.connect()
...
```

Ibis supports a cleaner `ibis.connect()` that takes a backend-specific URI. those don't make sense for many of the local backends and are currently NotImplemented, but it would be nice for consistency and ease of use to support empty URIs for all of:

- pandas
- polars
- dask
- datafusion

and any others not supported now. should also support #8435 and #7710 once those are in (and any other future local backends)

### Describe the solution you'd like

```python

backend = "polars" # "duckdb" "pandas" "datafusion" "dask"

import ibis

con = ibis.connect(f"{backend}://")
```

adding anything to the URIs could warn or error 

### What version of ibis are you running?

main

### What backend(s) are you using, if any?

duckdb/pandas/datafusion/polars/dask/pyspark

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:

Resolving patch:
diff --git a/ibis/backends/__init__.py b/ibis/backends/__init__.py
--- a/ibis/backends/__init__.py
+++ b/ibis/backends/__init__.py
@@ -1458,5 +1458,21 @@ class NoUrl:
 
     name: str
 
-    def _from_url(self, url: str, **_) -> ir.Table:
-        raise NotImplementedError(self.name)
+    def _from_url(self, url: str, **kwargs) -> BaseBackend:
+        """Connect to the backend with empty url.
+
+        Parameters
+        ----------
+        url : str
+            The URL with which to connect to the backend. This parameter is not used
+            in this method but is kept for consistency.
+        kwargs
+            Additional keyword arguments.
+
+        Returns
+        -------
+        BaseBackend
+            A backend instance
+
+        """
+        return self.connect(**kwargs)


Test patch:
diff --git a/ibis/backends/tests/test_client.py b/ibis/backends/tests/test_client.py
--- a/ibis/backends/tests/test_client.py
+++ b/ibis/backends/tests/test_client.py
@@ -711,12 +711,12 @@ def test_unsigned_integer_type(con, temp_table):
         ),
         param(
             "dask://",
-            marks=[mark.dask, mark.xfail(raises=NotImplementedError)],
+            marks=mark.dask,
             id="dask",
         ),
         param(
             "datafusion://",
-            marks=[mark.datafusion, mark.xfail(raises=NotImplementedError)],
+            marks=mark.datafusion,
             id="datafusion",
         ),
         param(
@@ -731,9 +731,14 @@ def test_unsigned_integer_type(con, temp_table):
         ),
         param(
             "pandas://",
-            marks=[mark.pandas, mark.xfail(raises=NotImplementedError)],
+            marks=mark.pandas,
             id="pandas",
         ),
+        param(
+            "polars://",
+            marks=mark.polars,
+            id="polars",
+        ),
         param(
             "postgres://postgres:postgres@localhost:5432",
             marks=mark.postgres,
Repository: ibis-project/ibis

Issue:
bug: pyspark.connect fails when using databricks-connect
### What happened?

I am unable to create a connection using `ibis.pyspark.connect` using a remote spark session created using `DatabricksSession`

```python
from databricks.connect import DatabricksSession
import ibis

spark = DatabricksSession.builder.getOrCreate()
con = ibis.pyspark.connect(spark) #raises PySparkAttributeError
```

From what I can see, this is because the `session.sparkContext`  attribute is trying to be accessed within `pyspark.Backed.do_connect`

I have tested this by commenting out this call and can successfully create a connection. I can't see any place where this context is specifically used, so I'm not sure if it's strictly required

### What version of ibis are you using?

9.0.0

### What backend(s) are you using, if any?

PySpark

### Relevant log output

```sh
File "/home/****/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3550, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-6ab88d163e5c>", line 8, in <module>
    con = ibis.pyspark.connect(spark)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/****/lib/python3.11/site-packages/ibis/__init__.py", line 108, in connect
    return backend.connect(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/****/lib/python3.11/site-packages/ibis/backends/__init__.py", line 848, in connect
    new_backend.reconnect()
  File "/home/****/lib/python3.11/site-packages/ibis/backends/__init__.py", line 862, in reconnect
    self.do_connect(*self._con_args, **self._con_kwargs)
  File "/home/****/lib/python3.11/site-packages/ibis/backends/pyspark/__init__.py", line 197, in do_connect
    self._context = session.sparkContext
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/****/lib/python3.11/site-packages/pyspark/sql/connect/session.py", line 772, in __getattr__
    raise PySparkAttributeError(
pyspark.errors.exceptions.base.PySparkAttributeError: [JVM_ATTRIBUTE_NOT_SUPPORTED] Attribute `sparkContext` is not supported in Spark Connect as it depends on the JVM. If you need to use this attribute, do not use Spark Connect when creating your session. Visit https://spark.apache.org/docs/latest/sql-getting-started.html#starting-point-sparksession for creating regular Spark Session in detail.
```


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:
Yep, this property looks entirely unused. PR incoming.

Resolving patch:
diff --git a/ibis/backends/pyspark/__init__.py b/ibis/backends/pyspark/__init__.py
--- a/ibis/backends/pyspark/__init__.py
+++ b/ibis/backends/pyspark/__init__.py
@@ -197,7 +197,6 @@ def do_connect(self, session: SparkSession | None = None) -> None:
 
             session = SparkSession.builder.getOrCreate()
 
-        self._context = session.sparkContext
         self._session = session
 
         # Spark internally stores timestamps as UTC values, and timestamp data


Test patch:
Repository: ibis-project/ibis

Issue:
docs: improvements to the home page
The Ibis project home page is better than it once was [citation needed], but
can use some improvements. In particular, it'd be great if we could have an
[interactive demo similar to
DuckDB's](https://shell.duckdb.org/#queries=v0,%20%20-Create-table-from-Parquet-file%0ACREATE-TABLE-train_services-AS%0A----FROM-'s3%3A%2F%2Fduckdb%20blobs%2Ftrain_services.parquet'~,%20%20-Get-the-top%203-busiest-train-stations%0ASELECT-station_name%2C-count(*)-AS-num_services%0AFROM-train_services%0AGROUP-BY-ALL%0AORDER-BY-num_services-DESC%0ALIMIT-3~).
This would required [PyArrow in
Pyodide](https://github.com/pyodide/pyodide/issues/2933) as the last blocker, I
think.

Regardless, we should ensure the landing page answers to a new/prospective user:

- What is Ibis?
- Why should I use Ibis?
- Confidence Ibis is a well-supported, production-ready library

Unfortunately, this may involve more HTML/CSS than I'm conformtable doing but
we'll figure something out.




Discussion:

Resolving patch:
diff --git a/docs/backends_sankey.py b/docs/backends_sankey.py
--- a/docs/backends_sankey.py
+++ b/docs/backends_sankey.py
@@ -94,7 +94,7 @@ def to_greyish(hex_code, grey_value=128):
 
 fig.update_layout(
     title_text="Ibis backend types",
-    font_size=24,
+    font_size=20,
     # font_family="Arial",
     title_font_size=30,
     margin=dict(l=30, r=30, t=80, b=30),


Test patch:
Repository: ibis-project/ibis

Issue:
feat: allow to connect to a duckdb named in-memory database
### Is your feature request related to a problem?

_No response_

### What is the motivation behind your request?

_No response_

### Describe the solution you'd like

I'd like to be able to use a named in-memory database `:memory:mydb` with the DuckDB backend.
This allows to create multiple connections to the same database for parallel reads.

### What version of ibis are you running?

9.0.0

### What backend(s) are you using, if any?

DuckDB

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:

Resolving patch:
diff --git a/ibis/backends/duckdb/__init__.py b/ibis/backends/duckdb/__init__.py
--- a/ibis/backends/duckdb/__init__.py
+++ b/ibis/backends/duckdb/__init__.py
@@ -454,10 +454,8 @@ def do_connect(
         <ibis.backends.duckdb.Backend object at ...>
 
         """
-        if (
-            not isinstance(database, Path)
-            and database != ":memory:"
-            and not database.startswith(("md:", "motherduck:"))
+        if not isinstance(database, Path) and not database.startswith(
+            ("md:", "motherduck:", ":memory:")
         ):
             database = Path(database).absolute()
 


Test patch:
Repository: django-cms/django-filer

Issue:
Exception on Cyrillic search
I noticed that when i try to do a search with Cyrillic string, exception is thrown:

Traceback:
File "/projects/ecity/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
1.                             response = middleware_method(request, e)
   File "/projects/ecity/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
2.                         response = callback(request, _callback_args, *_callback_kwargs)
   File "/projects/ecity/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
3.                     response = view_func(request, _args, *_kwargs)
   File "/projects/ecity/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
4.         response = view_func(request, _args, *_kwargs)
   File "/projects/ecity/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
5.             return view(request, _args, *_kwargs)
   File "/projects/ecity/site/app/filer/admin/folderadmin.py" in directory_listing
6.                 'q': urllib.quote_plus(q),
   File "/usr/lib/python2.7/urllib.py" in quote_plus
7.     return quote(s, safe)
   File "/usr/lib/python2.7/urllib.py" in quote
8.     return ''.join(map(quoter, s))

Exception Type: KeyError at /admin/filer/folder/
Exception Value: u'\u043f

<!---
@huboard:{"order":230.0}
-->



Discussion:

Resolving patch:
diff --git a/filer/admin/folderadmin.py b/filer/admin/folderadmin.py
--- a/filer/admin/folderadmin.py
+++ b/filer/admin/folderadmin.py
@@ -4,6 +4,7 @@
 from django.contrib import admin
 from django.contrib.admin import helpers
 from django.contrib.admin.util import quote, unquote, capfirst
+from django.template.defaultfilters import urlencode
 from filer.admin.patched.admin_utils import get_deleted_objects
 from django.core.exceptions import PermissionDenied
 from django.core.paginator import Paginator, InvalidPage, EmptyPage
@@ -232,7 +233,7 @@ def filter_file(qs, terms=[]):
             return qs
         q = request.GET.get('q', None)
         if q:
-            search_terms = urllib.unquote_plus(q).split(" ")
+            search_terms = unquote(q).split(" ")
         else:
             search_terms = []
             q = ''
@@ -363,7 +364,7 @@ def filter_file(qs, terms=[]):
                 'current_url': request.path,
                 'title': u'Directory listing for %s' % folder.name,
                 'search_string': ' '.join(search_terms),
-                'q': urllib.quote_plus(q),
+                'q': urlencode(q),
                 'show_result_count': show_result_count,
                 'limit_search_to_folder': limit_search_to_folder,
                 'is_popup': popup_status(request),


Test patch:
Repository: django-cms/django-filer

Issue:
Remove duplicate attributes from passed kwargs
Duplicate attributes were being passed to these models at import time through the kwargs. 



Discussion:

Resolving patch:
diff --git a/filer/fields/file.py b/filer/fields/file.py
--- a/filer/fields/file.py
+++ b/filer/fields/file.py
@@ -1,14 +1,14 @@
 #-*- coding: utf-8 -*-
-import inspect
+import warnings
+
 from django import forms
-from django.conf import settings as globalsettings
 from django.contrib.admin.widgets import ForeignKeyRawIdWidget
 from django.contrib.admin.sites import site
-from django.core.exceptions import ImproperlyConfigured
 from django.core.urlresolvers import reverse
 from django.db import models
 from django.template.loader import render_to_string
 from django.utils.safestring import mark_safe
+
 from filer.utils.compatibility import truncate_words
 from filer.models import File
 from filer import settings as filer_settings
@@ -110,9 +110,13 @@ class FilerFileField(models.ForeignKey):
 
     def __init__(self, **kwargs):
         # we call ForeignKey.__init__ with the Image model as parameter...
-        # a FilerImageFiled can only be a ForeignKey to a Image
-        return super(FilerFileField, self).__init__(
-            self.default_model_class, **kwargs)
+        # a FilerImageField can only be a ForeignKey to a Image
+        if "to" in kwargs.keys():
+            kwargs.pop("to")
+            warnings.warn("FilerImageField can only be a ForeignKey to a Image;"
+                          "%s passed" % kwargs['to'], SyntaxWarning)
+        return super(FilerFileField, self).__init__(self.default_model_class,
+                                                    **kwargs)
 
     def formfield(self, **kwargs):
         # This is a fairly standard way to set up some defaults
diff --git a/filer/fields/multistorage_file.py b/filer/fields/multistorage_file.py
--- a/filer/fields/multistorage_file.py
+++ b/filer/fields/multistorage_file.py
@@ -3,10 +3,13 @@
 import hashlib
 import warnings
 from io import BytesIO
+
 from django.core.files.base import ContentFile
 from django.utils import six
-from easy_thumbnails import fields as easy_thumbnails_fields, \
-    files as easy_thumbnails_files
+
+from easy_thumbnails import (fields as easy_thumbnails_fields,
+                             files as easy_thumbnails_files)
+
 from filer import settings as filer_settings
 from filer.utils.filer_easy_thumbnails import ThumbnailerNameMixin
 
@@ -97,6 +100,10 @@ class MultiStorageFileField(easy_thumbnails_fields.ThumbnailerField):
 
     def __init__(self, verbose_name=None, name=None,
                  storages=None, thumbnail_storages=None, thumbnail_options=None, **kwargs):
+        if 'upload_to' in kwargs:
+            kwargs.pop("to")
+            warnings.warn("MultiStorageFileField can handle only File objects;"
+                          "%s passed" % kwargs['to'], SyntaxWarning)
         self.storages = storages or STORAGES
         self.thumbnail_storages = thumbnail_storages or THUMBNAIL_STORAGES
         self.thumbnail_options = thumbnail_options or THUMBNAIL_OPTIONS


Test patch:
Repository: django-cms/django-filer

Issue:
A lot of file descriptors usage
I have a problem with performance on my current project. 
While I started to search a problem, I sighted that uWSGI process of this project holds much more file descriptors than other projects. There's something around 1000 opened files, while even no one on the site at this time, and all of these files are pictures in media/filer_public.

I don't know whether it's my bottleneck or not. But I need an advice, is it a normal behaviour?



Discussion:
Thumbnailing does produce a lot of file access, but the files should not remain open if there are no active requests. Are the open files the original uploads or are they thumbnails?

I think there are original files. This is how uWSGI lsof looks like: https://gist.github.com/chuwy/d7c8c879aa640920ea6f

hmmm... looks like there might be a file discriptor leak somewhere. What version of filer are you using?

Till yesterday I used filer from git, and now I'm using filer 0.9.4 (howewer there's no much difference, as far as I know) and cmsplugin-filer 0.9.5. I didn't try to rollback filer, but already tried all versions of other software (django, django-cms, uwsgi).

I just tried this on one of our servers. It seems using just filer alone does not leak the open files. But as soon as I place an Image-plugin on a django-cms page, the the selected image seems to stay open.

So probably an issue in django-cms or cmsplugin-filer.
(I tested this with `django-filer==0.9.4`, `cmsplugin-filer==0.9.5` and `django-cms==2.4.0.rc1`)

So, you'd recreated error? What should we do now?

Confirmed on latest filer / cmsplugin_filer / django CMS develop

I've been able to solve this by passing into cmsplugin_filer context an Image instance loaded from the database instead of the object related to the plugin model.
e.g.:

```
    context.update({
        'image': Image.objects.get(pk=instance.image.pk),
        'instance': instance,
        'link': instance.link,
        'opts': options,
        'size': options.get('size',None),
        'placeholder': placeholder
    })
```

instead of just

```
    context.update({
        'instance': instance,
        'link': instance.link,
        'opts': options,
        'size': options.get('size',None),
        'placeholder': placeholder
    })
```

And modifying the template accordingly.

A leak in `FilerImageField`?

Maybe it has something to do with the multi storage file field.

Strange is: models different from plugin models are not affected (apparently)


Resolving patch:
diff --git a/filer/models/imagemodels.py b/filer/models/imagemodels.py
--- a/filer/models/imagemodels.py
+++ b/filer/models/imagemodels.py
@@ -194,7 +194,7 @@ def thumbnails(self):
     @property
     def easy_thumbnails_thumbnailer(self):
         tn = FilerThumbnailer(
-            file=self.file.file, name=self.file.name,
+            file=self.file, name=self.file.name,
             source_storage=self.file.source_storage,
             thumbnail_storage=self.file.thumbnail_storage,
             thumbnail_basedir=self.file.thumbnail_basedir)


Test patch:
Repository: django-cms/django-filer

Issue:
ServerBase save_as parameter has confusing values
`ServerBase.save_as_header` accepts `save_as` parameter to insert `Content-Disposition=attachment` header; `save_as` parameter is used to control the filename in the header.
As of now it accepts three values:
- `False`: header is not sent
- _any string_: header is sent with _any string_ as filename
- `None`: header is sent with the filename from the file path

A `True` value in the last case maybe would be a clearer value.

<!---
@huboard:{"order":172.875}
-->



Discussion:

Resolving patch:
diff --git a/filer/server/backends/base.py b/filer/server/backends/base.py
--- a/filer/server/backends/base.py
+++ b/filer/server/backends/base.py
@@ -23,17 +23,18 @@ def save_as_header(self, response, **kwargs):
         """
         * if save_as is False the header will not be added
         * if save_as is a filename, it will be used in the header
-        * if save_as is None the filename will be determined from the file path
+        * if save_as is True or None the filename will be determined from the
+          file path
         """
         save_as = kwargs.get('save_as', None)
         if save_as == False:
             return
         file_obj = kwargs.get('file_obj', None)
         filename = None
-        if save_as:
-            filename = save_as
-        else:
+        if save_as is True or save_as is None:
             filename = os.path.basename(file_obj.path)
+        else:
+            filename = save_as
         response['Content-Disposition'] = smart_str('attachment; filename=%s' % filename)
 
     def size_header(self, response, **kwargs):


Test patch:
diff --git a/filer/tests/server_backends.py b/filer/tests/server_backends.py
--- a/filer/tests/server_backends.py
+++ b/filer/tests/server_backends.py
@@ -30,6 +30,7 @@ def setUp(self):
     def tearDown(self):
         self.filer_file.delete()
 
+
 class DefaultServerTestCase(BaseServerBackendTestCase):
     def test_normal(self):
         server = DefaultServer()
@@ -38,6 +39,19 @@ def test_normal(self):
         response = server.serve(request, self.filer_file.file)
         self.assertTrue(response.has_header('Last-Modified'))
 
+    def test_save_as(self):
+        server = DefaultServer()
+        request = Mock()
+        request.META = {}
+        response = server.serve(request, self.filer_file.file, save_as=True)
+        self.assertEqual(response['Content-Disposition'], 'attachment; filename=testimage.jpg')
+
+        response = server.serve(request, self.filer_file.file, save_as=False)
+        self.assertFalse(response.has_header('Content-Disposition'))
+
+        response = server.serve(request, self.filer_file.file, save_as='whatever.png')
+        self.assertEqual(response['Content-Disposition'], 'attachment; filename=whatever.png')
+
     def test_not_modified(self):
         server = DefaultServer()
         request = Mock()