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

fix(mysql): avoid creating any tables when using .sql() #9363

Merged

Conversation

cpcloud
Copy link
Member

@cpcloud cpcloud commented Jun 12, 2024

Description of changes

This PR fixes an issue with using .sql() with MySQL in environments where the
user doesn't have permission to create tables.

Previously we created a temporary table with zero rows and then used that to
discover types of a query.

In this PR, I use the given zero-row SELECT query to get the types of the columns
using cursor.description along with some low level details of the MySQL protocol.

Inferring types this way doesn't allow getting type information from ad-hoc
types that use plugins, like uuid or inet, so their physical type is used
(string in both those cases).

This seems like an acceptable tradeoff given that without this change .sql()
cannot be used in a whole class of deployments/environments.

Issues closed

Closes #9354.

@cpcloud cpcloud added this to the 9.1 milestone Jun 12, 2024
@cpcloud cpcloud added bug Incorrect behavior inside of ibis mysql The MySQL backend datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) labels Jun 12, 2024
@cpcloud cpcloud force-pushed the mysql-dont-create-table-for-dot-sql branch 2 times, most recently from 906e4bf to 042366c Compare June 12, 2024 13:11
Copy link
Contributor

ACTION NEEDED

Ibis follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message.

Please update your PR title and description to match the specification.

@cpcloud cpcloud changed the title bug(mysql): avoid creating any tables when using .sql() fix(mysql): avoid creating any tables when using .sql() Jun 12, 2024
@cpcloud cpcloud force-pushed the mysql-dont-create-table-for-dot-sql branch from 042366c to 4b5a609 Compare June 12, 2024 13:16
@cpcloud cpcloud requested review from jcrist and gforsyth June 12, 2024 13:41
Copy link
Member

@gforsyth gforsyth left a comment

Choose a reason for hiding this comment

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

:shipit:

@gforsyth gforsyth merged commit d2d5251 into ibis-project:main Jun 12, 2024
75 checks passed
@cpcloud cpcloud deleted the mysql-dont-create-table-for-dot-sql branch June 12, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) mysql The MySQL backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backend.sql() throws error if db user has only read permissions
2 participants