Lang Sql
The SQL language core (commons lang-sql 0001-sql-lang, 0002-sql-ast-parser): a small, fast, portable front end for SQL in many dialects. lex turns text into tokens and comments with exact positions; parse reads the tokens into a syntax tree, a closed union whose child fields are typed by sort, and attaches each comment to its node; a dialect says how it is written (defineDialect) and how its grammar differs; and the walks (children, walk, findAll, fold), toSexp and the rewrites (rewriteScript and its kin, with the build of nodes) read and change a tree; the extensions extensions/query (selections and analyses) and extensions/unist (the projection to unist) are further exports. The folder imports only @intellectual-frontiers/core, so that it can be published alone as @intellectual-frontiers/sql-lang; the dialects are the other exports (./dialects/<name>), and the core names none.
Not here yet, and specified after these layers: writing SQL from a tree, the extraction of documentation from comments, the dialects beyond the three, and SQL over data that is not a database.
Entry points
src/mod.tssrc/aide/catalog/mod.tssrc/aide/exec/mod.tssrc/aide/guard/mod.tssrc/aide/introspect/mod.tssrc/aide/normalize/mod.tssrc/aide/plan/mod.tssrc/aide/profile/mod.tssrc/aide/relational/mod.tssrc/aide/text/mod.tssrc/dialects/athena/mod.tssrc/dialects/bigquery/mod.tssrc/dialects/clickhouse/mod.tssrc/dialects/databricks/mod.tssrc/dialects/doris/mod.tssrc/dialects/dremio/mod.tssrc/dialects/drill/mod.tssrc/dialects/druid/mod.tssrc/dialects/duckdb/mod.tssrc/dialects/dune/mod.tssrc/dialects/exasol/mod.tssrc/dialects/fabric/mod.tssrc/dialects/hive/mod.tssrc/dialects/materialize/mod.tssrc/dialects/mysql/mod.tssrc/dialects/oracle/mod.tssrc/dialects/postgres/mod.tssrc/dialects/presto/mod.tssrc/dialects/redshift/mod.tssrc/dialects/risingwave/mod.tssrc/dialects/singlestore/mod.tssrc/dialects/snowflake/mod.tssrc/dialects/solr/mod.tssrc/dialects/spark/mod.tssrc/dialects/spark2/mod.tssrc/dialects/sqlite/mod.tssrc/dialects/starrocks/mod.tssrc/dialects/teradata/mod.tssrc/dialects/trino/mod.tssrc/dialects/tsql/mod.tssrc/extensions/docs/mod.tssrc/extensions/plpgsql/mod.tssrc/extensions/query/mod.tssrc/extensions/unist/mod.ts
Modules
Examples
import { commentsOf, parse } from "@intellectual-frontiers/lang-sql";
const { script, comments, attachments } = parse("-- a note\nselect a from t");
comments[0]?.text; // " a note"
commentsOf(attachments, script.statements[0]!).leading.length; // 1Spec: 0001-sql-lang FR-001, FR-004, FR-009, FR-014, FR-015, FR-016, FR-017; 0002-sql-ast-parser FR-008, FR-016; 0003-sql-ast-tools FR-001, FR-003
Limits
What the modules of this area do not do, or do only in part, as each module's @limits says.