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
Stabilize NetSuite SuiteQL pagination with best-effort ORDER BY
Offset/limit pagination over SuiteQL is only deterministic with a stable
ORDER BY. Plain table reads now sort by the incremental key (when set)
followed by the primary keys as a unique tie-breaker, so multi-page
extracts no longer skip or duplicate rows.
Ordering is best-effort and never blocks a load: if NetSuite rejects the
auto-added ORDER BY with a 400 (e.g. a table that exposes no sortable
column), the read retries once without it, warns that multi-page results
may be inconsistent, and continues. Custom (query:) reads are sent as-is.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/supported-sources/netsuite.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,6 @@ ingestr ingest \
65
65
--dest-table "main.netsuite_transactions"
66
66
```
67
67
68
-
For plain table names, ingestr runs `SELECT * FROM <source-table>` through SuiteQL. For joins, selected columns, built-in functions, or aliases, use the `query:` source-table form.
68
+
For plain table names, ingestr runs `SELECT * FROM <source-table>` through SuiteQL, appending an `ORDER BY` on the primary key (and incremental key when set) so that offset-based pagination returns a stable result set. If the table exposes no such column, ingestr retries without the `ORDER BY` and still loads the data, warning that results spanning more than one page (1000 rows) may be inconsistent; pass `--primary-key` to point at a sortable unique key. For joins, selected columns, built-in functions, or aliases, use the `query:` source-table form; custom queries are sent as-is, so add your own `ORDER BY` when the result spans more than one page.
69
69
70
70
NetSuite SuiteQL responses do not expose a static schema through this connector, so ingestr infers the schema from extracted rows.
fmt.Printf("Warning: netsuite rejected the ordered query; retrying without ORDER BY. Multi-page results may be inconsistent—pass --primary-key to set a sortable key.\n")
148
+
config.Debug("[NETSUITE] Falling back to unordered query: %s", fallbackQuery)
assert.Equal(t, `SELECT * FROM transaction WHERE lastmodifieddate >= TO_TIMESTAMP_TZ('2026-01-02T03:04:05.000 +00:00', 'YYYY-MM-DD"T"HH24:MI:SS.FF TZH:TZM') AND lastmodifieddate < TO_TIMESTAMP_TZ('2026-01-03T03:04:05.000 +00:00', 'YYYY-MM-DD"T"HH24:MI:SS.FF TZH:TZM') ORDER BY lastmodifieddate ASC`, got)
87
+
where:=`SELECT * FROM transaction WHERE lastmodifieddate >= TO_TIMESTAMP_TZ('2026-01-02T03:04:05.000 +00:00', 'YYYY-MM-DD"T"HH24:MI:SS.FF TZH:TZM') AND lastmodifieddate < TO_TIMESTAMP_TZ('2026-01-03T03:04:05.000 +00:00', 'YYYY-MM-DD"T"HH24:MI:SS.FF TZH:TZM')`
88
+
assert.Equal(t, where+" ORDER BY lastmodifieddate ASC, id ASC", got)
0 commit comments