forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destination Postgres: CDK T+D initial state gathering (airbytehq#35385)
Signed-off-by: Gireesh Sreepathi <[email protected]>
- Loading branch information
1 parent
dce8da4
commit 5582c62
Showing
13 changed files
with
80 additions
and
75 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
2 changes: 1 addition & 1 deletion
2
airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties
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 |
---|---|---|
@@ -1 +1 @@ | ||
version=0.23.0 | ||
version=0.23.2 |
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
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
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
51 changes: 51 additions & 0 deletions
51
...airbyte/integrations/destination/postgres/typing_deduping/PostgresDestinationHandler.java
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,51 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.postgres.typing_deduping; | ||
|
||
import io.airbyte.cdk.db.jdbc.JdbcDatabase; | ||
import io.airbyte.cdk.integrations.destination.jdbc.typing_deduping.JdbcDestinationHandler; | ||
import io.airbyte.integrations.base.destination.typing_deduping.AirbyteProtocolType; | ||
import io.airbyte.integrations.base.destination.typing_deduping.AirbyteType; | ||
import io.airbyte.integrations.base.destination.typing_deduping.Array; | ||
import io.airbyte.integrations.base.destination.typing_deduping.Struct; | ||
import io.airbyte.integrations.base.destination.typing_deduping.Union; | ||
import io.airbyte.integrations.base.destination.typing_deduping.UnsupportedOneOf; | ||
|
||
public class PostgresDestinationHandler extends JdbcDestinationHandler { | ||
|
||
public PostgresDestinationHandler(String databaseName, JdbcDatabase jdbcDatabase) { | ||
super(databaseName, jdbcDatabase); | ||
} | ||
|
||
@Override | ||
protected String toJdbcTypeName(AirbyteType airbyteType) { | ||
// This is mostly identical to the postgres implementation, but swaps jsonb to super | ||
if (airbyteType instanceof final AirbyteProtocolType airbyteProtocolType) { | ||
return toJdbcTypeName(airbyteProtocolType); | ||
} | ||
return switch (airbyteType.getTypeName()) { | ||
case Struct.TYPE, UnsupportedOneOf.TYPE, Array.TYPE -> "jsonb"; | ||
// No nested Unions supported so this will definitely not result in infinite recursion. | ||
case Union.TYPE -> toJdbcTypeName(((Union) airbyteType).chooseType()); | ||
default -> throw new IllegalArgumentException("Unsupported AirbyteType: " + airbyteType); | ||
}; | ||
} | ||
|
||
private String toJdbcTypeName(final AirbyteProtocolType airbyteProtocolType) { | ||
return switch (airbyteProtocolType) { | ||
case STRING -> "varchar"; | ||
case NUMBER -> "numeric"; | ||
case INTEGER -> "int8"; | ||
case BOOLEAN -> "bool"; | ||
case TIMESTAMP_WITH_TIMEZONE -> "timestamptz"; | ||
case TIMESTAMP_WITHOUT_TIMEZONE -> "timestamp"; | ||
case TIME_WITH_TIMEZONE -> "timetz"; | ||
case TIME_WITHOUT_TIMEZONE -> "time"; | ||
case DATE -> "date"; | ||
case UNKNOWN -> "jsonb"; | ||
}; | ||
} | ||
|
||
} |
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
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