@malloydata/malloy 0.0.324 → 0.0.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTEXT.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Malloy Core Package
|
|
2
|
+
|
|
3
|
+
The `malloy` package is the heart of the Malloy language implementation. It contains the compiler, translator, and runtime system that powers Malloy's semantic modeling and query capabilities.
|
|
4
|
+
|
|
5
|
+
## Package Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
packages/malloy/
|
|
9
|
+
├── src/
|
|
10
|
+
│ ├── lang/ # Translator: Parse tree → AST → IR (see src/lang/CONTEXT.md)
|
|
11
|
+
│ ├── model/ # Compiler: IR → SQL (see src/model/CONTEXT.md)
|
|
12
|
+
│ ├── dialect/ # Database-specific SQL generation
|
|
13
|
+
│ ├── api/ # Public API interfaces
|
|
14
|
+
│ ├── connection/ # Database connection abstractions
|
|
15
|
+
│ └── malloy.ts # Main entry point
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Two-Phase Architecture
|
|
19
|
+
|
|
20
|
+
The Malloy compilation process is split into two distinct phases:
|
|
21
|
+
|
|
22
|
+
### Phase 1: Translation (src/lang/)
|
|
23
|
+
The translator takes Malloy source code and transforms it into an Intermediate Representation (IR).
|
|
24
|
+
|
|
25
|
+
**Process:**
|
|
26
|
+
1. ANTLR parser generates parse tree from source code
|
|
27
|
+
2. Parse tree is transformed into Abstract Syntax Tree (AST)
|
|
28
|
+
3. AST is analyzed and transformed into IR
|
|
29
|
+
|
|
30
|
+
**Key characteristics:**
|
|
31
|
+
- IR is a **serializable data format** (plain objects, not class instances)
|
|
32
|
+
- IR fully describes the semantic model independent of SQL
|
|
33
|
+
- IR can be cached, transmitted, and reused across compilations
|
|
34
|
+
|
|
35
|
+
For detailed information about the translator, see [src/lang/CONTEXT.md](src/lang/CONTEXT.md).
|
|
36
|
+
|
|
37
|
+
### Phase 2: Compilation (src/model/)
|
|
38
|
+
The compiler takes IR and generates SQL queries for specific database dialects.
|
|
39
|
+
|
|
40
|
+
**Process:**
|
|
41
|
+
1. IR is read and analyzed
|
|
42
|
+
2. Query operations are transformed into SQL expressions
|
|
43
|
+
3. Dialect-specific SQL is generated
|
|
44
|
+
4. Metadata is generated for result processing
|
|
45
|
+
|
|
46
|
+
**Key characteristics:**
|
|
47
|
+
- Produces SQL that can be executed on target database
|
|
48
|
+
- Includes metadata to interpret and render results
|
|
49
|
+
- Dialect-agnostic until final SQL generation step
|
|
50
|
+
|
|
51
|
+
For detailed information about the compiler, see [src/model/CONTEXT.md](src/model/CONTEXT.md).
|
|
52
|
+
|
|
53
|
+
## Subsystem Context
|
|
54
|
+
|
|
55
|
+
For deeper details on specific subsystems:
|
|
56
|
+
- [src/lang/CONTEXT.md](src/lang/CONTEXT.md) - Translator architecture (grammar, AST, IR generation)
|
|
57
|
+
- [src/model/CONTEXT.md](src/model/CONTEXT.md) - Compiler architecture (SQL generation, expression compilation)
|
|
@@ -19,19 +19,21 @@ class BaseConnection {
|
|
|
19
19
|
try {
|
|
20
20
|
const cacheResponse = await fillCache();
|
|
21
21
|
if (typeof cacheResponse === 'string') {
|
|
22
|
-
|
|
22
|
+
// Don't cache errors - just return them
|
|
23
|
+
return { error: cacheResponse };
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
cached = {
|
|
26
27
|
schema: cacheResponse,
|
|
27
28
|
timestamp: refreshTimestamp !== null && refreshTimestamp !== void 0 ? refreshTimestamp : Date.now(),
|
|
28
29
|
};
|
|
30
|
+
this.schemaCache[schemaKey] = cached;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
catch (uncaught) {
|
|
32
|
-
|
|
34
|
+
// Don't cache errors - just return them
|
|
35
|
+
return { error: uncaught.message };
|
|
33
36
|
}
|
|
34
|
-
this.schemaCache[schemaKey] = cached;
|
|
35
37
|
}
|
|
36
38
|
if (cached.error) {
|
|
37
39
|
return cached;
|
|
@@ -43,6 +43,11 @@ class RenameField extends malloy_element_1.MalloyElement {
|
|
|
43
43
|
this.logError('invalid-rename-with-same-name', "Can't rename field to itself");
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
+
// Check if the new name would shadow an existing field
|
|
47
|
+
if (fs.entry(this.newName)) {
|
|
48
|
+
this.logError('invalid-rename-with-same-name', `Can't rename to '${this.newName}', field already exists`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
46
51
|
const oldValue = this.oldName.getField(fs);
|
|
47
52
|
/*
|
|
48
53
|
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.326";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.326';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.326",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "0.0.
|
|
45
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
46
|
-
"@malloydata/malloy-tag": "0.0.
|
|
44
|
+
"@malloydata/malloy-filter": "0.0.326",
|
|
45
|
+
"@malloydata/malloy-interfaces": "0.0.326",
|
|
46
|
+
"@malloydata/malloy-tag": "0.0.326",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
49
|
"jaro-winkler": "^0.2.8",
|