README.md

July 13, 2025 · View on GitHub

GitHub license Nuget QSI Unit Tests

Logo

The QSI is the pure C# Query Structure Interface.

Languages

LanguageParserRepos
MySqlMySQL Workbench source code(Antlr4)mysql-fworkbench
SingleStorebased on Qsi.MySql
PostgreSqlPostgreSQL server source code(yacc)libpg_query
Redshiftbased on Qsi.PostgreSql
OracleAntlr4
SqlServerMicrosoft.SqlServer.TransactSql.ScriptDom, Microsoft.SqlServer.Management.SqlParserMSDN, NuGet (ScriptDom),NuGet (Management)
CassandraAntlr4
AthenaAntlr4
SAP HanaAntlr4
ImpalaAntlr4
TrinoTrino source code(Antlr4)trino
PrimarSqlPrimarSqlPrimarSql

Structure Compiler

It compiles the result structure and relation

based on semantic tree transformed by parser's for each language.

Status

Features MySql SingleStore PostgreSql Amazon Redshift Oracle SQLServer Cassandra(Cql) Amazon Athena SAP Hana Apache Impala Trino PrimarSql
No table
Table access
Derived table
Derived table (Non-Alias)
Specify columns to table alias
Inline derived table
Table function
Table variable
Common table expression
Join tables
Union many tables
Table pivot
Table unpivot
Trace view definition
Trace variable definition
Execute prepared table query
Call table procedure

Table Features

Done? Feature Example
No table
SELECT 1 AS a, '2' AS b
ColumnReferences
a1 (literal)
b'2' (literal)
Table access
-- table : id, name
SELECT * FROM table
ColumnReferences
idtable.id
nametable.name
Derived table
-- table : id, name
SELECT * FROM
    (SELECT * FROM table) AS alias
ColumnReferences
idalias.id
table.id
namealias.name
table.name
Derived table (Non-Alias)
-- table : id, name
SELECT * FROM
    (SELECT * FROM table)
ColumnReferences
idderived.id
table.id
namederived.name
table.name
Specify columns to table alias
-- table : id, name
SELECT * FROM table AS alias(a, b)
ColumnReferences
aalias.a
table.id
balias.b
table.name
Inline derived table
SELECT * FROM
    (
        VALUES (1, 2), (3, 4)
    ) AS inline_table(a, b)
ColumnReferences
ainline_table.a
1 (literal)
3 (literal)
binline_table.b
2 (literal)
4 (literal)
Table function
-- function : id, name
SELECT * FROM tbl_func('table function')
ColumnReferences
idno reference
nameno reference
Table variable
-- TODO
Common table expression
WITH cte AS (SELECT 1 AS n)
SELECT * FROM cte
ColumnReferences
n1 (literal)
Common table expression (Aliases)
WITH cte (n) AS (SELECT 1)
SELECT * FROM cte
ColumnReferences
n1 (literal)
Common table expression (Recursive)
WITH RECURSIVE cte AS (
    SELECT 1 AS n
    UNION ALL
    SELECT n + 1 FROM cte WHERE n < 10
)
SELECT * FROM cte
ColumnReferences
n1 (literal)
cte.n (recursive)
Join tables
-- left_table : name, uid
-- right_table : age, uid
SELECT * FROM
    left_table l
    JOIN right_table r ON l.uid = r.uid
ColumnReferences
nameleft_table.name
uidleft_table.uid
ageright_table.age
uidright_table.uid
Join tables (Pivot columns)
-- left_table : name, uid
-- right_table : age, uid
SELECT * FROM
    left_table
    JOIN right_table USING (uid)
ColumnReferences
uidleft_table.uid
right_table.uid
nameleft_table.name
ageright_table.age
Union many tables
SELECT a FROM first_table
UNION ALL
SELECT b FROM second_table
ColumnReferences
afirst_table.a
second_table.b
Table pivot
-- TODO
Table unpivot
-- TODO
Trace view definition
-- table_view : a, b
-- table : id, name
SELECT * FROM table_view
ColumnReferences
atable_view.a
table.id
btable_view.b
table.name
Trace variable definition
-- TODO
Execute prepared table query
-- TODO
Call table procedure
-- TODO

Development

Requirements

  • PowerShell
  • .NET 6.0
  • Java >= 1.8

Command

Setup

PowerShell

PS> cd ./qsi
PS> ./Setup.ps1

Terminal

cd ./qsi
./setup.sh

Publish

PS> cd ./qsi
PS> ./Publish.ps1 <VERSION> [-Mode <PUBLISH_MODE>]
  • <VERSION>

    Specifies the package version.

    Version must be greater than the latest version tag on git.

  • -Mode <PUBLISH_MODE>

    Specifies the publish mode.

    PUBLISH_MODEAction
    Publish(Default)Publish packages to NuGet, GitHub repositories
    LocalPublish packages to local repository
    ArchiveBuild packages to ./qsi/Publish

Debugger

It supports abstract syntax trees and semantic trees, and a debugger that can debug compilation results.

Preview

Run

$ cd qsi/Qsi.Debugger
$ dotnet run