Skip to content

feat: Filter out system views out of system namespaces #22427

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

Merged
merged 25 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b31b7b8
This changes allows to filter out system views created out of system …
Feb 1, 2023
6a9460b
Add extra view
Feb 1, 2023
e25df94
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 2, 2023
c617d47
Fix issue
Feb 2, 2023
f3140e6
Merge remote-tracking branch 'origin/feat/exclude-system-views-postgr…
Feb 2, 2023
666fa2a
Merge branch 'master' into feat/exclude-system-views-postgres
Feb 6, 2023
7394465
Bump Postgres source version
Feb 6, 2023
2cd6d25
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 6, 2023
1de1303
bump version
Feb 6, 2023
677da3f
Bump alloydb
Feb 6, 2023
442db6f
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 6, 2023
e15909e
Bump versioning
Feb 6, 2023
3f569b0
Merge remote-tracking branch 'origin/feat/exclude-system-views-postgr…
Feb 6, 2023
cd960d4
auto-bump connector version
octavia-squidington-iii Feb 6, 2023
34eb114
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 7, 2023
9b57dbf
Set default implementation and remove from unneeded places
Feb 7, 2023
d94a006
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 7, 2023
8ecf0ed
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 8, 2023
54aec71
auto-bump connector version
octavia-squidington-iii Feb 8, 2023
b5482c4
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 8, 2023
def80f9
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 8, 2023
7210d53
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 9, 2023
f2c6bf6
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 9, 2023
8cf0fc3
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 9, 2023
db50127
Merge branch 'master' into feat/exclude-system-views-postgres
sergio-ropero Feb 9, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-alloydb-strict-encrypt

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=1.0.43
LABEL io.airbyte.version=1.0.44
LABEL io.airbyte.name=airbyte/source-alloydb-strict-encrypt
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-alloydb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-alloydb

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=1.0.43
LABEL io.airbyte.version=1.0.44
LABEL io.airbyte.name=airbyte/source-alloydb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Collections.emptySet();
}

@Override
protected Set<String> getExcludedViews() {
return Collections.emptySet();
}

