Error Handling
GeoBrix distinguishes a bad parameter from bad data.
- A bad or non-executable parameter — an invalid CRS code, a malformed argument, a string that cannot be resolved — raises a clear error. It is a fix-your-code problem and fails fast so you catch it during development.
- Bad data flowing through a column degrades to
NULL(or an empty result) rather than failing the whole job. Examples are a corrupt geometry or a coordinate outside the target CRS's valid area. One bad row never kills the stage.
This separation keeps large-scale spatial pipelines reliable: parameter mistakes surface immediately, while data quality issues in individual records are isolated and observable.
RasterX
RasterX has four result shapes. Each one applies the bad-data-degrades rule in its own way. A tile function returns a tile, so it can carry the reason for a failure. A function that returns a number or a string cannot, so it returns NULL.
Order of checks
Every raster tile function checks its input in the same order at every level:
- A
NULLtile, or aNULLrequired argument, givesNULL. - An error tile comes out unchanged, so the first reason survives.
- A bad argument raises an error that names the value.
- A tile that cannot be opened, is refused, or is over the read cap becomes an error tile.
A bad argument raises on every row that is not already an error tile. An error tile in the column does not hide a typo in your query.
The error tile
An error tile is a valid tile struct with no pixels. Its raster field is NULL, its path is NULL, and its metadata map holds the reason under last_error. The JVM level also writes the same text under error_message. Test for last_error, which every level writes.
A good tile can also carry last_error as a warning, for example when a merge skipped corrupt members. The mark of an error tile is no pixels plus last_error.
SELECT path,
gbx_rst_retile(tile, 256, 256) AS retiled
FROM my_rasters
-- a tile that cannot be retiled comes back as an error tile
To list the problem rows:
SELECT path, tile.metadata['last_error'] AS err
FROM results
WHERE tile.raster IS NULL AND tile.path IS NULL
AND tile.metadata['last_error'] IS NOT NULL
An error tile also answers the accessors in a fixed way: gbx_rst_isempty(tile) is true and gbx_rst_tryopen(tile) is false. gbx_rst_tryopen is false for any payload that does not open as a raster.
Scalar accessors
Functions that read one property (band count, CRS, pixel type and similar) return NULL for a NULL, error or corrupt tile. The rest of the column is unaffected. A NetCDF container tile has no bands. Band-level accessors give the empty answer for it, such as an empty array.
SELECT path, gbx_rst_numbands(tile) AS bands
FROM my_rasters
-- rows with a corrupt tile produce NULL for `bands`; the query does not fail
Tile functions
Functions that return a tile (transforms, resampling, band math) return an error tile when they meet bad data. One bad row never fails the stage.
Both levels accept the same tile drivers. Bytes in a driver from the allowed set that are not GeoTIFF translate to GeoTIFF in memory first. A driver GeoBrix refuses gives an error tile with a Fix:.
Tiles over the read cap
A function that must decode a tile checks the decoded size first. The cap is 64 MiB on Serverless and 1536 MiB on classic compute, in dedicated and standard access mode alike. A tile over the cap gives the same error tile at every level. The error text ends with a Fix: that says to retile first with gbx_rst_retile.
A virtual tile is judged by the window it reads, from the file's header, before any pixel is read. A small window of a large file is read. At the Python level, gbx_rst_retile, gbx_rst_tooverlappingtiles and gbx_rst_maketiles cut such a tile window by window, so they work at any size.
A file read over the cap is different. gbx_rst_fromfile, and rst_fromfile(materialize=True), fail the call with an error that says how to fix it. The raster_gbx reader does the same when you set virtualTiles=false. Set sizeInMB to split the file, or keep virtual tiles.
An out-of-memory error fails the task. GeoBrix never turns it into an error tile.
Functions that run GDAL's own algorithm
The terrain functions, gbx_rst_color_relief, the band-math functions, the warp and resample functions, gbx_rst_fillnodata, gbx_rst_summary, gbx_rst_contour, gbx_rst_polygonize, gbx_rst_viewshed and gbx_rst_gdal share these rules.
- A tile over the read cap gives an error tile with a
Fix:that says to retile first. GeoBrix judges it from the header, before it decodes a pixel. - The input and the estimated output must fit the compute's decoded budget together. The budget is 64 MiB on Serverless and 1536 MiB on classic compute, in dedicated and standard access mode alike. If they do not fit, the call gives an error tile with a
Fix:that says to retile first or ask for a smaller output. - A warp or resample over the budget does not give that error tile. It runs streamed: GDAL reads and writes the raster block by block, on local disk. The result is the same tile.
- A
gbx_rst_gdalcommand with areprojectstep streams the same way. A step that GDAL holds in memory (fill-nodata,sieve,proximity,viewshed,neighbors) must still fit three quarters of the budget. - A streamed warp is refused only when its output tile is over the read cap. The
Fix:says to retile first or ask for a smaller output. - A tile that is already in the target CRS comes back from
gbx_rst_transformunchanged, before the budget is judged. gbx_rst_viewshedandgbx_rst_gdalread a virtual tile that is a whole file by its path, block by block. The read cap does not apply to that read, and the budget judges the output.- Such a file on a Volume is first copied to local disk in one sequential pass, and so is each Volume source of a VRT. Each worker copies a file once and reuses the copy. A file over
GBX_STAGE_MAX_BYTES(4 GiB by default) is read in place. gbx_rst_summaryandgbx_rst_contourgive NULL where the others give an error tile.gbx_rst_polygonizegives no rows. A call that GDAL cannot run logs its reason once for each function and reason on the worker.- A virtual tile whose file is missing is retried about 10 times. It then raises with a
Fix:, and Spark retries the task. - A wrong argument raises and names the value.
Arrays of tiles, merges and combines
Functions that take an ARRAY of tiles (gbx_rst_merge, the gbx_rst_combine* family, gbx_rst_frombands) share one contract:
- A
NULLor empty array givesNULL. - An array of only error tiles gives the first member's error tile.
- A
NULLelement, an error tile or an unreadable tile is skipped. The skipped count goes intolast_error. - Tiles of different shapes raise.
- An array over the memory budget gives that group's error tile with a
Fix:.
The Fix: names the route that fits the group:
- Members on mixed CRS or pixel size: bring them to one grid first with
gbx_rst_transformandgbx_rst_resample_to_res. - A mosaic or result over the cap: keep the tiles as files on a Volume. Then build the mosaic with
rasterx.helpers.mint_vrt(paths, out="/Volumes/...")or thecog_gbxwriter in mosaic mode, and read the VRT. - Members that do not fit in memory, with a result that does:
merge_by_key(..., method="vrt"). - A combine over the cap: retile first with
gbx_rst_retile, or usecombine_by_key.
Aggregators
The aggregators (gbx_rst_merge_agg, gbx_rst_combineavg_agg, gbx_rst_frombands_agg and the others) skip a corrupt member and continue over the rest. They stream under the worker cap.
The aggregators that return BINARY have no place for a reason. When they must refuse, they raise an error with the same Fix: instead of returning NULL. They refuse when a member is over the read cap or the result is over the cap. A group with no usable member gives NULL.
Generators
Functions that turn one tile into many rows (tessellation, tiling, pyramids) behave by what they return:
- A generator that returns tiles emits one error row for a tile it cannot read. Filter or audit that row like any other.
- A generator that returns no tile column (the cell explodes, the TIN functions,
gbx_rst_polygonize) gives no rows for anyNULLor unreadable input. gbx_rst_polygonizenever gives a partial result: if reading its output fails once the file has opened, the task fails and Spark retries it.gbx_rst_xyzpyramidgives no rows for aNULLor unreadable tile. An unknownformat,resamplingorrescale, asizeoutside (0, 4096], amax_zabove the cap, or too many tiles for the zoom range raises its message.- A
NULLsize, resolution or grid gives one error tile.
Call a generator as FROM t, LATERAL gbx_...(args). That form works on every compute.
Readers
A reader fails the read when it cannot open a file. Set on_error to skip or quarantine to set the file aside and continue. The tile functions above follow the error-tile rule instead.
Setting both out_srid and out_crs
Set out_srid or out_crs, never both. A function that takes both raises, naming both, with the fix: set one. The rule holds at every level for these functions and their _agg forms:
gbx_rst_rasterizegbx_rst_gridfrompointsgbx_rst_dtmfromgeomsgbx_rst_h3_rasterizeandgbx_rst_quadbin_rasterize(the cell rasterizers)
Flipping data errors to hard failures for debugging
The Spark configuration key spark.databricks.labs.gbx.expressions.crash.on.error makes the JVM RasterX expressions raise hard failures instead of degrading. Use it to get stack traces during development.
spark.conf.set(
"spark.databricks.labs.gbx.expressions.crash.on.error",
"true"
)
Set it back to false (the default) before production runs.
The switch affects only the JVM level (L1). The Python level does not read Spark configuration. VectorX has no such switch.
VectorX
VectorX functions work on geometry columns (WKB, EWKB, WKT, or EWKT). They have no metadata carrier, so NULL is the single degrade signal for bad-data conditions. VectorX has no crash-on-error switch; the RasterX configuration key above does not affect it.
Bad geometry data
If the input geometry is corrupt, unparseable, or produces a non-finite result, the function returns NULL. Other rows are unaffected.
SELECT id, gbx_st_transformcrs(geom, 'EPSG:3857') AS geom_mercator
FROM my_table
-- rows with an unparseable geometry produce NULL; the query continues
Bad CRS argument
If the CRS argument cannot be resolved, the function raises an error. Examples are an unrecognised authority code, an empty string, or a value that is not a valid CRS. This is a parameter problem: the CRS string is a constant in your query, not data flowing through the column.
-- This raises an error: "FAKE:9999" is not a valid CRS.
SELECT gbx_st_transformcrs(geom, 'FAKE:9999') FROM my_table
Fix the CRS string; do not expect this to degrade quietly.
Reprojection domain check
gbx_st_transformcrs checks whether each geometry falls within the target CRS's valid area. A geometry that lies outside that area returns NULL rather than producing a silently nonsensical coordinate. An example is a point at longitude 0° reprojected into a CRS whose valid area covers only the eastern United States. A geometry that straddles the boundary also returns NULL, erring on the side of correctness.
Reprojections that fell outside the target CRS's valid area are returned as NULL. To find them:
SELECT id
FROM (
SELECT id, gbx_st_transformcrs(geom, 'EPSG:27700') AS projected
FROM my_table
)
WHERE projected IS NULL
When the target CRS carries no declared area of use, the domain check is skipped and the reprojection proceeds without a spatial guard.
GridX
GridX functions (BNG, Quadbin, Custom) return cell ids, geometries, arrays, or structs, and there is no metadata carrier. So NULL is the single degrade signal for bad-data conditions, the same pattern as VectorX. GridX has no crash-on-error switch.
Bad cell-id or geometry data
A malformed cell id (an unrecognised BNG grid-square letter pair, a cell string that cannot be decoded) or an unparseable geometry returns NULL. Other rows are unaffected; one bad cell id never fails the stage.
SELECT id, gbx_bng_aswkb(cellid) AS geom
FROM my_cells
-- rows with a malformed cellid produce NULL for `geom`; the query continues
Aggregators (gbx_bng_cellunion_agg, gbx_bng_cellintersection_agg) skip a corrupt member and continue over the remaining valid cell ids.
Generators (gbx_bng_kringexplode, gbx_bng_tessellateexplode) emit zero rows for a bad input cell rather than a single NULL row. An inner join against a generator silently drops those inputs. To find inputs that produced nothing, join the generator's output back to your source table with an anti-join or left join on the original id.
Bad resolution or grid argument
An out-of-range resolution, an unrecognised resolution string, or an invalid custom-grid specification raises an error rather than returning NULL. This is a parameter problem. The resolution is a constant in your query, not per-row data, so the error surfaces immediately during development rather than silently degrading at scale.
-- This raises an error: 99 is not a valid BNG resolution index.
SELECT gbx_bng_pointascell(geom, 99) FROM my_table
Fix the resolution argument; do not expect this to degrade quietly.
Quadbin latitude clamp
gbx_quadbin_pointascell follows the web-mercator convention: a latitude beyond ±85.05112878° is clamped to that limit, and a longitude beyond ±180° is clamped to ±180°. The function returns a real cell rather than NULL. A point at latitude 89° yields the same cell as one at 85.05112878°.
This behaviour is intentional and differs from BNG and Custom, which return NULL for a coordinate outside their valid extent.
Unity Catalog functions
A Unity Catalog function follows a stricter rule than the session function. It cannot return a reason beside the data.
- Corrupt data gives
NULL. A cell id that is no cell, or a geometry the kernel cannot read, givesNULLfor that row. - Non-conforming input is refused with a
Fix:. Examples are a geometry with the wrong SRID, a CRS form UC does not accept, and aBINARYvalue where aGEOMETRYbelongs. The error names the session function to use. - Parameters are checked first. A bad
mode,coverage, resolution, zoom orkraises with aFix:.
A Unity Catalog function refuses a result over its size limit with a Fix:. For example, gbx_quadbin_polyfill of a geometry over 1,000,000 cells raises in a session. On UC it is refused, and the Fix: says to use a lower zoom. See Unity Catalog functions.
Catching degraded rows
Scalar accessors and VectorX: filter on IS NOT NULL:
SELECT *
FROM results
WHERE geom IS NOT NULL
RasterX tile functions: filter on the error-tile mark:
SELECT *
FROM results
WHERE NOT (tile.raster IS NULL AND tile.path IS NULL
AND tile.metadata['last_error'] IS NOT NULL)
Or audit the errors:
SELECT path, tile.metadata['last_error'] AS err
FROM results
WHERE tile.raster IS NULL AND tile.path IS NULL
AND tile.metadata['last_error'] IS NOT NULL