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

Update snowdialect.py #357

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-kterada
Copy link
Collaborator

Optimizations for table-specific metadata lookups

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    ref: SNOW-689531

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

Refine table-specific metadata lookups to target specific tables instead of searching the entire schema for:
- get_columns()
- get_foreign_keys()
- get_pk_contraints()
- get_unique_constraints()

Please write a short description of how your code change solves the related issue.

Allow SHOW metadata lookups for table-level operations to be table-specific.

@github-actions
Copy link

github-actions bot commented Nov 8, 2022

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
@sfc-gh-aling
@sfc-gh-kterada
You can retrigger this bot by commenting recheck in this Pull Request

@sfc-gh-kterada sfc-gh-kterada marked this pull request as draft November 9, 2022 00:03
Copy link
Collaborator

@sfc-gh-aling sfc-gh-aling left a comment

Choose a reason for hiding this comment

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

appreciate the contribution! the logic looks good to me, however, I think we could improve code reuse a bit more.

src/snowflake/sqlalchemy/snowdialect.py Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
src/snowflake/sqlalchemy/snowdialect.py Outdated Show resolved Hide resolved
Comment on lines 809 to 812
if table_name is not None:
return self._get_table_columns(connection, table_name, schema, **kw)
else:
schema_columns = self._get_schema_columns(connection, schema, **kw)
Copy link
Collaborator

Choose a reason for hiding this comment

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

could be simplified after code reuse

sfc-gh-kterada and others added 21 commits November 19, 2022 23:46
Optimizations for table-specific metadata lookups
Applied lint black formatting changes
Address unit test failures
Additional unit test fixes.
Unit test fixes
Address unit test failures
Address unit test failures
Address unit test failures
Address unit test failures
Address unit test failures
Refactored identification of reserved word table names
lint test failure cleanup attempt
an alternative approach to referencing RESERVED_WORDS
Start addressing native sqlalchemy unit test failures
Implement optimization changes suggested by sfc-gh-aling. Thank you!
@sfc-gh-aling sfc-gh-aling force-pushed the SNOW-689531-optimize-table-metadata-lookups branch from 544c4f5 to bb7965a Compare November 20, 2022 07:56
@codecov-commenter
Copy link

codecov-commenter commented Nov 20, 2022

Codecov Report

Merging #357 (bb7965a) into main (c6d9ab7) will decrease coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #357      +/-   ##
==========================================
- Coverage   80.03%   79.86%   -0.17%     
==========================================
  Files           8        8              
  Lines        1177     1182       +5     
  Branches      186      186              
==========================================
+ Hits          942      944       +2     
- Misses        174      178       +4     
+ Partials       61       60       -1     
Impacted Files Coverage Δ
src/snowflake/sqlalchemy/snowdialect.py 76.74% <100.00%> (-0.55%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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