-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
🐛 Source Postgres: write hstore as json #13367
Conversation
4c60f62
to
51cf252
Compare
/test connector=connectors/source-postgres
Build PassedTest summary info:
|
if (resultSet.getString(colIndex) == null) { | ||
json.putNull(columnName); | ||
} else if (columnTypeName.equalsIgnoreCase("hstore")) { | ||
putHstoreAsJson(json, columnName, resultSet, colIndex); | ||
} else if (columnTypeName.equalsIgnoreCase("bool") || columnTypeName.equalsIgnoreCase("boolean")) { | ||
putBoolean(json, columnName, resultSet, colIndex); | ||
} else if (columnTypeName.equalsIgnoreCase("bytea")) { |
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.
@yurii-bidiuk refactor this to switch, please. See as example https://github.com/airbytehq/airbyte/pull/13166/files
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.
done
@@ -169,6 +173,12 @@ private void putMoney(final ObjectNode node, final String columnName, final Resu | |||
node.put(columnName, DataTypeUtils.returnNullIfInvalid(() -> Double.valueOf(moneyValue), Double::isFinite)); | |||
} | |||
|
|||
private void putHstoreAsJson(final ObjectNode node, final String columnName, final ResultSet resultSet, final int index) | |||
throws SQLException { | |||
HashMap<String, String> data = (HashMap<String, String>) resultSet.getObject(index); |
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.
fixed
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.
Left comments, please take a look.
6e5f433
to
e24565f
Compare
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.
ecb87b6
to
9b6e2b3
Compare
9b6e2b3
to
2ea9d94
Compare
/publish connector=connectors/source-postgres
|
@grishick Hi Greg. Publish for this PR is failed, looks like the same issue with timeout as we had before |
private void putHstoreAsJson(final ObjectNode node, final String columnName, final ResultSet resultSet, final int index) | ||
throws SQLException { | ||
final var data = resultSet.getObject(index); | ||
node.put(columnName, new Gson().toJson(data)); |
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.
nitpick: most of our codebase uses ObjectMapper rather than Gson, e.g.
Line 20 in da88158
private final ObjectMapper objectMapper = MoreMappers.initMapper(); |
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.
Fixed
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.
I think it would be better to declare the object mapper as a static final
constant
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.
done
TestDataHolder.builder() | ||
.sourceType("hstore") | ||
.airbyteType(JsonSchemaType.STRING) | ||
.addInsertValues("'\"paperback\" => \"243\",\"publisher\" => \"postgresqltutorial.com\"," |
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.
nitpick: these would be a bit more readable using multiline strings:
.addInsertValues("""
"paperback" => ...
""")
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.
Fixed
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.
could you also do this for the json blob on the next line? https://github.com/airbytehq/airbyte/pull/13367/files#diff-a2069083fdac6437ab9a15a5376aeccbb550b9a05a7c28ea483bd4ea8bff1437R555
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.
done
2ea9d94
to
8b23971
Compare
8b23971
to
ce9c9c0
Compare
ce9c9c0
to
918eb71
Compare
918eb71
to
75c3bdf
Compare
/publish connector=connectors/source-postgres
|
3ec4441
to
1b58cd5
Compare
What
Fixed #11953
How
Converted hstore key-value to JSON format
Recommended reading order
PostgresSourceOperations.java
PostgresSourceDatatypeTest.java
🚨 User Impact 🚨
Values of hstore type will be represented as JSON string instead of key-value map
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.