Geometric Types
Handle PostgreSQL geometric and spatial data types.
Overview
PostgreSQL geometric types include:
-
Point: (x,y) coordinates
-
Line: Linear equations
-
Box: Rectangular boxes
-
Path: Connected points
-
Polygon: Closed paths
-
Circle: Center and radius
Geometric Type Support
TDK supports PostgreSQL geometric types through:
-
Direct copying: Preserves geometric values
-
Custom transformations: Modify geometric data
-
Type conversion: Convert to/from text
Common Issues
Issue: Geometric Type Not Preserved
Symptom: Geometric values become NULL or corrupted.
Solution: Ensure JDBC driver supports geometric types:
data_sources:
input:
url: jdbc:postgresql://host:5432/db?geometryEnabled=true
driver_class_name: org.postgresql.Driver
Issue: Cannot Transform Geometric Data
Symptom: "Cannot transform geometric type" errors.
Solution: Use scripting transformer for custom geometric transformations:
transformations:
- columns: ["location"] # POINT type
type: Scripting
config:
script: |
// Offset point by random amount
if (location != null) {
var parts = location.replace('(', '').replace(')', '').split(',');
var x = parseFloat(parts[0]) + Math.random() * 0.01;
var y = parseFloat(parts[1]) + Math.random() * 0.01;
return '(' + x + ',' + y + ')';
}
return location;
PostGIS Spatial Types
For PostGIS extension (geography, geometry):
Preserve Spatial Data
table_schema:
- table_name_pattern: "public.locations"
transformations:
- columns: ["geom"] # geometry/geography column
# Don't transform - preserve spatial data
type: Preserve
Transform Spatial References
For masking while preserving spatial relationships:
transformations:
- columns: ["geom"]
type: Scripting
config:
script: |
// Apply small random offset to coordinates
// while preserving geometry type
if (geom != null) {
return ST_Translate(geom,
Math.random() * 0.001,
Math.random() * 0.001);
}
return geom;