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

Add LIKE expr support for Postgres, DuckDB and SQLite #17

Merged

Conversation

sgrebnov
Copy link
Collaborator

PR fixes the following error when using LIKE expressions, for example

select * from part where p_type like '%BRASS'

Before:

Error An internal error occurred. Execute '.error' to show details.
sql> .error
Status { code: Internal, message: "External error: Execution error: Unable to generate SQL: Expression not supported p_type LIKE LargeUtf8(\"%BRASS\")", source: None }

After

+-----------+----------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
| p_partkey | p_name                                 | p_mfgr         | p_brand  | p_type                  | p_size | p_container | p_retailprice | p_comment           |
+-----------+----------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
| 2         | blush thistle blue yellow saddle       | Manufacturer#1 | Brand#13 | LARGE BRUSHED BRASS     | 1      | LG CASE     | 902.00        | lar accounts amo    |
| 3         | spring green yellow purple cornsilk    | Manufacturer#4 | Brand#42 | STANDARD POLISHED BRASS | 21     | WRAP CASE   | 903.00        | egular deposits hag |
| 4         | cornflower chocolate smoke green pink  | Manufacturer#3 | Brand#34 | SMALL PLATED BRASS      | 14     | MED DRUM    | 904.00        | p furiously r       |
| 15        | blanched honeydew sky turquoise medium | Manufacturer#1 | Brand#15 | LARGE ANODIZED BRASS    | 45     | LG CASE     | 915.01        | usual ac            |
| 22        | medium forest blue ghost black         | Manufacturer#4 | Brand#43 | PROMO POLISHED BRASS    | 19     | LG DRUM     | 922.02        |  even p             |
+-----------+----------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+

@sgrebnov sgrebnov force-pushed the sgrebnov/like-expr-support branch from c507692 to 0ae743f Compare July 24, 2024 21:54
Copy link
Contributor

@Sevenannn Sevenannn left a comment

Choose a reason for hiding this comment

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

Can this handle the case sensitive like, for example in mysql: LIKE BINARY

@sgrebnov
Copy link
Collaborator Author

Can this handle the case sensitive like, for example in mysql: LIKE BINARY

Good point, going to improve this as LIKE in Postgres is case-sensitive and in sqlite is case insensitive, needs mapping per target engine. To be updated

@sgrebnov sgrebnov changed the title Add LIKE expr support Add LIKE expr support for Postgres, DuckDB and SQLite Jul 25, 2024
@phillipleblanc phillipleblanc merged commit 8fb3b0a into datafusion-contrib:main Jul 25, 2024
2 checks passed
@sgrebnov sgrebnov deleted the sgrebnov/like-expr-support branch August 1, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants