Skip to content

Sqlalchemy dev POC #30

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

Closed
wants to merge 31 commits into from

Conversation

overcoil
Copy link

@overcoil overcoil commented Aug 10, 2022

What type of PR is this?

  • Feature

Description

This is a barebone dialect together with an expanded integration test that builds on the initial scaffolding. The main add are primary/foreign key support (to ignore them if they're specified) and explicit support for the numeric, string and date/time types.

How is this tested?

  • Unit tests
  • E2E Tests
  • [X ] Manually
  • N/A

I expanded integration.py to cover the scenario of creating and dropping a table with the types.

Related Tickets & Documents

PECO-174

susodapop and others added 30 commits July 7, 2022 17:14
-a bare-bone dialect styled after PyHive and Impyla
-includes minimal/stubs for DatabricksIdentifierPreparer, DatabricksExecutionContext, DatabricksTypeCompiler, & DatabricksCompiler
-bare-bone implementation of dialect
-basic test suite
-sample app (not working)
(secret revoked)
-clean up Makefile for pytest
-explore passing in --requirements to help with suite run
-exploration of DDLCompiler
Signed-off-by: George Chow <[email protected]>
Signed-off-by: George Chow <[email protected]>
id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.7
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this work on other versions of python3 as well? any limitation on the supported python version?

Copy link
Author

Choose a reason for hiding this comment

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

It should. Note that I cribbed from code-quality-checks.yml for this action to test out some ideas. Now that I think about it, this action won't be operative since I've since removed the Pytest test. I will remove this action completely.

(The current plan is to not turn on Github Action in the OSS repo; contributors are encouraged to do so and to use these though.)

Copy link
Author

Choose a reason for hiding this comment

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

Rectified

DATABRICKS_SCHEMA: ${{ secrets.REPOSEC_DATABRICKS_SCHEMA }}

run: |
echo y | dbsqlcli --hostname $DATABRICKS_SERVER_HOSTNAME --http-path $DATABRICKS_HTTP_PATH --access-token $DATABRICKS_TOKEN -e "USE $DATABRICKS_SCHEMA; DROP TABLE IF EXISTS t; DROP TABLE IF EXISTS tabletest; DROP TABLE IF EXISTS integer_table;"
Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens if there are concurrent PRs? are they going to use the same database name and table name and hence one PR CI may fail because of other PR CI writing to the same table?

Copy link
Author

Choose a reason for hiding this comment

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

Refer to my answers to your other comment on this action.

@@ -1,18 +0,0 @@
# Following official SQLAlchemy guide:
Copy link
Collaborator

@moderakh moderakh Aug 12, 2022

Choose a reason for hiding this comment

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

where did this class come from? did we already have some sql-alchemy related code in the main branch?

Copy link
Author

Choose a reason for hiding this comment

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

This was created initially from the rough scaffolding that Jesse and I put together earlier on (commit 0378460). I ended up tossing it after I figured out that I won't be using SA's test suite.

if type_.precision is None:
return "DECIMAL"
elif type_.scale is None:
return "DECIMAL(%(precision)s)" % {"precision": type_.precision}
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we have test covering the methods of this class?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. I will revisit integration.py to include both the default and specified scales.

Copy link
Author

Choose a reason for hiding this comment

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

Rectified.

supports_unicode_statements = True
supports_unicode_binds = True
returns_unicode_strings = True
description_encoding = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's description_encoding?

Copy link
Author

Choose a reason for hiding this comment

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

According to what I found in SA's doc (https://github.com/sqlalchemy/sqlalchemy/blob/main/doc/build/changelog/changelog_05.rst), it "is used for encoding the column name when processing the metadata. This usually defaults to utf-8." I went with "None" as for all the other dialects I studied.


class DatabricksDialect(default.DefaultDialect):
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems src/databricks/sqlalchemy/dialect.py already existed before. Where did this come from?

did we have some sort of support for sqlalchemy dialect previously?

Copy link
Author

Choose a reason for hiding this comment

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

The pre-existing src/databricks/sqlalchemy/dialect.py was a rough scaffolding that Jesse and I put together earlier on (see commit 0378460). I built on this scaffolding.

@susodapop
Copy link
Contributor

Closing in favour of #57 although I will incorporate many of these tests into that PR.

@susodapop susodapop closed this Oct 14, 2022
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