-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Postgres Source: add timezone awareness and handle BC dates #13166
Postgres Source: add timezone awareness and handle BC dates #13166
Conversation
/test connector=connectors/source-postgres
|
/test connector=connectors/source-postgres-strict-encrypt
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
} else if (columnTypeName.equalsIgnoreCase("time")) { | ||
putTime(json, columnName, resultSet, colIndex); | ||
} else if (columnTypeName.equalsIgnoreCase("timetz")) { | ||
putTimeWithTimezone(json, columnName, resultSet, colIndex); | ||
} else if (columnTypeName.equalsIgnoreCase("timestamptz")) { | ||
putTimestampWithTimezone(json, columnName, resultSet, colIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible we will have more else if
statements here, in the future?
I suggest refactoring this block to smth like:
return switch (typeName) {
case "real", "double", "float" -> Double.parseDouble(varCharValue);
case "varchar" -> varCharValue;
case "boolean" -> Boolean.parseBoolean(varCharValue);
case "integer" -> Integer.parseInt(varCharValue);
default -> null;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible we will have more
else if
statements here, in the future? I suggest refactoring this block to smth like:return switch (typeName) { case "real", "double", "float" -> Double.parseDouble(varCharValue); case "varchar" -> varCharValue; case "boolean" -> Boolean.parseBoolean(varCharValue); case "integer" -> Integer.parseInt(varCharValue); default -> null; };
replaced with switch
return isBCE(date) ? value.substring(1) + " BC" : value; | ||
} | ||
|
||
private static boolean isBCE(LocalDate date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why static
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is util method and we can reuse it without initialising of the new instance AbstractJdbcCompatibleSourceOperations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VitaliiMaltsev in such case, should it be public
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VitaliiMaltsev in such case, should it be
public
?
made it public
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.integrations.source.relationaldb.models.DbState; | ||
import io.airbyte.integrations.source.relationaldb.models.DbStreamState; | ||
import io.airbyte.protocol.models.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (typeName.equalsIgnoreCase("timestamptz")) { | ||
return JDBCType.TIMESTAMP_WITH_TIMEZONE; | ||
} else if (typeName.equalsIgnoreCase("timetz")) { | ||
return JDBCType.TIME_WITH_TIMEZONE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like, the comment above is related to this block of code as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like, the comment above is related to this block of code as well.
replaced with switch
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.integrations.source.relationaldb.models.DbState; | ||
import io.airbyte.integrations.source.relationaldb.models.DbStreamState; | ||
import io.airbyte.protocol.models.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/test connector=connectors/source-postgres
|
/publish connector=connectors/source-postgres
|
/test connector=connectors/source-postgres
Build PassedTest summary info:
|
/publish connector=connectors/source-postgres run-tests=false
|
/publish connector=connectors/source-postgres-strict-encrypt run-tests=false
|
@evantahler FYI auto-bump has failed here (see @VitaliiMaltsev 's last attempt) |
@grishick isn't a failure expected if the version on this branch has already been bumped (your previous /publish did work)? The previous failures of the publish command seem to be test failures, as noted above
|
@evantahler auto-bump version issue is related to Postgres source strict encrypt connector, not to Postgres source |
Ah! sorry, I did not read closely enough to see that there were 2 connectors getting published here. I'm actually not sure how this was working since #11712. My reading of the action:
Seems to imply that if we are bumping the version, in all cases, we want to update our Looking at some other recent PRs (#13176 (comment)) it looks like they are also failing for the same reason. Do we want to publish the connector, or is that something that cloud should do? It would be a simple fix to skip parts of the action if the connector name matches I also think that we might be moving away from these secondary image and use an ENV var / setting to toggle on strict-encrypt mode in cloud. @tuliren - what's the path forward here? |
Hm... so this means that publishing strict-encrypt connectors with |
…q#13166) * Postgres Source: add timezone awareness and handle BC dates * fixed checkstyle * add tests * updated changelog * removed star import * fixed tests * refactoring * removed star import * fixed bytea type * created final static constants * bump version * auto-bump connector version Co-authored-by: Octavia Squidington III <[email protected]>
The publication of the The current workflow is:
I guess we can just make the version bumping script ignore the error if a connector does not exist.
Yes, I think we can do the following:
Added a comment to this related issue: #8634 (comment) |
After updating our Postgres source connector to 0.4.19 following this PR merge, we're witnessing issues in one of our pipelines because date field precision is now truncated if the value of the millisecond or second is 0. Value in PG database: I'm not sure if it's on purpose or if it's a bug, we've had to revert to 0.4.18 though |
|
What
There are next date-related types that should be covered:
timestamp with/without timezone
date
time with/without timezone
How
Recommended reading order
JsonSchemaType.java
AbstractJdbcCompatibleSourceOperations.java
PostgresSourceOperations.java
🚨 User Impact 🚨
user impact is possible at the normalization stage, since normalization cannot yet handle new parameters in the json schema
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/SUMMARY.md
docs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changesTests
Unit
Put your unit tests output here.
Integration
Put your integration tests output here.
Acceptance
Put your acceptance tests output here.