-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ingest/cockroachdb): add cockroachdb ingestion (#10226)
- Loading branch information
Showing
9 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
metadata-ingestion/docs/sources/cockroachdb/cockroachdb_recipe.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
source: | ||
type: cockroachdb | ||
config: | ||
# Coordinates | ||
host_port: localhost:26257 | ||
database: DemoDatabase | ||
|
||
# Credentials | ||
username: user | ||
password: pass | ||
|
||
# Optional: SSL configuration. | ||
# options: | ||
# connect_args: | ||
# sslcert: "<<path to sslcert>>" | ||
# sslkey: "<<path to sslkey>>" | ||
# sslrootcert: "<<path to verification ca chain>>" | ||
# sslmode: "verify-full" | ||
|
||
sink: | ||
# sink configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
metadata-ingestion/src/datahub/ingestion/source/sql/cockroachdb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from pydantic.fields import Field | ||
|
||
from datahub.configuration.common import AllowDenyPattern | ||
from datahub.ingestion.api.common import PipelineContext | ||
from datahub.ingestion.api.decorators import ( | ||
SourceCapability, | ||
SupportStatus, | ||
capability, | ||
config_class, | ||
platform_name, | ||
support_status, | ||
) | ||
from datahub.ingestion.source.sql.postgres import PostgresConfig, PostgresSource | ||
|
||
|
||
class CockroachDBConfig(PostgresConfig): | ||
scheme = Field(default="cockroachdb+psycopg2", description="database scheme") | ||
schema_pattern = Field( | ||
default=AllowDenyPattern(deny=["information_schema", "crdb_internal"]) | ||
) | ||
|
||
|
||
@platform_name("CockroachDB") | ||
@config_class(CockroachDBConfig) | ||
@support_status(SupportStatus.TESTING) | ||
@capability(SourceCapability.PLATFORM_INSTANCE, "Enabled by default") | ||
@capability(SourceCapability.DOMAINS, "Supported via the `domain` config field") | ||
@capability(SourceCapability.DATA_PROFILING, "Optionally enabled via configuration") | ||
@capability(SourceCapability.DELETION_DETECTION, "Enabled via stateful ingestion") | ||
class CockroachDBSource(PostgresSource): | ||
|
||
config: CockroachDBConfig | ||
|
||
def __init__(self, config: CockroachDBConfig, ctx: PipelineContext): | ||
super().__init__(config, ctx) | ||
|
||
def get_platform(self): | ||
return "cockroachdb" | ||
|
||
@classmethod | ||
def create(cls, config_dict, ctx): | ||
config = CockroachDBConfig.parse_obj(config_dict) | ||
return cls(config, ctx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from datahub.ingestion.api.common import PipelineContext | ||
from datahub.ingestion.source.sql.cockroachdb import ( | ||
CockroachDBConfig, | ||
CockroachDBSource, | ||
) | ||
from datahub.ingestion.source.sql.postgres import PostgresConfig, PostgresSource | ||
|
||
|
||
def _base_config(): | ||
return {"username": "user", "password": "password", "host_port": "host:1521"} | ||
|
||
|
||
def test_platform_correctly_set_cockroachdb(): | ||
source = CockroachDBSource( | ||
ctx=PipelineContext(run_id="cockroachdb-source-test"), | ||
config=CockroachDBConfig.parse_obj(_base_config()), | ||
) | ||
assert source.platform == "cockroachdb" | ||
|
||
|
||
def test_platform_correctly_set_postgres(): | ||
source = PostgresSource( | ||
ctx=PipelineContext(run_id="postgres-source-test"), | ||
config=PostgresConfig.parse_obj(_base_config()), | ||
) | ||
assert source.platform == "postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters