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

Add ACTIVATE_VERSION message support #607

Closed
wants to merge 149 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
1766025
archival comment
aaronsteers Mar 31, 2021
7190619
copy catalog helpers from `development` branch
Apr 1, 2021
4703b47
update from main
aaronsteers Aug 27, 2021
1d51d48
resolve merge conflicts
aaronsteers Aug 27, 2021
f8d4dcd
refactor to 3 classes
aaronsteers Aug 27, 2021
ea6f93f
remove TODO comment
aaronsteers Aug 27, 2021
e9e2b0b
cleanup jsonschema methods
aaronsteers Aug 27, 2021
7d1e5db
add sqlalchemy
aaronsteers Sep 1, 2021
44f09fd
add to_jsonschema_type()
aaronsteers Sep 1, 2021
d9756d7
refactor database classes
aaronsteers Sep 1, 2021
03900de
fix typing
aaronsteers Sep 1, 2021
c3a7460
consolidate classes
aaronsteers Sep 2, 2021
a842a86
fix declared type
aaronsteers Sep 2, 2021
4012412
fix property refs
aaronsteers Sep 2, 2021
74f33b6
fix sqlalchemy refs
aaronsteers Sep 2, 2021
1a24c27
fix discovery
aaronsteers Sep 2, 2021
253e138
fix selection bug
aaronsteers Sep 2, 2021
ae7cfa9
remove extra classes
aaronsteers Sep 2, 2021
6443614
add to docs
aaronsteers Sep 2, 2021
4580574
declare SQLStream at top level
aaronsteers Sep 2, 2021
6a00468
lint wip
aaronsteers Sep 2, 2021
059f7fb
update warning message
aaronsteers Sep 2, 2021
879b0db
fix docstr
aaronsteers Sep 2, 2021
4611726
docstring linting
aaronsteers Sep 2, 2021
57bef1a
mypy ignore sqlalchemy
aaronsteers Sep 2, 2021
31b8eb7
smart catalog generation for SQLStream class
aaronsteers Sep 14, 2021
4c45a4a
merge from main
aaronsteers Oct 7, 2021
bb573e9
fix click choice
aaronsteers Oct 7, 2021
6834632
Merge remote-tracking branch 'origin/main' into 74-database-type-streams
aaronsteers Oct 7, 2021
b5fb14f
Merge branch 'main' into 74-database-type-streams
aaronsteers Oct 12, 2021
e3ae6e9
add option for connection reuse
aaronsteers Oct 12, 2021
19146c2
migrate to new classes
aaronsteers Oct 12, 2021
7800382
improved fully_qualified_name
aaronsteers Oct 12, 2021
ff3feba
poetry update
aaronsteers Oct 12, 2021
9afe77b
fix connection declaration
aaronsteers Oct 12, 2021
ccc7e50
Merge branch 'main' into 74-database-type-streams
aaronsteers Oct 29, 2021
f2ee8d9
add SQLTap class
aaronsteers Oct 29, 2021
5173ee6
fix docstring
aaronsteers Oct 29, 2021
7b9406b
refactor classmethods into SQLConnector class
aaronsteers Oct 29, 2021
4bfe213
update and sort imports
aaronsteers Oct 29, 2021
3c3c123
invoke discovery from connector
aaronsteers Oct 29, 2021
9ea28d1
sql.py rename, refactoring
aaronsteers Oct 29, 2021
ccdf474
unused import
aaronsteers Oct 29, 2021
6bc9dbd
update cookiecutter for sql source
aaronsteers Oct 29, 2021
a125e11
add sqlite unit test
aaronsteers Oct 29, 2021
b0206ae
fix spellings, types
aaronsteers Oct 29, 2021
08e265a
bugfix in Metadata.from_dict()
aaronsteers Oct 29, 2021
29cdb2e
fixed tests
aaronsteers Oct 29, 2021
0bf3021
add SQLite sample
aaronsteers Oct 29, 2021
113152b
rename to get_sqlalchemy_url
aaronsteers Oct 31, 2021
978eb47
improve docstrings
aaronsteers Nov 1, 2021
0016c7a
refactor sinks to separate files
aaronsteers Nov 2, 2021
6497c18
Merge remote-tracking branch 'origin/264-break-out-sink-classes-to-se…
aaronsteers Nov 2, 2021
2688c64
start sql sink class
aaronsteers Nov 2, 2021
e2f400b
cleanup methods and docstrings
aaronsteers Nov 5, 2021
c249559
add SQLTarget class
aaronsteers Nov 5, 2021
7c05767
start sqlite target tests
aaronsteers Nov 5, 2021
674424c
update sink with SQL classes
aaronsteers Nov 5, 2021
af42e0b
sql alchemy data types for streams
aaronsteers Nov 5, 2021
e0540ff
sort imports
aaronsteers Nov 9, 2021
b345413
expand class docstrings
aaronsteers Nov 9, 2021
b86f33c
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 9, 2021
a48c65e
expand sqlconnector capabilities
aaronsteers Nov 9, 2021
924f83c
continued sink iteration
aaronsteers Nov 9, 2021
933e087
remove unused import
aaronsteers Nov 9, 2021
6e81ca1
lint fixes
aaronsteers Nov 9, 2021
67ece7d
update tests
aaronsteers Nov 16, 2021
ff5a45a
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 16, 2021
0b384f7
fix typing
aaronsteers Nov 16, 2021
0c24c23
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 16, 2021
0a08aa5
autoformat
aaronsteers Nov 16, 2021
7bd0e07
cherry pick black bump (d7b98bc6)
aaronsteers Nov 16, 2021
878f1f8
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 16, 2021
b0e5084
ignore simpleeval in black
aaronsteers Nov 16, 2021
afccec0
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 16, 2021
bec817b
Merge remote-tracking branch 'origin/main' into 74-database-type-streams
aaronsteers Nov 18, 2021
c453d85
poetry lock
aaronsteers Nov 18, 2021
07a9539
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 18, 2021
d64430f
add typical overrides to cookiecutter
aaronsteers Nov 19, 2021
d4597f3
specify "SQL" as extra
aaronsteers Nov 23, 2021
d6e7790
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 23, 2021
a1eaf53
update bump version, tap cookiecutter extras logic
aaronsteers Nov 24, 2021
c2536d9
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Nov 24, 2021
4e37e69
target cookiecutter
aaronsteers Nov 24, 2021
d41493b
Apply 1 suggestion(s) to 1 file(s)
Dec 7, 2021
d961820
Merge remote-tracking branch 'origin/main' into 74-database-type-streams
aaronsteers Dec 7, 2021
3817431
add comment
aaronsteers Dec 7, 2021
8f86cba
move test
aaronsteers Dec 7, 2021
e83237b
delete old test config templates
aaronsteers Dec 7, 2021
1052f13
move sample
aaronsteers Dec 7, 2021
7bcc36c
remove 'extras' declaration for sqlalchemy
aaronsteers Dec 7, 2021
703d5f3
isort
aaronsteers Dec 7, 2021
3564caa
add SQLTap doc
aaronsteers Dec 7, 2021
9e41dde
add SQLTap to index
aaronsteers Dec 7, 2021
f35870e
added comment about stream_results=True default
aaronsteers Dec 8, 2021
a790fd4
convert methods as static
aaronsteers Dec 8, 2021
62f3b48
update to_sql_type() docstring
aaronsteers Dec 8, 2021
a468903
add to_sql_type() conversion
aaronsteers Dec 10, 2021
ac0df6d
add constrained columns lookup
aaronsteers Dec 10, 2021
6ce78a6
add incremental logic and bookmark usage
aaronsteers Dec 10, 2021
cb168f2
add notes re: addl_replication_methods
aaronsteers Dec 10, 2021
45b750e
remove extra import
aaronsteers Dec 10, 2021
7127c8d
update comments, add logger
aaronsteers Dec 10, 2021
767a8a5
add comments, improve ordering of discovery method
aaronsteers Dec 10, 2021
029c5de
fix lru cache ref for py<=3.7
aaronsteers Dec 10, 2021
276dd47
Merge remote-tracking branch 'origin/main' into 74-database-type-streams
aaronsteers Dec 10, 2021
09ee0ce
proper primary key detection, with tests
aaronsteers Dec 10, 2021
4441bfe
add SQLConnector to docs
aaronsteers Dec 10, 2021
21d4042
add tests for sql type conversions
aaronsteers Dec 10, 2021
2c01f94
fix hardcoded library name
aaronsteers Dec 10, 2021
38591bf
improve type handling, remove handling for generic python types
aaronsteers Dec 10, 2021
304db6d
cleaner type checking
aaronsteers Dec 10, 2021
16cfb0c
improved type handling
aaronsteers Dec 10, 2021
6b48846
revert extras syntax
aaronsteers Dec 11, 2021
32707bf
Merge remote-tracking branch 'origin/main' into 74-database-type-streams
aaronsteers Dec 14, 2021
026a925
Merge branch '74-database-type-streams' into 263-sql-type-targets-and…
aaronsteers Dec 14, 2021
b8bca10
update docstring for clarity
aaronsteers Dec 14, 2021
08ea54c
add target-sqlite sample
aaronsteers Dec 14, 2021
f6852be
refactor end-to-end tests into testing module
aaronsteers Dec 14, 2021
f99aa92
add sqlite end-to-end test
aaronsteers Dec 14, 2021
234085d
auto-reset the tap_stdout buffer
aaronsteers Dec 14, 2021
d67a99f
lint fixes
aaronsteers Dec 14, 2021
073f48b
more robust log
aaronsteers Dec 14, 2021
77de7a5
isort
aaronsteers Dec 14, 2021
5eb8611
improve initialization
aaronsteers Dec 14, 2021
bc0db1a
improved tests
aaronsteers Dec 14, 2021
7480096
add docstring
aaronsteers Dec 14, 2021
3de5d37
add SQLSink 'create table' and 'bulk insert'
aaronsteers Dec 15, 2021
a1c9e2d
improve connector capabilities
aaronsteers Dec 15, 2021
0075ca5
improved tests
aaronsteers Dec 15, 2021
cf381f0
lint fixes
aaronsteers Dec 15, 2021
b03ea7e
cleanup SQLSink
aaronsteers Dec 15, 2021
16380df
declare deleted_at at top of method
aaronsteers Dec 15, 2021
01055df
export SQLConnector
aaronsteers Dec 16, 2021
85eed72
fix missing import
aaronsteers Dec 16, 2021
c229674
add ACTIVATE_VERSION support
aaronsteers Dec 16, 2021
fce2e1d
adds ACTIVATE_VERSION message support
aaronsteers Dec 16, 2021
8e1b3e2
lint fix
aaronsteers Dec 17, 2021
8297a97
use Stream._sync_start_time in signpost and table version
aaronsteers Jan 7, 2022
4bab76e
remove stream_table_version property
aaronsteers Jan 7, 2022
271cd0c
Merge basic SQL targets support from MR !200
Jan 18, 2022
2bd7d37
Merge basic SQL targets support from MR !200, #263
Jan 18, 2022
be2095b
Merge branch '74-database-type-streams' into aj-activate_version-support
aaronsteers Jan 18, 2022
0f92a57
fix isort
aaronsteers Jan 18, 2022
d752685
update from upstream mr
aaronsteers Jan 18, 2022
b92fc2a
remove dupe fixture
aaronsteers Jan 18, 2022
ff0a82d
update _sync_start_time handling
aaronsteers Jan 18, 2022
369be66
isort
aaronsteers Jan 18, 2022
9b23bff
fix types, update versions
aaronsteers Jan 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ replace = singer-sdk = "^{new_version}"

