Hiperspace.SQL
2.5.18
Prefix Reserved
See the version list below for details.
dotnet add package Hiperspace.SQL --version 2.5.18
NuGet\Install-Package Hiperspace.SQL -Version 2.5.18
<PackageReference Include="Hiperspace.SQL" Version="2.5.18" />
<PackageVersion Include="Hiperspace.SQL" Version="2.5.18" />
<PackageReference Include="Hiperspace.SQL" />
paket add Hiperspace.SQL --version 2.5.18
#r "nuget: Hiperspace.SQL, 2.5.18"
#:package Hiperspace.SQL@2.5.18
#addin nuget:?package=Hiperspace.SQL&version=2.5.18
#tool nuget:?package=Hiperspace.SQL&version=2.5.18
Hiperspace.SQL
Hiperspace.SQL is a full SQL query engine for Hiperspace, supporting the full range of joins, aggregations, and subqueries.
Hiperspace.SQL provides the same query functionality as a .NET client can use with LINQ queries, but without the need to write code in C#/F#
Hiperspace fully supports point-in-time "time travel" queries that are not possible with Python Data-Frames or DuckDB
Features
- Hiperspace.SQL is not limited to queries of columns within a table, but supports the full navigation of properties of Hiperspace elements
- Where a column is a complex object, it is returned as a JSON object
- Executing a batch of SQL statements return columnar data frames (dictionary of column-name and array of values)
- Explain SQL returns the execution plan, detailing the SetSpaces accessed and keys used for search (Key, Index, Scan)
- The Parquet method returns a Parquet file that can be used with any Apache Parquet library, or added to DuckDB OLAP store
Data Dictionary
SCHEMA_TABLE
| Column Name | Data Type | Description |
|---|---|---|
| TABLE_NAME | string | The name of the table |
| TABLE_TYPE | string | The type of the table in SCHEMA_PROPERTY |
SCHEMA_COLUMN
| Column Name | Data Type | Description |
|---|---|---|
| TABLE_NAME | string | The name of the table |
| COLUMN_NAME | string | The name of the column |
| COLUMN_TYPE | string | The type of the table in SCHEMA_PROPERTY |
SCHEMA_PROPERTY
| Column Name | Data Type | Description |
|---|---|---|
| TYPE_NAME | string | The Type Name |
| PROPERTY_NAME | string | The name of each property |
| PROPERTY_TYPE | string | reference to SCHEMA_PROPERTY.TYPE_NAME |
Examples
Simple query
SELECT p.Name, p.Gender FROM Persons as p WHERE p.Name = 'Lucy'
Query parameters
SELECT p.Name, p.Gender FROM Persons as p WHERE p.Name = :name
Query batches
SELECT p.Name, p.Gender FROM Persons as p WHERE p.Name = :name;
SELECT Name as name, Father as father from Persons ;
Joins
SELECT p.Name, f.Name as Father, f.Father as GrandFather
FROM Persons as p
join Persons as f on p.Father.Name = f.Name
WHERE p.Name = :name
Aggregates
select p.Father.Name, count(p.Name) as Children
from Persons as p
group by p.Father.Name as f
having count(*) > 1;
Like expressions
select p.Father.Name, count(p.Name) as Children
from Persons as p
where Name like 'L%' and Name like '%y' or (Name like '%u%' and Name like '_uc_')
group by p.Father.Name as f
having count(*) > 1;
Null handling
select p.Name, p.Father.Name
from Persons as p
where Name is not null
in query
SELECT p.Name, p.Gender
FROM Persons as p
WHERE p.Gender in (select p2.Gender from Persons as p2 where p2.Name = 'Lucy')
union
SELECT p.Name, p.Gender
FROM Persons as p
WHERE p.Name in ('Lucy', 'Mark')
union
SELECT p.Name, p.Gender
FROM Persons as p
WHERE p.Name in ('Eve', 'Mary')
inline view
SELECT p.Name, p.Gender
FROM Persons as p
join (select p2.Gender from Persons as p2 where p2.Name = 'Lucy') as p3 on p.Gender = p3.Gender
dictionary query
select * from SCHEMA_TABLES;
select * from SCHEMA_COLUMNS;
select * from SCHEMA_PROPERTIES;
Hierarchy query
select p.Name as Parent, c.Name as Child
from Persons as p, p.MotherChild as c
where p.Name = :name;
is equivalent to
select p.Name as Parent, c.Name as Child
from Persons as p JOIN Persons as c ON p.Name = c.Mother.Name
where p.Name = :name;
since MotherChild is a set (of person) with each Person element, and any set can be joined with another set.
In this case there is an implicit join between the set MotherChild and the Person p.
Graph
The Cousins example
includes the property AllRelatives = allrelation(this) which uses the Cousins.Helper.AllRelations function
to return the set of HiperEdge for all graph nodes that can be recursively found in Hiperspace for each person.
The following query finds all the relations for a person
select p.Name as Person,
r.To.Name as Relation,
r.TypeName as Relationship,
r.Length as Length,
r.Width as Width
from Persons as p,
p.AllRelatives as r
where p.Name = :name;
NB : There is no need to use a JOIN clause as p.AllRelatives includes the implicit join to Person.
the ability to navigate graph relationships is a unique feature of Hiperspace.SQL
API
The Hiperspace.SQL API can be called from any language that supports DOTNET interop, including Python (using pythonnet). Access via the Hiperspace.SQL.Engine object that is constructed with reference to any domain space.
Explain
Provides a detailed breakdown of the query execution plan
member engine.Explain (source, parameters : IDictionary<string,obj>) : string array =
Execute
Executes the SQL queries and returns an array of Data Frames
member engine.Execute (source , parameters : IDictionary<string,obj>) : IDictionary<string, obj array> array =
Parquet
Executes the SQL queries will an array of filenames (one for each statement) and returns the filenames after writing the results to the Apache Parquet files.
member this.Parquet (source, fileNames, parameters : IDictionary<string,obj>): string array =
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FSharp.Core (>= 10.0.100)
- FsLexYacc (>= 11.3.0)
- FsLexYacc.Runtime (>= 11.3.0)
- HiLang (>= 2.5.8)
- Hiperspace (>= 2.5.16)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.0.0)
- Microsoft.CodeAnalysis.Analyzers (>= 4.14.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Parquet.Net (>= 5.3.0)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.0)
-
net8.0
- FSharp.Core (>= 10.0.100)
- FsLexYacc (>= 11.3.0)
- FsLexYacc.Runtime (>= 11.3.0)
- HiLang (>= 2.5.8)
- Hiperspace (>= 2.5.16)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.0.0)
- Microsoft.CodeAnalysis.Analyzers (>= 4.14.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Parquet.Net (>= 5.3.0)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
-
net9.0
- FSharp.Core (>= 10.0.100)
- FsLexYacc (>= 11.3.0)
- FsLexYacc.Runtime (>= 11.3.0)
- HiLang (>= 2.5.8)
- Hiperspace (>= 2.5.16)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.0.0)
- Microsoft.CodeAnalysis.Analyzers (>= 4.14.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.0.0)
- Parquet.Net (>= 5.3.0)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.5.26 | 46 | 12/21/2025 |
| 2.5.21 | 407 | 12/10/2025 |
| 2.5.18 | 655 | 12/3/2025 |
| 2.5.8 | 163 | 11/15/2025 |
| 2.5.2 | 190 | 11/6/2025 |
| 2.5.0 | 175 | 10/20/2025 |
| 2.4.6 | 183 | 9/23/2025 |
| 2.4.4 | 263 | 8/7/2025 |
| 2.4.2 | 150 | 7/28/2025 |
| 2.4.0 | 181 | 7/10/2025 |
| 2.3.8 | 171 | 7/1/2025 |
| 2.3.4 | 175 | 6/5/2025 |
| 2.2.2 | 190 | 5/5/2025 |
| 2.2.1 | 241 | 4/14/2025 |
| 2.2.0 | 127 | 3/29/2025 |
| 2.1.9 | 256 | 3/5/2025 |
| 2.1.6 | 155 | 2/15/2025 |
| 2.0.0 | 127 | 1/14/2025 |
| 1.0.5 | 145 | 11/15/2024 |
| 1.0.2 | 144 | 11/1/2024 |
| 1.0.1 | 188 | 10/18/2024 |
https://www.cepheis.com/hiperspace/20251303
## Overview
This release adds `NotFoundException` to distinguish *not found* from *cannot be found* conditions. and extends the functionality of `@AlternateIndex` to support multiple alternate indexes on *segments* and *aspects* that are referenced by multiple *entities*.
-----
### Not Found
Prior to this release `Get(...)` calls did not distinguish between *Not Found* and *not found because of IO error*. To improve the handling of missing values several changes have been made:
* Additional Exception class `NotFoundException`
* `KeyRef<>` (*reference to another element*) changed to return `null` when a value cannot be found
* `RefSingle<>` (*reference to an aspect*) changed to return `null` when a value cannot be found
-----
### AlternateIndex
Alternate indexes are created automatically whenever there is a path from an *element* from another *element*, but can be added to support access from a view. The prime example is `Edge` which is defined (*in the Hilang prelude*) as
```
"edge between nodes"
view Edge
( /* keys */
From : Node,
To : Node,
TypeName : String
)
{ /* values */
Name : String
};
```
`@AlternateIndex` enables an *element* to index the *key/value* that corresponds to the `From` key member for indexed access from a `Node.Froms` extension property
For the model
```
entity CostCentre (Id : Int32) [Costs : Cost (CostCentre = this)];
aspect Cost {CostCentre : CostCentre, Amount : Decimal};
```
with
```
entity Asset (...) {...} [Cost : Cost];
entity Project (...) {...} [Cost : Cost];
```
Concreate elements `AssetCost` and `ProjectCost` will be created indexes
`AssetCostCostCentre.Index` and `ProjectCostCostCentre.Index`
Source edit will change the source to
```
entity CostCentre (Id : Int32) [Costs : Cost (CostCentre = this)];
aspect Cost
{
@AlternateIndex("AssetCost", 42)
,AlternateIndex("ProjectCost", 43)
CostCentre : CostCentre, Amount : Decimal};
```
To ensure the index Id is not used for something else resultuing in an incompatible model and store.
***how does CostCentre know what (Asset/Project/ etc) the Cost is for?***
The `aspect Cost` is transformed to a `view` that is equvilent to
```
view Cost (owner : Any) {CostCentre : CostCentre, Amount : Decimal};
```
the (*C#*) hiperspace query
```
from centre in space.CostCentres
select centre.Id, (from line in centre.Costs
let asset = line.owner.Is<Asset>() ? Amount : 0
let project = line.owner.Is<Project>() ? Amount : 0
group line by line.CostCentre into totals
select new { Projects = totals.Sum(v => v.asset),
Assets = totals.Sum(v => v.project)})
```
Will return the total costs by type for each CostCentre
#### Inherited Index
This model defines an overall *trade* type with three different implementations for {*FI, EQ, FX*} that have different properties for the different asset-classes. *Trade* is referenced by *Book*, the extension property *`Book.Trades`* returns a collection of *Trade* has a *`Book`* equal to the current *Book*. For efficient access, and index is created for the *`Trade.Book`* that is inherited by each implementation.
The syntax `Banking.FI.Trade : Banking.Trade = Banking.Trade()` means `Banking.FI.Trade`:
* Inherits *keys / values / extensions / properties* from `Banking.Trade` (via **`:`**)
* Can be viewed as a `Banking.Trade` (via **`=`**)
```
view Banking.Trade (Id : String)
{Book : Banking.Book};
entity Banking.FI.Trade : Banking.Trade = Banking.Trade();
entity Banking.FX.Trade : Banking.Trade = Banking.Trade();
entity Banking.EQ.Trade : Banking.Trade = Banking.Trade();
entity Banking.Book (Id : String) [Trades : Banking.Trade (Book = this)];
```
Adding `%ids` to the model, with result in a source edit to a `#` id to each *element*, *key/value* and extension property, and `@AlternateIndex` property for each generated concrete index.
```
view Banking.Trade #45 (Id : String)
{@AlternateIndex("Banking.EQ.Trade", 52)
,AlternateIndex("Banking.FI.Trade", 48)
,AlternateIndex("Banking.FX.Trade", 50)
Book : Banking.Book};
entity Banking.FI.Trade : Banking.Trade = Banking.Trade() #49;
entity Banking.FX.Trade : Banking.Trade = Banking.Trade() #51;
entity Banking.EQ.Trade : Banking.Trade = Banking.Trade() #53;
entity Banking.Book #47 (Id : String #1) [Trades : Banking.Trade (Book = this) #54];
```
subsequent compilation of the model will result in the indexes using the same *Id* value when stored.
**NB** the `#id` can be of any value, but can never to reused for a different purpose once used with a *Hiperspace*.
-----
### Source Editing
When the directive `%ids` is added to a hilang model, the source code is edited to add `#id` values to ensure that the schema can be evolved without the risk of introducing incompatible changes.
***know issue***: Source editing lacks the context of other edits to a line of `hilang` source `@AlternateIndex("Banking.EQ.Trade", 52) @AlternateIndex("Banking.FI.Trade", 48) Book : Banking.Book` will create a syntax error the next time the *schema* is compiled because `@` is the prefix for a comma-separated list of one-or-more attributes. The code needs to be edited to change subsequent `@` to `,`