@Override
protected List<TableInfo<CommonField<StandardSQLTypeName>>> discoverInternal(final BigQueryDatabase database) throws Exception {
return discoverInternal(database, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

public static void main(final String[] args) throws Exception {
final Source source = new JdbcSource();
LOGGER.info("starting source: {}", JdbcSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Collections.emptySet();
}

@Override
protected Set<String> getExcludedViews() {
return Collections.emptySet();
}

@Override
protected List<TableInfo<CommonField<BsonType>>> discoverInternal(final MongoDatabase database)
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-postgres-strict-encrypt

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=1.0.43
LABEL io.airbyte.version=1.0.44
LABEL io.airbyte.name=airbyte/source-postgres-strict-encrypt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-postgres

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=1.0.43
LABEL io.airbyte.version=1.0.44
LABEL io.airbyte.name=airbyte/source-postgres
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

@Override
public AirbyteCatalog discover(final JsonNode config) throws Exception {
final AirbyteCatalog catalog = super.discover(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

public static void main(final String[] args) throws Exception {
final Source source = new PostgresTestSource();
LOGGER.info("starting source: {}", PostgresTestSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ private List<TableInfo<CommonField<DataType>>> discoverWithoutSystemTables(
final Database database)
throws Exception {
final Set<String> systemNameSpaces = getExcludedInternalNameSpaces();
final Set<String> systemViews = getExcludedViews();
final List<TableInfo<CommonField<DataType>>> discoveredTables = discoverInternal(database);
return (systemNameSpaces == null || systemNameSpaces.isEmpty() ? discoveredTables
: discoveredTables.stream()
.filter(table -> !systemNameSpaces.contains(table.getNameSpace())).collect(
.filter(table -> !systemNameSpaces.contains(table.getNameSpace()) && !systemViews.contains(table.getName())).collect(
Collectors.toList()));
}

Expand Down Expand Up @@ -634,12 +635,19 @@ protected abstract List<CheckedConsumer<Database, Exception>> getCheckOperations
protected abstract JsonSchemaType getAirbyteType(DataType columnType);

/**
* Get list of system namespaces(schemas) in order to exclude them from the discover result list.
* Get list of system namespaces(schemas) in order to exclude them from the `discover` result list.
*
* @return set of system namespaces(schemas) to be excluded
*/
protected abstract Set<String> getExcludedInternalNameSpaces();

/**
* Get list of system views in order to exclude them from the `discover` result list.
*
* @return set of views to be excluded
*/
protected abstract Set<String> getExcludedViews();

/**
* Discover all available tables in the source database.
*
Expand Down
25 changes: 13 additions & 12 deletions docs/integrations/sources/alloydb.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,16 @@ According to Postgres [documentation](https://www.postgresql.org/docs/14/datatyp

## Changelog

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------|
| 1.0.43 | 2022-02-06 | [21634](https://github.com/airbytehq/airbyte/pull/21634) | Improve Standard sync performance by caching objects.|
| 1.0.36 | 2023-01-24 | [21825](https://github.com/airbytehq/airbyte/pull/21825) | Put back the original change that will cause an incremental sync to error if table contains a NULL value in cursor column.|
| 1.0.35 | 2022-12-14 | [20436](https://github.com/airbytehq/airbyte/pull/20346) | Consolidate date/time values mapping for JDBC sources |
| 1.0.34 | 2022-12-13 | [20378](https://github.com/airbytehq/airbyte/pull/20378) | Improve descriptions |
| 1.0.17 | 2022-10-31 | [18538](https://github.com/airbytehq/airbyte/pull/18538) | Encode database name |
| 1.0.16 | 2022-10-25 | [18256](https://github.com/airbytehq/airbyte/pull/18256) | Disable allow and prefer ssl modes in CDC mode |
| | 2022-10-13 | [15535](https://github.com/airbytehq/airbyte/pull/16238) | Update incremental query to avoid data missing when new data is inserted at the same time as a sync starts under non-CDC incremental mode |
| 1.0.15 | 2022-10-11 | [17782](https://github.com/airbytehq/airbyte/pull/17782) | Align with Postgres source v.1.0.15 |
| 1.0.0 | 2022-09-15 | [16776](https://github.com/airbytehq/airbyte/pull/16776) | Align with strict-encrypt version |
| 0.1.0 | 2022-09-05 | [16323](https://github.com/airbytehq/airbyte/pull/16323) | Initial commit. Based on source-postgres v.1.0.7 |
| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1.0.44 | 2022-02-06 | [22221](https://github.com/airbytehq/airbyte/pull/22221) | Exclude new set of system tables when using `pg_stat_statements` extension. |
| 1.0.43 | 2022-02-06 | [21634](https://github.com/airbytehq/airbyte/pull/21634) | Improve Standard sync performance by caching objects. |
| 1.0.36 | 2023-01-24 | [21825](https://github.com/airbytehq/airbyte/pull/21825) | Put back the original change that will cause an incremental sync to error if table contains a NULL value in cursor column. |
| 1.0.35 | 2022-12-14 | [20436](https://github.com/airbytehq/airbyte/pull/20346) | Consolidate date/time values mapping for JDBC sources |
| 1.0.34 | 2022-12-13 | [20378](https://github.com/airbytehq/airbyte/pull/20378) | Improve descriptions |
| 1.0.17 | 2022-10-31 | [18538](https://github.com/airbytehq/airbyte/pull/18538) | Encode database name |
| 1.0.16 | 2022-10-25 | [18256](https://github.com/airbytehq/airbyte/pull/18256) | Disable allow and prefer ssl modes in CDC mode |
| | 2022-10-13 | [15535](https://github.com/airbytehq/airbyte/pull/16238) | Update incremental query to avoid data missing when new data is inserted at the same time as a sync starts under non-CDC incremental mode |
| 1.0.15 | 2022-10-11 | [17782](https://github.com/airbytehq/airbyte/pull/17782) | Align with Postgres source v.1.0.15 |
| 1.0.0 | 2022-09-15 | [16776](https://github.com/airbytehq/airbyte/pull/16776) | Align with strict-encrypt version |
| 0.1.0 | 2022-09-05 | [16323](https://github.com/airbytehq/airbyte/pull/16323) | Initial commit. Based on source-postgres v.1.0.7 |
1 change: 1 addition & 0 deletions docs/integrations/sources/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ The root causes is that the WALs needed for the incremental sync has been remove

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1.0.44 | 2022-02-06 | [22221](https://github.com/airbytehq/airbyte/pull/22221) | Exclude new set of system tables when using `pg_stat_statements` extension. |
| 1.0.43 | 2022-02-06 | [21634](https://github.com/airbytehq/airbyte/pull/21634) | Improve Standard sync performance by caching objects. |
| 1.0.42 | 2022-01-23 | [21523](https://github.com/airbytehq/airbyte/pull/21523) | Check for null in cursor values before replacing. |
| 1.0.41 | 2022-01-25 | [20939](https://github.com/airbytehq/airbyte/pull/20939) | Adjust batch selection memory limits databases. |
Expand Down