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

FR: Adding additional functions in the API library #156

Closed
freedomofnet opened this issue Oct 14, 2020 · 4 comments · Fixed by #219
Closed

FR: Adding additional functions in the API library #156

freedomofnet opened this issue Oct 14, 2020 · 4 comments · Fixed by #219
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@freedomofnet
Copy link

Is your feature request related to a problem? Please describe.

The current Google.cloud.spanner library has very limited functionalities compared to other db libraries (e.g., bigquery) and some of the key APIs are missing. For example,

get_table
table
list_tables
schema
query
execute

I would like to have the above functions added to the library.

Describe the solution you'd like

These functions could be implementable via the INFORMATION_SCHEMA query syntax.

@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Oct 14, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Oct 16, 2020
@larkee larkee added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Oct 21, 2020
@larkee
Copy link
Contributor

larkee commented Nov 4, 2020

Hi there,

Thank you for filing this issue. I've been working on preparing the 2.0.0 release of the library which has blocked me from doing any work on this request. However, that work is nearly complete which means I'll be free for feature work again. As such, I wanted to get some more details on the APIs you mentioned.

Would you be able to explain what the expectation is for each of these APIs and give a code example of the usage? From looking over the BigQuery documentation, it seems the way the APIs are structured is quite different and so I'm not sure having a Table object would make as much sense in Spanner.

As a note, I believe the functionality of query and execute are implemented however the way to call them may differ. For example, this shows how to run a SQL query against a Spanner database:

from google.cloud import spanner

client = spanner.Client()
instance = client.instance('instance-id')
database = instance.database('database-id')

with database.snapshot() as snapshot:
    results = snapshot.execute_sql("SQL QUERY")

    for row in results:
        ...

Please let me know what the intended usage is so I can better consider what the best option is. 👍

@tswast
Copy link
Contributor

tswast commented Nov 21, 2020

Regarding Table, this would map to INFORMATION_SCHEMA queries for fetching table metadata (schema/columns being the most important piece). Perhaps there could be a get_table and list_tables method which just executes relevant information schema queries?

@tswast
Copy link
Contributor

tswast commented Nov 21, 2020

The intended use case is for an Ibis connector, which provides runtime helpers for generating and validating analytical queries.

P.S. I agree that query / execute are a bit nonsensical asks. The existing execute_sql command is sufficient. (I think this was included in the Ibis project scope due to the need to convert the streamed result set into a pandas dataframe: #155)

@larkee
Copy link
Contributor

larkee commented Dec 15, 2020

Thanks for your patience!

As part of the Django connector work, a dbapi adapter was implemented and now lives in this repo under google/cloud/spanner_dbapi. This adapter adds some of the functionalities you mentioned.

Unfortunately, I don't have any cycles to work on any missing methods you may need. However, I am happy to review any PRs you may open in regards to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants