BQL

BQL changes in 3.0

Every change from 2.x to 3.0 that makes an existing BQL query fail or return something else — queries that no longer parse, conditions that select other objects, values, grouping and aggregates, the structure of the records, limits and the table export — with what to do for each.

This page lists every change from 2.x to 3.0 that makes a BQL query you already run fail, or return other objects, other values or another structure, and what to do about it. It applies wherever BQL runs: queries sent from the SDKs and the OpenAPI, stored query actions, and the BQL inside BVL, BCL, BRL and the other languages. The instance rewrites a stored action once, as a new version, when the only reasons it no longer parses are the changes under Queries that no longer parse (changelog/v3-0/from-2-to-3#stored-actions); the queries your application keeps itself get the same rewrite from UpgradeSyntax, many in one request (Convert 2.x queries to 3.0). Fix the rest yourself: run the queries on a 3.0 test instance and fix what fails. changelog/v3-0/from-2-to-3#query-languages has the short version; the new language features are on BIM.works 3.0 and in BQL.

Unchanged: the response envelope ({"objects": […]} from Query2, a bare array from the OpenAPI), the shape of a plain attribute, property or quantity value, comments and string literals, case-sensitive keywords, type conditions with their subtypes and NI, case-insensitive text comparison with the CS prefix, NOT as a full complement, property paths and their quoting, the relation steps (buildingStorey, space, containedIn, typeObject, children, …), the qid format, the USING units, and LIMIT and OFFSET.

Many value changes appear only once a model has been reindexed on 3.0. Until then the model is answered from its 2.x data (changelog/v3-0/from-2-to-3#model-data).

Every change has a class:

  • Breaking: the query no longer parses, or fails.
  • Behaviour: the query runs, but selects other objects or returns other values or another structure. Often 2.x was wrong.
  • Deprecated: still works; use the replacement.
  • Requirement: what the caller needs.

Overview#

Change 2.x 3.0 Class
Unit conversion in GET IN <unit>, ignored UNIT <unit>, converted; IN <unit> no longer parses Breaking, Behaviour
Reserved words — about 140 more, among them lowercase length, area, status; unquoted names spelled like them no longer parse Breaking
CS LENGTH parsed no longer parses Breaking
A query sent as a JSON syntax tree the 2.x tree the 3.0 tree Breaking
Syntax errors one message; some malformed queries ran partly line L:C: …, up to three; no partial runs Behaviour
f = null explicit nulls only, almost nothing every object without a value Behaviour
f != null, a bare f, ranges, numeric IN the object's own values also values from its type object Behaviour
BETWEEN upper bound excluded both bounds included Behaviour
Decimals in WHERE truncated to whole numbers in the index exact Behaviour
= 0.3 m, IN (100 mm, 0.2 m) the number looked up without its unit converted Behaviour
Literals in ft, in, km, l, ac, … the unit dropped converted Behaviour
a > b between two features NOT_IMPLEMENTED works Behaviour
a = b between two features NOT_IMPLEMENTED works Behaviour
model.discipline exact; != matched everything also sub-disciplines; != works Behaviour
Calculated quantities, geometry, units the native engine, 2.x unit handling the Java engine, mesh metrics, fixed units Behaviour
GROUP BY a, b the first key only every key Behaviour
Objects without the group key dropped a [none] group Behaviour
Text group keys case-insensitive case-sensitive Behaviour
COUNT(f) every object objects with a value of f Behaviour
Two aggregates of one kind one lost the second keyed by its full text Behaviour
Empty MIN, MAX, RANGE, MEDIAN ±1.797E308, or an error NaN Behaviour
Order over several models could change between requests stable Behaviour
AS the key of a computed column; ignored on stored features names the column in columns, moves no value; alias_keys: true keeps the old placement Breaking
A UNIT column the full value, unconverted a smaller, converted leaf Behaviour
A grouped attribute.X flat under attribute nested as attribute.X Behaviour
calculated.* — measurement on every value, plus details Behaviour
Response size no clean limit 256 MB, then PAYLOAD_TOO_LARGE Requirement
Rights — the query:run scope; read rights on a stored query Requirement
Table export (CSV, XLS, XLSX) no header, cells shifted a header and aligned columns Behaviour
The JSON BimQuery supported deprecated Deprecated

Queries that no longer parse#

IN <unit> is UNIT <unit> (Breaking, and Behaviour). The unit clause after a GET feature is UNIT; IN stays the list comparator of WHERE.

BQL#
GET quantity.Qto_WallBaseQuantities.Height UNIT mm WHERE quantity.Qto_WallBaseQuantities.Height IN (2000, 3000)
BQL#
GET quantity.Qto_WallBaseQuantities.Height IN mm

Replace IN directly before a unit: \bIN\s+(mm|cm|dm|m|km|in|ft|yd|mi|mm2|cm2|dm2|m2|km2|in2|ft2|yd2|mi2|ac|mm3|cm3|dm3|m3|in3|ft3|yd3|l|mg|cg|g|kg|dc)\b → UNIT $1. 2.x parsed the clause but never applied it: GET … IN mm returned the value in its stored unit. After the rewrite the value really is converted, an explicit UNIT wins over USING for its column, and the column has a smaller leaf (below). If you relied on the 2.x numbers, drop the clause instead of converting it (UNIT).

New reserved words (Breaking). Keywords are case-sensitive, and a keyword wins over a name, so an unquoted set, property, quantity or alias spelled exactly like a new keyword no longer parses. IFC's own names are PascalCase (Length, Width, Status) and are not affected; sets written by Revit, ArchiCAD or other exporters sometimes use lowercase names. The new lowercase and camelCase keywords:

area, length, thickness, status, path, item, local, world, figure, figures, details, quality, measurement, members, representation, identifier, header, gis, sem, deg, rad, climb, clearance, headroom, usableArea, usableAreaFactor, convertGeoReference, providesBoundariesFor, isBoundedBy, uploadedOn, uploadedBy, suggestion, suggestedType, predefinedType, predefinedStatus, confidence, confidence1 to confidence3, candidate1 to candidate3, manifold, watertight, repaired, repairArchetype, orientationConsistent, degenerateTriangles, originalVolume, originalWatertight, and the calculated quantity names frontArea, backArea, topArea, footprintLength, footprintWidth, footprintArea, grossSurface, netSurface, grossVolume, netVolume, shortestLength, axisLength, longestLength, minThickness, maxThickness, sectionWidth, sectionHeight, outlineSurface, endsSurface, outerPerimeter, openingPerimeter, totalPerimeter, totalRise, riserCount, treadCount, riserHeight, minRiserHeight, maxRiserHeight, runWidth, runDepth, treadDepth, openingArea, openingDepth, openingVolume.

The new uppercase ones: UNIT, MODELS, WITHIN, CASE, WHEN, THEN, ELSE, END, ABS, FIRST, DISTINCT, COALESCE, GREATEST, LEAST, ROUND, FLOOR, CEIL, POWER, SQRT, MOD, CONCAT, UPPER, LOWER, TRIM, LEFT, RIGHT, SUBSTRING, SPLIT_PART, REPLACE, REGEX_EXTRACT, CHAR_LENGTH, TO_NUMBER, TO_STRING, LOOKUP, REFERENCE, SLICE, PROJECTION, FROM, TOLERANCE, FILL_HOLES, DIRECTION, ABOVE, BELOW, MINIMUM_RECTANGLE, SITE, ABSOLUTE, LOWEST, ELEVATION, THROUGH, AGENT, NEAREST, CENTROID, SPATIAL, GEOTECHNICAL, BRIDGE, ROAD, RAILWAY, PORTS_AND_WATERWAYS, TIMBER_STRUCTURE, VERTICAL_TRANSPORT, TUNNEL, SURVEY, and the unit and function names that go with them.

Quote such a name; quoted names parse at both versions. name, type, value, unit, description, height, width, depth, volume, perimeter, level, location, color, source and id were already reserved in 2.x.

BQL#
GET qid, property.Dimensions."length" AS "len" WHERE property.*."status" = "New"
BQL#
GET qid, property.Dimensions.length WHERE property.*.status = "New"

CS LENGTH is LENGTH (Breaking, rare). CS never changed the result; drop it. LENGTH != n is new.

A query sent as a JSON syntax tree (Breaking). Query2 still takes a tree ("__type": "Bql") instead of text, but the tree changed shape: qids, parameters, length comparisons, feature comparisons, numeric values and the IN comparators are written differently. The 2.x JavaScript QueryHelper built the 2.x tree. Send the query text, or build the 3.0 tree with the 3.0 SDK (AST).

Syntax errors (Behaviour). A query with a syntax error is refused with SYNTAX_ERROR and messages such as line 1:9: missing EOF at 'WHER', up to three, joined by ; ; input that is no query reads line 1:1: the input is not a BQL query. 2.x ran the part it could parse of some malformed queries; those fail now. FIRST(x) takes only qid.

A type in mixed case (Behaviour). type = IfcWall was a syntax error in 2.x; in 3.0 it parses and fails with UNKNOWN_TYPE ("Unknown IFC type: IfcWall"). Type names stay upper case. Only the error code changes.

Deprecated spellings. UseableAreaFeature(...), UseableAreaFactor(...), UseableAreaFactorFeature(...) and Headroom(...) still parse, with a warning; use geometry:usableArea, geometry:usableAreaFactor and geometry:headroom.

Everything else 2.x accepted keeps its meaning. 3.0 accepts more: whitespace inside the formerly glued keywords (LENGTH_UNIT =, header .), USING clauses in any order, whole numbers where a decimal was required, NOT IN, BETWEEN a AND b, parameters in most places.

Different objects selected#

= null means "no value" (Behaviour, large). In 2.x f = null found only objects with an explicit null, which is almost none, and on quantities it failed. In 3.0 it finds every object that has no value for f: no property, a null, or nothing on its type object either. It covers attributes, property.<Set>.<Name>, property.*.<Name>, quantities and calculated quantities. A "missing data" check now finds what it was written for; re-validate the reports and checks built on it. There is no way to get the 2.x meaning back.

BQL#
GET qid WHERE type = IFCDOOR AND property.Pset_DoorCommon.FireRating = null

!= null and a bare feature (Behaviour). These are the exact complement of = null: the object's own values plus the values on its type object. A value that is only a null does not count. Expect more matches where data lives on type objects (reference/bql/where#has-value).

Type-object values in comparisons (Behaviour). = already looked at type objects in 2.x. Now >, >=, <, <=, BETWEEN, numeric IN and the comparisons evaluated per object do too, unless the object has a value of its own: property.Pset_DoorCommon.Factor > 1 finds the doors whose type says 1.5. Quantities and calculated values are never taken from a type object (reference/bql/type-objects#where).

BETWEEN includes both bounds (Behaviour). 2.x read BETWEEN (a, b) as >= a AND < b from the index (and inclusive elsewhere); 3.0 reads >= a AND <= b everywhere. Objects whose value equals the upper bound now match.

Decimals are exact (Behaviour; 2.x was wrong). The 2.x index cut decimal values to whole numbers in their canonical unit, query values included. So NetFloorArea > 10.5 behaved as > 10, = 12.5 matched everything from 12 up to 13, and NetVolume > 0.5 on m³ matched nothing below 1 m³. Lengths in millimetres were mostly unaffected; areas, volumes, masses and ratios were. 3.0 keeps the decimals; a model needs its reindex for this.

A literal with a unit in =, != and IN (Behaviour; 2.x was wrong). 2.x looked quantity.*.Width = 1.05 m up as 1.05 in the millimetre index; ranges did convert. 3.0 converts every literal: = 0.3 m and IN (100 mm, 0.2 m) match (reference/bql/unit#literals).

Non-metric literals (Behaviour; 2.x was wrong). 2.x knew only mm to m, mm² to m², mm³ to m³, mg to kg and °C, and silently compared > 10 ft, < 1 km, > 2 l or > 1 ac as bare numbers. 3.0 converts every unit.

Comparing two features (Behaviour; 2.x was wrong). In 2.x a > b, a < b and the other orderings between two features compared the other way round and ignored units, so they returned roughly the complement; a = b and a != b failed with NOT_IMPLEMENTED. In 3.0 the right side of a comparison can be any arithmetic expression, and the comparison is correct and converts units. A query that "worked" by writing the operator the wrong way round must be turned back.

BQL#
GET qid WHERE quantity.Qto_WallBaseQuantities.Height > quantity.Qto_WallBaseQuantities.Width

A number without a unit (unchanged). It compares in the canonical unit: millimetres, m², m³, kg and degrees, not the model's unit. On a model in metres, quantity.Qto_WallBaseQuantities.Height > 2.5 means 2.5 mm, at both versions. Write units in WHERE literals (reference/bql/where#comparisons).

model.discipline (Behaviour). A value matches the model's disciplines and their sub-disciplines (= HVAC matches a ventilation model), and != and NOT IN are the complements. In 2.x != matched every model with a known discipline, the excluded one included. Every IFC check-in now suggests a discipline, so a model's disciplines can differ from 2.x.

Smaller fixes (Behaviour):

  • LENGTH on a list value evaluated every operator as <= in 2.x.
  • A decimal literal also finds whole-number values (Count = 2.0, Count > 1.5), and quantity.<Set>.<Name> = 2700 mm finds a stored 2700.0.
  • Evaluated per object, quantity.*.<Name> read a property of that name in 2.x; it reads the quantity now.
  • Enumerated, list and bounded property values are read per object too, so text functions and = null agree with the index.
  • A condition that fails in a grouped or aggregate query answered an empty result in 2.x; 3.0 fails with "The condition could not be evaluated: …" or MODEL_NOT_AVAILABLE.
  • A visitor of a published workspace queries through the workspace's filter, and features it hides are left out of GET (hiddenFeatures) or refused in WHERE with FEATURE_NOT_VISIBLE. Accounts and tokens see no change.

Values#

Calculated quantities are recomputed (Behaviour). calculated.quantity.volume, floorArea and perimeter came from the native geometry engine in 2.x; in 3.0 they are metrics of the stored mesh, converted to the model's units. floorArea is projected on the plan, so it is smaller under sloped soffits, ramps and roofs; perimeter follows the boundaries of the faces (a stair counts every step) instead of a 2D outline, on far more products. Spatial objects (project, site, building, storey) carry the totals of their contents instead of placeholders, and zones the total of their contents instead of the union of their spaces, so a sum over all objects counts the contents two or more times. About 40 further quantities are new (netVolume, grossVolume, outerPerimeter, …); where their definition fits, prefer them (Calculated values, How calculated quantities are measured).

Another geometry engine (Behaviour). 3.0 tessellates with its own Java engine, also during the reindex. aabb.*, calculated.aabb.*, calculated.obb.*, the geometry counts, hasGeometry, every calculated quantity and the geometric conditions (geometry:contained_in, CLASHES_WITH, ORDER BY GEOMETRY) run on the new meshes: expect small differences, and a few objects that gain or lose geometry.

Unit conversions fixed (Behaviour; 2.x was wrong). 2.x converted feet, yards and miles with the inch factor, multiplied kilometres by 1000 twice, converted centimetres to decimetres by ×100, and used the in² factors for ft², yd², mi², ac and dm², and a wrong one for yd³. Models in imperial units, and conversions into those units, give other numbers now. USING LENGTH_UNIT= still takes mm, cm, dm and m only.

Units read at check-in (Behaviour, after the reindex). Models in feet are recognised (2.x labelled them metres); derived units such as N, kN, Pa, kPa, MPa and W/K are labelled instead of unitless; values in conversion-based units (gallon, pound, hectare, …) are rescaled to a base unit; dates are unitless. So the unit and symbol of many property values change, and some numbers are rescaled. The fields of the value (value, unit, symbol, original_unit, original_value, original_symbol) are the same.

Aggregates over mixed units (Behaviour). The first value with a unit decides the unit of the aggregate, values of the same kind are converted into it, and values without a unit are added as they are. 2.x converted the wrong way round, and dropped the column on a value without a unit, such as an IFCQUANTITYCOUNT.

Systems are indexed for IFC4 (IfcDistributionSystem, IfcBuildingSystem, IfcDistributionCircuit, …), so system.* is no longer empty for IFC4 MEP models.

Grouping and aggregates#

Every key counts (Behaviour, large). GROUP BY a, b gives one record per combination of keys, ordered by the first key, then the second. 2.x grouped by the first key only and took the others from an arbitrary member (reference/bql/group-by#multi-key).

BQL#
GET buildingStorey.attribute.Name, type, COUNT(qid) GROUP BY buildingStorey.attribute.Name, type

A [none] group (Behaviour). Grouping adds a group for the objects without a value, whatever the key (an attribute, a property, a quantity, a material, a classification, a layer, a zone, a system, a related object such as buildingStorey.attribute.Name), and at every level of a multi-key grouping; 2.x dropped those objects. Its record has the aggregates but no key. An object whose value is only on its type object falls into it. Dashboards that add up the groups or walk over them should skip that record, or add WHERE <key> != null (reference/bql/group-by#none).

Text keys are case-sensitive (Behaviour). 2.x grouped text on its upper-cased index value, so "Concrete" and "CONCRETE" were one group, shown with the first member's spelling. 3.0 groups on the stored text: more groups where the spelling varies. Decimal keys are no longer cut to whole numbers either.

COUNT(f) (Behaviour). It counts the objects that have a value of f; 2.x counted every object in the group. COUNT(qid) is the group size, as before: use it for "number of objects".

Keys of aggregate columns (Behaviour). Without an alias an aggregate is keyed by its keyword (COUNT, MIN, MAX, AVG, MEDIAN, MODE, RANGE, STDDEV), SUM by SUM(<argument>) and COLLECT by COLLECT(<arguments>), as before. Two of one kind wrote both under one key in 2.x, and one was lost; now the second is keyed by its full text, such as MAX(quantity.Qto_WallBaseQuantities.Height). The value objects are unchanged.

Empty aggregates (Behaviour). Over a group without values every numeric aggregate is NaN, written as the string "NaN": {"type": "double", "value": "NaN"}. 2.x gave ±1.7976931348623157E308 for MIN, MAX and RANGE, failed for MEDIAN, and gave NaN for AVG. SUM is 0, as before. Parse such values defensively.

Order (Behaviour):

  • Over several models, unordered results come in a stable order: models by version, objects by id. In 2.x the order, and so every LIMIT … OFFSET page, could change between requests.
  • ORDER BY model.name, model.discipline, model.ifcVersion and model.filesize sort; 2.x returned an empty result.
  • ORDER BY GEOMETRY(...) keeps objects without geometry, at the end, and objects at the same place.
  • GROUP BY … ORDER BY on group values that are neither numbers nor text sorts on their text; 2.x failed.

Unchanged, and worth knowing: ORDER BY a, b sorts by a only and leaves out the rows without a value of a; there is no default or maximum LIMIT; a GET item in a grouped query that is neither a key nor an aggregate gives an arbitrary member's value (3.0 warns about it) (ORDER BY, LIMIT and OFFSET).

The structure of the records#

AS names a column and moves no value (Breaking). A record is the same with or without aliases: a stored feature is under its path, a computed column under its text, an aggregate under its keyword or text (reference/bql/get#alias). The alias is the alias and label of the item in the answer's columns, which say where each item's value is (reference/bql/output#columns), and the header of a table export. In 2.x an alias was the key of a computed column (an aggregate, arithmetic, eval(...), a shape, BOX, …) and was ignored on a stored feature; early 3.0 builds put aliased stored features under their alias too.

BQL#
GET COUNT(qid) AS walls, SUM(quantity.*.NetVolume) AS wallVolume, attribute.Name AS nm WHERE type = IFCWALL GROUP BY attribute.Name

answers records such as {"attribute": {"Name": {…}}, "COUNT": {…}, "SUM(quantity.*.NetVolume)": {…}}, where 2.x answered {"attribute": {"Name": {…}}, "walls": {…}, "wallVolume": {…}}. Change your code in one of two ways:

  • read values through the columns: in JavaScript QueryColumns.get(record, "walls", records.columns), or QueryColumns.byLabel(records) for records keyed by label (row.walls); in Java queryWithColumns; over the OpenAPI "columns": true on Query;
  • or keep the old placement, as a stopgap: "alias_keys": true on Query, aliasKeys: true on Query2, client.bim.setAliasKeys(true) (or the aliasKeys option of one query) in the JavaScript SDK, setAliasKeys(true) on the Java SDK's BimApi.

Two different items that would share a key now fail with DUPLICATE_COLUMN instead of one overwriting the other: two calls of one relation with different WHERE clauses both write the relation's name. A UNIT column is keyed by its whole text (below).

A UNIT column (Behaviour). The converted value, in a leaf {"type": "double", "value": …, "unit": "<unit>"}: type in lower case, a symbol for derived dimensions, and without the name, oid, classType, description, set name, symbol and original_* fields of a full value. It is keyed by its whole text, unit included ("quantity.*.NetVolume UNIT m3"), so the same feature in two units is two columns; with alias_keys: true by its alias, or else its path. A unit of another kind than the value gives no value, and a requested feature without a value comes back as an explicit null. Arithmetic columns are written the same way (reference/bql/unit#result).

Values from type objects (Behaviour). In 2.x an object's own value could carry "origin": "type" and fields of its type's value; now origin appears only on a value that really comes from the type (reference/bql/type-objects#merging).

Calculated values (Behaviour). Every calculated.quantity.<name> value has a measurement object (status, method, accuracy, quality), and calculated.* adds calculated.details, about 7 KB per object, and the new calculated fields. GET calculated.* answers grow several times (reference/bql/calculated-values#measurement).

A grouped attribute.X (Behaviour). It comes back nested, {"attribute": {"X": {…}}}, as in an ungrouped record; 2.x wrote it flat, {"attribute": {"name": "X", …}} (reference/bql/group-by#result).

Labels in group records. property.meta, calculated.aabb.<f>, model.<field> and quantity.* are labelled by their path; 2.x wrote wrong labels or failed.

classification.* has identification next to the other fields.

New keys in the envelope appear only with new request options: groups, groupPath, groupKeys and groupLevel, qids, and hiddenFeatures when a workspace hides features (Output).

Rights and limits#

  • Rights (Requirement). Query2, QueryCount, TableExport, ValidateQuery, the Query task and the OpenAPI /ifc/Query need the query:run scope; IFC and ifcXML output also model:read. Running a stored query by its uuid needs read rights on it (NO_READ_RIGHTS, OBJECT_NOT_FOUND); 2.x did not check.
  • Response size (Requirement). An answer over 256 MB, by default, fails with PAYLOAD_TOO_LARGE; in 2.x it timed out, failed in the client or came back empty. Page with LIMIT and OFFSET, which is stable now, or ask for compression.
  • Features on by default. Clash detection (CLASHES_WITH) and the text index (MATCHES, TEXT_MATCHES) are on by default, so queries that failed with FEATURE_NOT_ENABLED on a default 2.x instance run. A clash query is bounded per request.

Other ways results come out#

The table export (Behaviour). CSV, XLS and XLSX are built from the query's records: a header row (the alias or the feature), one column per GET item, an empty cell for a missing value, numbers as numbers, the aggregates, multiple values joined with ", ", a column per name for a wildcard, and type-object values. In 2.x a missing value shifted the later cells one column to the left, there was no header, and numbers and aggregates were left out. Read the columns by their header, not by position (reference/bql/output#tables).

The JSON BimQuery (Deprecated). The Query task with a JSON query, and the Java BimQuery class, still run; discipline filters follow the hierarchy, and aggregations are refused when a workspace filter applies. Send BQL text.

The OpenAPI POST /ifc/Query (Behaviour). The JSON answer is the same bare array. New are a format field (json, count, qids, csv, xlsx, ifc, ifcxml), parameters, groups and action_uuid. An empty models array validates the query and answers {"messages": […]} instead of running it, and errors have their own HTTP status instead of 500.

New, nothing to change#

Nothing below changes a query that does not use it; BQL describes each: UNIT and arithmetic in GET; arithmetic and feature comparisons in WHERE; WITHIN tolerances; ABS; value functions (COALESCE, ROUND, UPPER, CONCAT, TO_NUMBER, …); CASE … WHEN … THEN … ELSE … END; aggregates over relations (children(SUM(x) WHERE …)); FIRST(qid); COLLECT(DISTINCT …); the SLICE(h) and PROJECTION(...) shapes; the members relation; classification[...] filters; classification.meta, layer.meta and material.meta; representation.*; suggestedType and suggestion.*; geometry:clearance; nav:* routes; model.filename, path, uploadedOn and uploadedBy; model.SUM(...); the new disciplines; the angle units deg and rad; parameters everywhere; BETWEEN a AND b; NOT IN; LENGTH !=; niceType in WHERE; calculated.figures, details and the consistency fields; groups by path (groupPath, groupKeys); compactQids; parameters bound on the server; virtual features.