Hiperspace.SQL
2.6.5
Prefix Reserved
dotnet add package Hiperspace.SQL --version 2.6.5
NuGet\Install-Package Hiperspace.SQL -Version 2.6.5
<PackageReference Include="Hiperspace.SQL" Version="2.6.5" />
<PackageVersion Include="Hiperspace.SQL" Version="2.6.5" />
<PackageReference Include="Hiperspace.SQL" />
paket add Hiperspace.SQL --version 2.6.5
#r "nuget: Hiperspace.SQL, 2.6.5"
#:package Hiperspace.SQL@2.6.5
#addin nuget:?package=Hiperspace.SQL&version=2.6.5
#tool nuget:?package=Hiperspace.SQL&version=2.6.5
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.1.302)
- FsLexYacc (>= 11.4.0)
- FsLexYacc.Runtime (>= 11.4.0)
- HiLang (>= 2.6.5)
- Hiperspace (>= 2.6.5)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.6.0)
- Microsoft.CodeAnalysis.Analyzers (>= 5.6.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.6.0)
- Parquet.Net (>= 6.0.3)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.10)
- System.Numerics.Tensors (>= 10.0.10)
-
net8.0
- FSharp.Core (>= 10.1.302)
- FsLexYacc (>= 11.4.0)
- FsLexYacc.Runtime (>= 11.4.0)
- HiLang (>= 2.6.5)
- Hiperspace (>= 2.6.5)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.6.0)
- Microsoft.CodeAnalysis.Analyzers (>= 5.6.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.6.0)
- Parquet.Net (>= 6.0.3)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.10)
- System.Numerics.Tensors (>= 10.0.10)
- System.Text.Json (>= 10.0.10)
-
net9.0
- FSharp.Core (>= 10.1.302)
- FsLexYacc (>= 11.4.0)
- FsLexYacc.Runtime (>= 11.4.0)
- HiLang (>= 2.6.5)
- Hiperspace (>= 2.6.5)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.CodeAnalysis (>= 5.6.0)
- Microsoft.CodeAnalysis.Analyzers (>= 5.6.0)
- Microsoft.CodeAnalysis.CSharp (>= 5.6.0)
- Parquet.Net (>= 6.0.3)
- protobuf-net.Core (>= 3.2.56)
- System.CodeDom (>= 10.0.10)
- System.Numerics.Tensors (>= 10.0.10)
- System.Text.Json (>= 10.0.10)
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.6.5 | 100 | 8/2/2026 |
| 2.6.3 | 101 | 7/20/2026 |
| 2.6.2 | 126 | 7/6/2026 |
| 2.5.52 | 129 | 5/9/2026 |
| 2.5.50 | 121 | 4/24/2026 |
| 2.5.47 | 126 | 4/15/2026 |
| 2.5.43 | 119 | 4/1/2026 |
| 2.5.39 | 119 | 3/20/2026 |
| 2.5.35 | 125 | 2/27/2026 |
| 2.5.33 | 129 | 2/14/2026 |
| 2.5.32 | 137 | 1/30/2026 |
| 2.5.29 | 135 | 1/17/2026 |
| 2.5.28 | 142 | 12/31/2025 |
| 2.5.26 | 220 | 12/21/2025 |
| 2.5.21 | 458 | 12/10/2025 |
| 2.5.18 | 704 | 12/3/2025 |
| 2.5.8 | 226 | 11/15/2025 |
| 2.5.2 | 247 | 11/6/2025 |
| 2.5.0 | 228 | 10/20/2025 |
| 2.4.6 | 232 | 9/23/2025 |
https://www.cepheis.com/hiperspace/20260802
# Overview
This release enhances the support for alternate indexes to include nested values and handling of unique references to other entities.
This enhancement removes the need to define additional element values to support view access.
---
## Alternate Index
The normal/**best** way to define an index is to include an access path. The following *model* defines a Customer and Account ***and*** implicitly an alternate index for navigation from Customer to all accounts.
```
entity Customer (Id : Int32){Name : String}[Accounts : Account (Customer = this)];
entity Account (Id : Int32){Customer : Customer};
```
The `@AlternateIndex` property of a *key*/*value* allows for indexes to be created where it is not possible to define an access path (e.g. to `segment` or `aspect` that may have multiple implementations. If Account is instead defined as a *segment*, it would not be possible to define an access path from `Book` to `Account` since the segment could be defined for any number of *elements*.
```
entity Customer = Node ()(Id : Int32) {Name : String} [Accounts : Account, TypeName = "Customer"];
segment Account = Node(), Edge() (Id : Int32) {Name : String, @AlternateIndex Book : Book} [TypeName = "Account", From = Book, To = this];
entity Book = Node() (Id : Int32) {Name : String}[TypeName = "Book"];
```
When `Book` is viewed as a *graph* `Node`, it has a `Froms` collection of `Edge` that includes all *Accounts* that refer to the `Book`. `@AlternateIndex` creates an access path to `Account` from `Book`.
### ISO20022
[ISO20022.Static.BranchAndFinancialInstitution](https://github.com/channell/Hiperspace.ISO20022/blob/291d6bb1f03bc6925d31b702ccc53986a4217903/Static.hilang#L498) includes a nested value `ISO20022.Static.FinancialInstitution` that could be a *Bank*, a *LegalEntity* or both.
```
entity ISO20022.Static.BranchAndFinancialInstitution
= Node (Name = FinInstnId.Nm, SKey = SKey, TypeName = "ISO20022.BranchAndFinancialInstitution")
, ISO20022.Edges
( From = this
, To = Bank
, Name = BankName
, FromTypeName = "BranchAndFinancialInstitution-Bank"
, ToTypeName = "Bank-BranchAndFinancialInstitution"
)
(
@XmlElement BrnchId : ISO20022.Static.BranchData,
@XmlElement FinInstnId : ISO20022.Static.FinancialInstitution,
)
[
@XmlIgnore, JsonIgnore
Bank : ISO20022.Static.Bank (AnyBIC = FinInstnId.BICFI),
]
```
This release adds the option to include `@AlternateIndex` for `ISO20022.Static.FinancialInstitution.BICFI` and have an index on every *entity/segment/aspect* that includes the `FinancialInstitution` reference. When `ISO20022.Static.Bank` is viewed as a graph `Node` it will include a *edges* to and from every `BranchAndFinancialInstitution` that referenes it.
---
## Unique Reference
When an *element* has an extent reference to another *element* it is normally a **set**, in the top example `Customer.Accounts` is a set because any number of `Account` could refer to `Customer`, but if the parameter to the reference is the same as key of the referenced *element* it is included as **single** since it will never have more than one value. When an *element* includes a reference to an `aspect` (single value inheriting the owner’s key) the **single** value behaves like a nested value:
* Reading the `Value` does a lazy lookup from the `SubSpace` cache, or from the underlying `HiperSpace`
* Setting the `Value` copies the *owner* key to the aspect transparently to behave like a value but stored seperately.
This release add the ability set foreign references in the same way as `aspect`, but instead of binding the *owner* of the aspect, the parameter fields in the referencing element are updated.
For the ISO20022 example above the code `var aBranch = new BranchAndFinancialInstitution { Bank = goldmanSachs };` will assign `goldmanSachs.AnyBIC` value to `aBranch.FinInstnId.BICFI` since that is semantically equvilent to `var aBranch = new BranchAndFinancialInstitution { FinInstnId = new ISO20022.Static.FinancialInstitution { BICFI = goldmanSachs }};`
---
# Worked Example
The [ISO20022](https://github.com/channell/Hiperspace.ISO20022/blob/main/Static.hilang) includes the defintion of **Party** that can *optionally* reference *a Legal Entity*, *a Bank* or *both*, in addtion to generic *person* nand *branch* information. The entity can be *viewed* as a `Node` in graph (*with the `TypeName` "ISO20022.Party"*) **and** up to four `Edge`:
* **Party-Bank** (*if `OrgId.AnyBIC` has a value*) - via Party Key
* **Bank-Party** (*if `OrgId.AnyBIC` has a value*) - via Party AnyBIC index
* **Party-LegalEntity** (*if `OrgId.LEI` has a value*) - via Party Key
* **LegalEntity-Party** (*if `OrgId.LEI` has a value*) - via Party LEI index
if we query `SELECT node, edge.To AS Party FROM Nodes AS node, n.Tos /*implicit join*/ AS edge WHERE node.Name = 'Goldman Sachs' AND edge.TypeName = 'Bank-Party';` will return a result set of all *parties* that participate in an ISO20022 message for the Bank with the name Goldman Sachs. The query plan will perform:
1. Create a template `Node` with `Name` "Goldman Sachs"
2. Query `SetSpace<Node>` for all `Node` that has a index on Name (*including `node.TypeName = 'ISO20022.Bank'` would limit the query to `SetSpace<Bank>`*)
3. Create a template `Bank` with `Name` "Goldman Sachs"
4. Query `SetSpace<Bank>` using the Bank Name index
3. Create a template `Edge` with `From` set to the `Node` object for "Goldman Sachs" and TypeName 'Bank-Party'
4. Query `SetSpace<edge>` (*since edge TypeName is set, only `SetSpace<Party>` is searched*)
5. Create a template `Party` with `Bank` set to "Goldman Sachs" (*the `binder` code adds an `OrgId` value, and set `OrgId.AnyBIC` to `Bank.AnyBIC`*)
6. Query `SetSpace<Party>` using the Party AnyBIC index
7. Project a data frame of Node and Party
The following LINQ query will traverse the graph of nodes through all edges (upto a length 100) to find CreditTransferTransaction associated with "Goldman Sachs":
```
from node in space.Nodes
where node.Name == "Goldman Sachs"
let transfer = node.HiperEdges("*", 100, new HashSet<string> {"Fact:ISO20022.Cube.CreditTransferTransaction"}
select transfer;
```
For **Hiperspace.DB** the graph search will use GPU parallel search, otherwise a parallel pipeline is used.
---
## Referenced libraries
External references have been updated to the latest version