Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSyntaxError: invalid 'part' for EXTRACT/DATE_PART: 'year' #16880

Closed
2 tasks done
s-banach opened this issue Jun 11, 2024 · 1 comment
Closed
2 tasks done

SQLSyntaxError: invalid 'part' for EXTRACT/DATE_PART: 'year' #16880

s-banach opened this issue Jun 11, 2024 · 1 comment
Labels
A-sql Area: Polars SQL functionality

Comments

@s-banach
Copy link
Contributor

s-banach commented Jun 11, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

from datetime import date
import polars as pl

pl.DataFrame({"x": date(2024, 6, 11)}).sql(
    "select date_part(x, 'year') as xy from self"
)

Log output

No response

Issue description

I believe #16767 inadvertently changed the argument order from date_part(column, part) to date_part(part, column).

Expected behavior

Keep working the same.

Installed versions

--------Version info---------
Polars:               1.0.0-alpha.1
Index type:           UInt32       
Platform:             Windows-10-10.0.19045-SP0
Python:               3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:42:31) [MSC v.1937 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            0.10.4
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.8.4
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.2
pyarrow:              16.0.0
pydantic:             2.7.2
pyiceberg:            <not installed>
sqlalchemy:           2.0.30
torch:                2.3.0+cpu
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@s-banach s-banach added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jun 11, 2024
@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jun 12, 2024

That wasn't inadvertent - it's a fix; we accidentally had the DATE_PART parameter order backwards 😅 (I'll put a more explicit note on that PR for clarity).

DATE_PART syntax should be:

date_part(part, column)

Syntax references:

You can use EXTRACT to be consistent across all versions for now.

@alexander-beedie alexander-beedie added A-sql Area: Polars SQL functionality and removed bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql Area: Polars SQL functionality
Projects
None yet
Development

No branches or pull requests

2 participants