[bumpversion:file:cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml]
search = singer-sdk = "^{current_version}"
replace = singer-sdk = "^{new_version}"
replace = singer-sdk = "^{new_version}"
1 change: 1 addition & 0 deletions cookiecutter/tap-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"stream_type": [
"REST",
"GraphQL",
"SQL",
"Other"
],
"auth_method": [
Expand Down
5 changes: 5 additions & 0 deletions cookiecutter/tap-template/cookiecutter.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ tests:
auth_method: JWT
include_cicd_sample_template: "None (Skip)"

- source_name: SQLTemplateTest
tap_id: test-tap-sql-type
stream_type: SQL
auth_method: Custom or N/A

- source_name: OtherCustomTemplateTest
tap_id: test-tap-other-custom-type
stream_type: Other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

from typing import List

from singer_sdk import Tap, Stream
from singer_sdk import {{ 'SQL' if cookiecutter.stream_type == 'SQL' else '' }}Tap, {{ 'SQL' if cookiecutter.stream_type == 'SQL' else '' }}Stream
from singer_sdk import typing as th # JSON schema typing helpers

{%- if cookiecutter.stream_type == "SQL" %}
from {{ cookiecutter.library_name }}.client import {{ cookiecutter.source_name }}Stream
{%- else %}
# TODO: Import your custom stream types here:
from {{ cookiecutter.library_name }}.streams import (
{{ cookiecutter.source_name }}Stream,
Expand All @@ -13,6 +16,7 @@
GroupsStream,
{%- endif %}
)
{%- endif %}

{%- if cookiecutter.stream_type in ("GraphQL", "REST", "Other") %}
# TODO: Compile a list of custom stream types here
Expand All @@ -24,7 +28,7 @@
{%- endif %}


class Tap{{ cookiecutter.source_name }}(Tap):
class Tap{{ cookiecutter.source_name }}({{ 'SQL' if cookiecutter.source_name == 'SQL' else '' }}Tap):
"""{{ cookiecutter.source_name }} tap class."""
name = "{{ cookiecutter.tap_id }}"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""SQL client handling.

This includes {{ cookiecutter.source_name }}Stream and {{ cookiecutter.source_name }}Connector.
"""

import sqlalchemy

from singer_sdk import SQLConnector, SQLStream

class {{ cookiecutter.source_name }}Connector(SQLConnector):
"""Connects to the {{ cookiecutter.source_name }} SQL source."""

def get_sqlalchemy_url(cls, config: dict) -> str:
"""Concatenate a SQLAlchemy URL for use in connecting to the source."""
# TODO: Replace this with a valid connection string for your source:
return (
f"awsathena+rest://{config['aws_access_key_id']}:"
f"{config['aws_secret_access_key']}@athena"
f".{config['aws_region']}.amazonaws.com:443/"
f"{config['schema_name']}?"
f"s3_staging_dir={config['s3_staging_dir']}"
)

@staticmethod
def to_jsonschema_type(sql_type: sqlalchemy.types.TypeEngine) -> dict:
"""Returns a JSON Schema equivalent for the given SQL type.

Developers may optionally add custom logic before calling the default implementation
inherited from the base class.
"""
# Optionally, add custom logic before calling the super().
# You may delete this method if overrides are not needed.
return super().to_jsonschema_type(sql_type)

@staticmethod
def to_sql_type(jsonschema_type: dict) -> sqlalchemy.types.TypeEngine:
"""Returns a JSON Schema equivalent for the given SQL type.

Developers may optionally add custom logic before calling the default implementation
inherited from the base class.
"""
# Optionally, add custom logic before calling the super().
# You may delete this method if overrides are not needed.
return super().to_sql_type(jsonschema_type)


class {{ cookiecutter.source_name }}Stream(SQLStream):
"""Stream class for {{ cookiecutter.source_name }} streams."""

connector_class = {{ cookiecutter.source_name }}Connector


def get_records(self, partition: Optional[dict]) -> Iterable[Dict[str, Any]]:
"""Return a generator of row-type dictionary objects.

Developers may optionally add custom logic before calling the default implementation
inherited from the base class.

Args:
partition: If provided, will read specifically from this data slice.

Yields:
One dict per record.
"""
# Optionally, add custom logic instead of calling the super().
# This is helpful if the source database provides batch-optimized record retreival.
# If no overrides or optimizations are needed, you may delete this method.
yield from super().get_records(partition)
2 changes: 1 addition & 1 deletion cookiecutter/target-template/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"admin_name": "FirstName LastName",
"target_id": "target-{{ cookiecutter.destination_name.lower() }}",
"library_name": "{{ cookiecutter.target_id.replace('-', '_') }}",
"serialization_method": ["Per record", "Per batch"]
"serialization_method": ["Per record", "Per batch", "SQL"]
}
3 changes: 3 additions & 0 deletions cookiecutter/target-template/cookiecutter.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ tests:
- destination_name: TargetRecordSinkTest
target_id: target-recordsink-test
serialization_method: Per record
- destination_name: SQLSinkTest
target_id: target-sqlsink-test
serialization_method: SQL
7 changes: 7 additions & 0 deletions docs/classes/singer_sdk.SQLConnector.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
singer\_sdk.SQLConnector
======================

.. currentmodule:: singer_sdk

.. autoclass:: SQLConnector
:members:
7 changes: 7 additions & 0 deletions docs/classes/singer_sdk.SQLStream.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
singer\_sdk.SQLStream
======================

.. currentmodule:: singer_sdk

.. autoclass:: SQLStream
:members:
7 changes: 7 additions & 0 deletions docs/classes/singer_sdk.SQLTap.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
singer\_sdk.SQLTap
===============

.. currentmodule:: singer_sdk

.. autoclass:: SQLTap
:members:
11 changes: 11 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Plugin Classes
:template: class.rst

Tap
SQLTap
Target

Stream Classes
Expand All @@ -23,6 +24,7 @@ Stream Classes
Stream
RESTStream
GraphQLStream
SQLStream

Sink Classes
--------------
Expand All @@ -35,6 +37,15 @@ Sink Classes
RecordSink
BatchSink

SQL Connector for SQL Taps and Targets
--------------------------------------

.. autosummary::
:toctree: _autosummary
:template: class.rst

SQLConnector

Authenticator Classes
---------------------

Expand Down
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python_version = 3.8
warn_unused_configs = True
warn_return_any = True
exclude = singer_sdk/tests
plugins = sqlalchemy.ext.mypy.plugin

[mypy-singer.*]
# Library 'pipelinewise-singer-tools' does not have type hints:
Expand Down Expand Up @@ -34,3 +35,6 @@ ignore_missing_imports = True

[mypy-jsonpath_ng.*]
ignore_missing_imports = True

[mypy-sqlalchemy.*]
ignore_missing_imports = True
Loading