@whaly/connector-sdk 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1133,6 +1133,7 @@ var Stream = class {
1133
1133
  // Private sync methods:
1134
1134
  async _syncRecords(parent) {
1135
1135
  let rowsSent = 0;
1136
+ const dryRunLimit = isDryRun() ? getDryRunLimit() : void 0;
1136
1137
  let recordSyncedMetrics = [];
1137
1138
  if (this.rowsSyncedMetricsConf.isEnabled() === true) {
1138
1139
  recordSyncedMetrics = getCounterMetrics(
@@ -1174,6 +1175,10 @@ var Stream = class {
1174
1175
  metric.increment();
1175
1176
  });
1176
1177
  rowsSent += 1;
1178
+ if (dryRunLimit !== void 0 && rowsSent >= dryRunLimit) {
1179
+ logger.info(`\u{1F6D1} Stream: ${this.streamId} - DRY_RUN_LIMIT reached (${dryRunLimit} records), stopping.`);
1180
+ break;
1181
+ }
1177
1182
  if (rowsSent % 1e3 === 0) {
1178
1183
  const percentStr = this.totalRows ? ` (${Math.round(rowsSent / this.totalRows * 100)}%)` : "";
1179
1184
  logger.info(`\u23F3 Stream: ${this.streamId} - ${rowsSent} records synced so far...${percentStr}`);
@@ -2199,11 +2204,12 @@ var ITarget = class _ITarget {
2199
2204
  streamState.setSchema(schema);
2200
2205
  streamState.setCompiledValidateFn(this.ajv.compile({ type: "object", properties: schema }));
2201
2206
  const streamReplicationMethod = this.streams[streamId]?.getReplicationMethod();
2202
- if (message.keyProperties.length === 0 && streamReplicationMethod !== "APPEND" /* APPEND */) {
2207
+ if (message.keyProperties.length === 0 && streamReplicationMethod === "INCREMENTAL" /* INCREMENTAL */) {
2203
2208
  throw new Error(`StreamId: ${message.stream} - \`key_properties\` field is required and can't be empty in SCHEMA message.
2204
2209
  Received SCHEMA message: ${JSON.stringify(message)}`);
2205
2210
  }
2206
2211
  streamState.setKeyProperties(message.keyProperties);
2212
+ dbSync.renamedColumnStore.computeColumnNameForStream(streamId, schema);
2207
2213
  if (!isDryRun()) {
2208
2214
  await dbSync.updateSchemaInWarehouse(schema, message.keyProperties);
2209
2215
  const {
@@ -4082,6 +4088,12 @@ var BigQueryDBSync = class extends StreamWarehouseSyncService {
4082
4088
  });
4083
4089
  };
4084
4090
  getReplaceQueries = () => {
4091
+ if (this.primaryKeys.length === 0) {
4092
+ return [
4093
+ `TRUNCATE TABLE ${this.sqlTableId};`,
4094
+ ...this.getAppendQueries()
4095
+ ];
4096
+ }
4085
4097
  return [
4086
4098
  `TRUNCATE TABLE ${this.sqlTableId};`,
4087
4099
  ...this.getMergeQueries()