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

bug: to_sql always shows DuckDB SQL for a memtable even if there's a default backend set #9227

Closed
1 task done
gforsyth opened this issue May 21, 2024 · 1 comment · Fixed by #9228
Closed
1 task done
Assignees
Labels
bug Incorrect behavior inside of ibis

Comments

@gforsyth
Copy link
Member

What happened?

[ins] In [1]: import ibis

[ins] In [2]: con = ibis.bigquery.connect(project_id="ibis-gbq", dataset_id="ibis_gbq
         ...: _testing")

[ins] In [3]: ibis.set_backend(con)

[ins] In [4]: t = ibis.memtable({"b": [1, 2]})

[ins] In [5]: ibis.to_sql(t.b.count())
Out[5]: 
SELECT
  COUNT("t0"."b") AS "Count(b)"
FROM "ibis_pandas_memtable_cr5nlla4tffofda5zgamctyks4" AS "t0"

Note the incorrect quotes (should be backticks) -- falling back to DuckDB SQL makes sense, but not when a user has explicitly set the backend.

What version of ibis are you using?

main

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

All

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@gforsyth gforsyth added the bug Incorrect behavior inside of ibis label May 21, 2024
@gforsyth gforsyth self-assigned this May 21, 2024
@gforsyth
Copy link
Member Author

xref #9179
There may be other issues with Oracle table aliases, but this behavior of to_sql is what sent me down a rabbit hole trying to change how we use alias (that may still be necessary).

gforsyth added a commit that referenced this issue May 21, 2024
We weren't passing `use_default=True` when looking for backends in
`to_sql` when no `dialect` was specified.  This worked for nearly all
cases, except when an expression was built from a `memtable`.
A `memtable` doesn't have a specific backend, but if a user has set a
default backend, we should assume that dialect for rendering
sql (instead of our default of DuckDB sql)

Resolves #9227
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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant