You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: airbyte-integrations/connectors/source-relational-db/src/main/java/io/airbyte/integrations/source/relationaldb/StateDecoratingIterator.java
+24-7
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,30 @@ public class StateDecoratingIterator extends AbstractIterator<AirbyteMessage> im
27
27
privatefinalAirbyteStreamNameNamespacePairpair;
28
28
privatefinalStringcursorField;
29
29
privatefinalJsonSchemaPrimitivecursorType;
30
-
privatefinalintstateEmissionFrequency;
31
30
32
31
privatefinalStringinitialCursor;
33
32
privateStringmaxCursor;
34
33
privatebooleanhasEmittedFinalState;
35
34
36
-
// The intermediateStateMessage is set to the latest state message.
37
-
// For every stateEmissionFrequency messages, emitIntermediateState is set to true and
38
-
// the latest intermediateStateMessage will be emitted.
35
+
/**
36
+
* These parameters are for intermediate state message emission. We can emit an intermediate state
37
+
* when the following two conditions are met.
38
+
* <p/>
39
+
* 1. The records are sorted by the cursor field. This is true when {@code stateEmissionFrequency} >
40
+
* 0. This logic is guaranteed in {@code AbstractJdbcSource#queryTableIncremental}, in which an
41
+
* "ORDER BY" clause is appended to the SQL query if {@code stateEmissionFrequency} > 0.
42
+
* <p/>
43
+
* 2. There is a cursor value that is ready for emission. A cursor value is "ready" if there is no
44
+
* more record with the same value. We cannot emit a cursor at will, because there may be multiple
45
+
* records with the same cursor value. If we emit a cursor ignoring this condition, should the sync
46
+
* fail right after the emission, the next sync may skip some records with the same cursor value due
47
+
* to "WHERE cursor_field > cursor" in {@code AbstractJdbcSource#queryTableIncremental}.
48
+
* <p/>
49
+
* The {@code intermediateStateMessage} is set to the latest state message that is ready for
50
+
* emission. For every {@code stateEmissionFrequency} messages, {@code emitIntermediateState} is set
51
+
* to true and the latest "ready" state will be emitted in the next {@code computeNext} call.
Copy file name to clipboardExpand all lines: airbyte-integrations/connectors/source-relational-db/src/test/java/io/airbyte/integrations/source/relationaldb/StateDecoratingIteratorTest.java
0 commit comments