Spatial, hierarchyid, sql_variant and JSON columns¶
SQDR replicates spatial columns, SQL Server hierarchyid and sql_variant columns, and JSON columns, converting them
when the destination has no matching type.
Spatial and hierarchyid columns¶
SQDR replicates SQL Server geometry, geography and hierarchyid columns, PostgreSQL (PostGIS) geometry and
geography columns, and BigQuery GEOGRAPHY columns.
How it works. The Replicator Service reads a spatial value in a standard binary form (the spatial reference ID followed by the value's well-known binary, WKB), the form Stelo Capture stages for incremental replication, and turns it back into the destination's type:
| Destination | geometry, geography |
hierarchyid |
|---|---|---|
| SQL Server | geometry, geography |
hierarchyid |
| PostgreSQL with PostGIS | geometry, geography |
Text (up to 4000 characters): the path, such as /1/2/ |
| A destination with Stream (Using Apply extensions) on (Snowflake, Databricks, BigQuery and the other Java connector destinations) | A binary LOB holding the value's bytes in the standard form | Text, as for PostgreSQL |
| Other destinations | A character LOB holding the value as well-known text (WKT), such as SRID=4326;POINT (1 2) |
Text, as for PostgreSQL |
- Destination phrase. For a native
geometryorgeographydestination column, the Replicator Service sets the column's Destination phrase (@GEOMETRY_IN(^value)or@GEOGRAPHY_IN(^value)), the SQL that converts the value at the destination. It follows the destination column's type: ageographyvalue written to ageometrycolumn is read as planar. The built-in conversions come frombuiltin-macros.json, which every install replaces. - Size. A baseline holds each spatial value in 32 KB; a larger value stops the run with a "Buffer limit" message: raise the group's Indeterminable-size column limit (KB) (see Group Replication Settings). A value is never cut: a WKT longer than its character destination column is refused, since a shorter WKT would describe another shape.
- Keys. A
geometryorgeographycolumn can't be a destination key column (its values can't be compared): the save refuses it. Nor is it used as a checkpoint/restart key or a slicing column. Ahierarchyidcolumn can be a key. - Incremental replication needs a Capture Agent of SQDR Plus 7.0 or later, which stages the values in the same form. A value staged in an older form stops the member and asks for a baseline.
SQL Server sql_variant¶
SQDR replicates SQL Server sql_variant columns.
- At a SQL Server destination whose column is
sql_variant(the default mapping from a SQL Server source), each value keeps its own base type, precision, scale, length and collation. - At any other destination, or a SQL Server column of another type, the column is text: a destination character
type that holds 16,000 characters (Unicode if there is one), or its character LOB type where none does. Each value is
written as JSON naming its base type and holding the exact value, for example
{"type":"int","value":"42"}, at most 16,000 characters. - NULL stays NULL (no JSON).
- Derived phrases on a
sql_variantcolumn are refused, since its values don't share one type. To replicate something derived from it, such as its base type, add a derived column that reads it. - A
sql_variantcolumn is never used as the checkpoint/restart key. It can be a key column: at SQL Server it compares exactly; elsewhere it compares as its JSON text. - Incremental replication needs a Capture Agent of SQDR Plus 7.0 or later, which stages the values as the same JSON.
JSON columns¶
SQDR replicates JSON columns: MySQL, Oracle, SQL Server and BigQuery JSON, PostgreSQL json and jsonb, and
Informix JSON and BSON.
How it works. The Replicator Service reads a JSON value as its text (Unicode, as long as the document), the form Stelo Capture stages for incremental replication, and writes it to the destination's own JSON type where it has one:
| Destination | Destination column |
|---|---|
| MySQL, Oracle, BigQuery | JSON |
| SQL Server | json |
| PostgreSQL | jsonb; json for a PostgreSQL json source column |
| Informix | JSON; BSON for an Informix BSON source column |
| Other destinations, and Oracle and SQL Server releases without a JSON type | A Unicode character LOB holding the JSON text |
- Destination phrase. For a JSON destination column, the Replicator Service sets the column's Destination
phrase (
@JSON_IN(^value),@JSONB_IN(^value)or@BSON_IN(^value)), the SQL that turns the text into the destination's type. It follows the destination column's type; a phrase you enter yourself is kept. - Equal as JSON, not as text.
jsonb, MySQLJSON, OracleJSONandBSONstore a parsed document, so the destination's text can differ from the source's in whitespace, key order and duplicate keys. - Keys. A JSON column can't be a key column: the save refuses it.
- Incremental replication stages the same text. From MySQL and Informix sources, it needs a Capture Agent of Stelo Capture 7.0 or later.