-
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
add incremental to ~~jdbc~~ jooq source (and postgres) #1172
Changes from 5 commits
40faa3f
a8a6812
47a88bf
f6a49d7
8d94461
d255418
ac4307d
1321a7b
22f125f
eda376c
f7adcea
c6c9b33
a201ce6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.commons.stream; | ||
|
||
import java.util.Iterator; | ||
import java.util.Spliterator; | ||
import java.util.Spliterators; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
|
||
public class MoreStreams { | ||
|
||
public static <T> Stream<T> toStream(Iterator<T> iterator) { | ||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,14 +24,13 @@ | |
|
||
package io.airbyte.integrations.standardtest.source; | ||
|
||
import static io.airbyte.protocol.models.SyncMode.FULL_REFRESH; | ||
import static io.airbyte.protocol.models.SyncMode.INCREMENTAL; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.Lists; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.config.JobGetSpecConfig; | ||
import io.airbyte.config.StandardCheckConnectionInput; | ||
|
@@ -65,6 +64,7 @@ | |
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
import org.junit.jupiter.api.AfterEach; | ||
|
@@ -265,10 +265,10 @@ public void testIncrementalSyncWithState() throws Exception { | |
return; | ||
} | ||
|
||
ConfiguredAirbyteCatalog configuredAirbyteCatalog = withSourceDefinedCursors(getConfiguredCatalog()); | ||
List<AirbyteMessage> airbyteMessages = runRead(configuredAirbyteCatalog, getState()); | ||
List<AirbyteRecordMessage> recordMessages = filterRecords(airbyteMessages); | ||
List<AirbyteStateMessage> stateMessages = airbyteMessages | ||
final ConfiguredAirbyteCatalog configuredAirbyteCatalog = withSourceDefinedCursors(getConfiguredCatalog()); | ||
final List<AirbyteMessage> airbyteMessages = runRead(configuredAirbyteCatalog, getState()); | ||
final List<AirbyteRecordMessage> recordMessages = filterRecords(airbyteMessages); | ||
final List<AirbyteStateMessage> stateMessages = airbyteMessages | ||
.stream() | ||
.filter(m -> m.getType() == Type.STATE) | ||
.map(AirbyteMessage::getState) | ||
|
@@ -314,8 +314,18 @@ private List<AirbyteRecordMessage> filterRecords(Collection<AirbyteMessage> mess | |
private ConfiguredAirbyteCatalog withSourceDefinedCursors(ConfiguredAirbyteCatalog catalog) { | ||
ConfiguredAirbyteCatalog clone = Jsons.clone(catalog); | ||
for (ConfiguredAirbyteStream configuredStream : clone.getStreams()) { | ||
if (configuredStream.getSyncMode() == INCREMENTAL && configuredStream.getStream().getSourceDefinedCursor()) { | ||
configuredStream.setCursorField(configuredStream.getStream().getDefaultCursorField()); | ||
if (configuredStream.getStream().getSupportedSyncModes().contains(io.airbyte.protocol.models.SyncMode.INCREMENTAL)) { | ||
sherifnada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
configuredStream.setSyncMode(io.airbyte.protocol.models.SyncMode.INCREMENTAL); | ||
if (Optional.ofNullable(configuredStream.getStream().getSourceDefinedCursor()).orElse(false)) { | ||
configuredStream.setCursorField(configuredStream.getStream().getDefaultCursorField()); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as the todo describes, this is really bad. i don't think we need to block postgres on fixing this, but as part of our goal to "launch" incremental, we need to figure out how to include it into our standard tests more ergonomically and transparently. will add an issue for next week. #1217 |
||
// todo (cgardens) - this is really too terrible. there are some column types that aren't supported | ||
// so you just need to order your columns such that we pick a valid one. too much guessing here. got | ||
// to fix. | ||
// see cursor field to an arbitrary field in the stream. | ||
configuredStream | ||
.setCursorField(Lists.newArrayList(new ArrayList<>(Jsons.keys(configuredStream.getStream().getJsonSchema().get("properties"))).get(0))); | ||
} | ||
} | ||
} | ||
return clone; | ||
|
@@ -324,8 +334,8 @@ private ConfiguredAirbyteCatalog withSourceDefinedCursors(ConfiguredAirbyteCatal | |
private ConfiguredAirbyteCatalog withFullRefreshSyncModes(ConfiguredAirbyteCatalog catalog) { | ||
ConfiguredAirbyteCatalog clone = Jsons.clone(catalog); | ||
for (ConfiguredAirbyteStream configuredStream : clone.getStreams()) { | ||
if (configuredStream.getStream().getSupportedSyncModes().contains(FULL_REFRESH)) { | ||
configuredStream.setSyncMode(FULL_REFRESH); | ||
if (configuredStream.getStream().getSupportedSyncModes().contains(io.airbyte.protocol.models.SyncMode.FULL_REFRESH)) { | ||
configuredStream.setSyncMode(io.airbyte.protocol.models.SyncMode.FULL_REFRESH); | ||
} | ||
} | ||
return clone; | ||
|
@@ -334,7 +344,7 @@ private ConfiguredAirbyteCatalog withFullRefreshSyncModes(ConfiguredAirbyteCatal | |
private boolean sourceSupportsIncremental() throws Exception { | ||
ConfiguredAirbyteCatalog catalog = getConfiguredCatalog(); | ||
for (ConfiguredAirbyteStream stream : catalog.getStreams()) { | ||
if (stream.getStream().getSupportedSyncModes().contains(INCREMENTAL)) { | ||
if (stream.getStream().getSupportedSyncModes().contains(io.airbyte.protocol.models.SyncMode.INCREMENTAL)) { | ||
return true; | ||
} | ||
} | ||
|
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.
will find replace other instances of this in a separate pr.