Check kind of type in Python (#909)
Moves the kind of type detection from the query for reflection from
EdgeQL to Python because the computed property use in the query turned
out to be too costly:
```
─────────────────────────── Query ───────────────────────────
analyze
with
module schema
select ➊ Type {
➋ kind := assert_exists(
'Object' IF Type IS ObjectType ELSE
➌ 'Scalar' IF Type IS ScalarType ELSE
➍ 'Array' IF Type IS Array ELSE
'NamedTuple' IF ➎ Type[IS Tuple].named ?? false ELSE
➏ 'Tuple' IF Type IS Tuple ELSE
➐ 'Range' IF Type IS Range ELSE
➑ 'MultiRange' IF Type IS MultiRange ELSE
➒ 'Pseudo' IF Type IS PseudoType ELSE
<str>{},
message := "unexpected type",
),
};
────────────────────────────────────────────── Coarse-grained Query Plan ──────────────────────────────────────────────
│ Time Cost Loops Rows Width │ Relations
root │ 2282.4 837696.69 1.0 248.0 32 │ schema::ArrayExprAlias, schema::Tuple, schema::ScalarType,
│ │ schema::Range, schema::RangeExprAlias, schema::MultiRange,
│ │ schema::TupleExprAlias, schema::PseudoType, schema::ObjectType,
│ │ schema::MultiRangeExprAlias, schema::Array
```
vs
```
──────────────────────── Query ────────────────────────
analyze
with
module schema
select ➊ Type {
➋ is_object := Type IS ObjectType,
➌ is_scalar := Type IS ScalarType,
➍ is_array := Type IS Array,
➎ is_named_tuple := Type[IS Tuple].named ?? false,
➏ is_tuple := Type IS Tuple,
➐ is_range := Type IS Range,
➑ is_multi_range := Type IS MultiRange,
➒ is_pseudo := Type IS PseudoType,
};
────────────────────────────────────────────── Coarse-grained Query Plan ──────────────────────────────────────────────
│ Time Cost Loops Rows Width │ Relations
root │ 210.6 6316.56 1.0 248.0 32 │ schema::ArrayExprAlias, schema::Tuple, schema::ScalarType, schema::Range,
│ │ schema::RangeExprAlias, schema::MultiRange, schema::TupleExprAlias,
│ │ schema::PseudoType, schema::ObjectType, schema::MultiRangeExprAlias,
│ │ schema::Array
``` N
Nik committed
460eee75d292b5f07d62362d85d359f0b1975d64
Parent: 3e66fe5
Committed by GitHub <noreply@github.com>
on 9/17/2025, 7:02:37 PM