@malloydata/malloy 0.0.429 → 0.0.431

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.
@@ -1,3 +1,4 @@
1
+ import type { BuildIdOptions } from '../../model';
1
2
  import type { LogMessage } from '../../lang';
2
3
  import type { PersistNode } from '../../model/persist_utils';
3
4
  import type { Model, PersistSource } from './core';
@@ -46,5 +47,9 @@ export declare function resolvePersistWalk(model: Model, tagParseLog: LogMessage
46
47
  *
47
48
  * @param walk A resolved walk from {@link resolvePersistWalk}, in order
48
49
  * @param connectionDigests One digest per connection named by a persist source
50
+ * @param buildIdOpts What the BuildID's SQL is compiled under. The compiler
51
+ * recomputes the same key at serve time through `buildIdOptions()`; supply a
52
+ * different `virtualMap` here and the table is built under a key nothing
53
+ * looks up.
49
54
  */
50
- export declare function mkBuildTargets(walk: ResolvedNode[], connectionDigests: Record<string, string>): ConnectionBuild[];
55
+ export declare function mkBuildTargets(walk: ResolvedNode[], connectionDigests: Record<string, string>, buildIdOpts: BuildIdOptions): ConnectionBuild[];
@@ -75,8 +75,12 @@ function addUnique(into, seen, keys) {
75
75
  *
76
76
  * @param walk A resolved walk from {@link resolvePersistWalk}, in order
77
77
  * @param connectionDigests One digest per connection named by a persist source
78
+ * @param buildIdOpts What the BuildID's SQL is compiled under. The compiler
79
+ * recomputes the same key at serve time through `buildIdOptions()`; supply a
80
+ * different `virtualMap` here and the table is built under a key nothing
81
+ * looks up.
78
82
  */
79
- function mkBuildTargets(walk, connectionDigests) {
83
+ function mkBuildTargets(walk, connectionDigests, buildIdOpts) {
80
84
  var _a;
81
85
  const targets = new Map();
82
86
  // What each source hands to whoever referenced it: its own target if it is
@@ -101,7 +105,7 @@ function mkBuildTargets(walk, connectionDigests) {
101
105
  `BuildID of '${node.sourceID}'. Supply a digest for every connection ` +
102
106
  'named by a persist source.');
103
107
  }
104
- const sql = source.getSQL();
108
+ const sql = source.getSQL(buildIdOpts);
105
109
  const buildId = source.makeBuildId(digest, sql);
106
110
  const key = targetKey(connectionName, buildId);
107
111
  let target = targets.get(key);
@@ -611,7 +611,11 @@ export declare class PersistSource implements Taggable {
611
611
  * For sql_select sources, returns the SQL string (with segment expansion).
612
612
  * For query_source sources, compiles the inner query to SQL.
613
613
  *
614
- * @param options - Compile options including buildManifest for persistence.
614
+ * @param options - Compile options. `buildManifest` and `connectionDigests`
615
+ * substitute already-built dependencies, giving the SQL to execute.
616
+ * Anything that changes the SQL without them — `virtualMap` — must match
617
+ * what the compiler will use, or the table is built under a key nothing
618
+ * looks up.
615
619
  * @return The SQL string for this source.
616
620
  */
617
621
  getSQL(options?: CompileQueryOptions): string;
@@ -1357,7 +1357,11 @@ class PersistSource {
1357
1357
  * For sql_select sources, returns the SQL string (with segment expansion).
1358
1358
  * For query_source sources, compiles the inner query to SQL.
1359
1359
  *
1360
- * @param options - Compile options including buildManifest for persistence.
1360
+ * @param options - Compile options. `buildManifest` and `connectionDigests`
1361
+ * substitute already-built dependencies, giving the SQL to execute.
1362
+ * Anything that changes the SQL without them — `virtualMap` — must match
1363
+ * what the compiler will use, or the table is built under a key nothing
1364
+ * looks up.
1361
1365
  * @return The SQL string for this source.
1362
1366
  */
1363
1367
  getSQL(options) {
@@ -1365,7 +1369,7 @@ class PersistSource {
1365
1369
  const queryModel = this.model.queryModel;
1366
1370
  // Compile with finalize=false so this SQL is the bare source SELECT.
1367
1371
  // The build-time key (makeBuildId over this SQL) must equal the serve-time
1368
- // manifest lookup key, which query_query.ts recomputes from the same
1372
+ // manifest lookup key, which persistedTableFor recomputes from the same
1369
1373
  // unfinalized SELECT; finalizing would diverge the two on dialects with a
1370
1374
  // final stage (Postgres) and mis-materialize the table.
1371
1375
  if (sd.type === 'sql_select') {
@@ -511,7 +511,9 @@ class Runtime {
511
511
  }
512
512
  }
513
513
  return {
514
- connections: (0, build_targets_1.mkBuildTargets)(walk, connectionDigests),
514
+ connections: (0, build_targets_1.mkBuildTargets)(walk, connectionDigests, {
515
+ virtualMap: this.virtualMap,
516
+ }),
515
517
  tagParseLog,
516
518
  };
517
519
  }
@@ -7,7 +7,8 @@ export { getResultStructDefForQuery, getResultStructDefForView, } from './query_
7
7
  export { indent, composeSQLExpr, makeDigest, mkModelDef, mkModelID, pathToKey, typeDefToString, } from './utils';
8
8
  export { getModelAnnotations } from './annotation_utils';
9
9
  export { constantExprToSQL } from './constant_expression_compiler';
10
- export { getCompiledSQL } from './sql_compiled';
10
+ export { getCompiledSQL, buildIdOptions } from './sql_compiled';
11
+ export type { BuildIdOptions } from './sql_compiled';
11
12
  export { MalloyCompileError } from './malloy_compile_error';
12
13
  export { mkSourceID, mkBuildID, mkQuerySourceDef, mkSQLSourceDef, mkTableSourceDef, resolveSourceID, resolveSourceRef, sourceNamespaceReference, registerSource, hasSourceRegistryEntry, } from './source_def_utils';
13
14
  export type { NamespaceReference } from './source_def_utils';
@@ -18,7 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.hasSourceRegistryEntry = exports.registerSource = exports.sourceNamespaceReference = exports.resolveSourceRef = exports.resolveSourceID = exports.mkTableSourceDef = exports.mkSQLSourceDef = exports.mkQuerySourceDef = exports.mkBuildID = exports.mkSourceID = exports.MalloyCompileError = exports.getCompiledSQL = exports.constantExprToSQL = exports.getModelAnnotations = exports.typeDefToString = exports.pathToKey = exports.mkModelID = exports.mkModelDef = exports.makeDigest = exports.composeSQLExpr = exports.indent = exports.getResultStructDefForView = exports.getResultStructDefForQuery = exports.QueryModel = exports.QueryQuery = exports.QueryStruct = exports.QueryField = void 0;
21
+ exports.hasSourceRegistryEntry = exports.registerSource = exports.sourceNamespaceReference = exports.resolveSourceRef = exports.resolveSourceID = exports.mkTableSourceDef = exports.mkSQLSourceDef = exports.mkQuerySourceDef = exports.mkBuildID = exports.mkSourceID = exports.MalloyCompileError = exports.buildIdOptions = exports.getCompiledSQL = exports.constantExprToSQL = exports.getModelAnnotations = exports.typeDefToString = exports.pathToKey = exports.mkModelID = exports.mkModelDef = exports.makeDigest = exports.composeSQLExpr = exports.indent = exports.getResultStructDefForView = exports.getResultStructDefForQuery = exports.QueryModel = exports.QueryQuery = exports.QueryStruct = exports.QueryField = void 0;
22
22
  __exportStar(require("./malloy_types"), exports);
23
23
  const query_node_1 = require("./query_node");
24
24
  Object.defineProperty(exports, "QueryField", { enumerable: true, get: function () { return query_node_1.QueryField; } });
@@ -51,6 +51,7 @@ var constant_expression_compiler_1 = require("./constant_expression_compiler");
51
51
  Object.defineProperty(exports, "constantExprToSQL", { enumerable: true, get: function () { return constant_expression_compiler_1.constantExprToSQL; } });
52
52
  var sql_compiled_1 = require("./sql_compiled");
53
53
  Object.defineProperty(exports, "getCompiledSQL", { enumerable: true, get: function () { return sql_compiled_1.getCompiledSQL; } });
54
+ Object.defineProperty(exports, "buildIdOptions", { enumerable: true, get: function () { return sql_compiled_1.buildIdOptions; } });
54
55
  var malloy_compile_error_1 = require("./malloy_compile_error");
55
56
  Object.defineProperty(exports, "MalloyCompileError", { enumerable: true, get: function () { return malloy_compile_error_1.MalloyCompileError; } });
56
57
  var source_def_utils_1 = require("./source_def_utils");
@@ -6,6 +6,7 @@ import { QueryStruct, QueryField } from './query_node';
6
6
  import { StageWriter } from './stage_writer';
7
7
  import type { FieldInstance } from './field_instance';
8
8
  import { FieldInstanceResult, FieldInstanceResultRoot } from './field_instance';
9
+ import type { CompileQueryCallback } from './sql_compiled';
9
10
  interface OutputPipelinedSQL {
10
11
  sqlFieldName: string;
11
12
  pipelineSQL: string;
@@ -66,6 +67,12 @@ export declare class QueryQuery extends QueryField {
66
67
  /** returns a fields and primary key of a struct for this query */
67
68
  getResultStructDef(resultStruct?: FieldInstanceResult, isRoot?: boolean): QueryResultDef;
68
69
  getStructSourceSQL(qs: QueryStruct, stageWriter: StageWriter): string;
70
+ /**
71
+ * A compile callback which writes to its own StageWriter rather than the
72
+ * one this query is building, so the SQL comes back as a string. Both the
73
+ * manifest lookup and inline expansion need a source's SQL in that form.
74
+ */
75
+ protected isolatedQueryCompiler(): CompileQueryCallback;
69
76
  /**
70
77
  * Compile a Query into SQL stages. Used by both query_source compilation
71
78
  * and getCompiledSQL for interpolated sources.
@@ -12,7 +12,6 @@ const query_node_1 = require("./query_node");
12
12
  const stage_writer_1 = require("./stage_writer");
13
13
  const field_instance_1 = require("./field_instance");
14
14
  const sql_compiled_1 = require("./sql_compiled");
15
- const source_def_utils_1 = require("./source_def_utils");
16
15
  const malloy_compile_error_1 = require("./malloy_compile_error");
17
16
  const nest_capability_1 = require("./nest-capability");
18
17
  function pathToCol(path) {
@@ -532,7 +531,7 @@ class QueryQuery extends query_node_1.QueryField {
532
531
  return outputStruct;
533
532
  }
534
533
  getStructSourceSQL(qs, stageWriter) {
535
- var _a, _b, _c, _d;
534
+ var _a, _b, _c, _d, _e;
536
535
  switch (qs.structDef.type) {
537
536
  case 'table':
538
537
  // tablePath is canonical SQL — translator pre-validated.
@@ -555,38 +554,21 @@ class QueryQuery extends query_node_1.QueryField {
555
554
  return '{COMPOSITE SOURCE}';
556
555
  case 'finalize':
557
556
  return qs.structDef.name;
558
- case 'sql_select':
559
- return `(${(0, sql_compiled_1.getCompiledSQL)(qs.structDef, (_c = qs.prepareResultOptions) !== null && _c !== void 0 ? _c : {}, (query, opts) => {
560
- // Compile query to isolated SQL (not into parent's stageWriter)
561
- const ret = this.compileQueryToStages(query, opts !== null && opts !== void 0 ? opts : {}, undefined, false);
562
- return ret.sql;
563
- })})`;
557
+ case 'sql_select': {
558
+ // A hit is a table name, which is what a FROM clause wants; the
559
+ // inline form is a SELECT and has to be parenthesized to sit there.
560
+ const tableName = (0, sql_compiled_1.persistedTableFor)(qs.structDef, (_c = qs.prepareResultOptions) !== null && _c !== void 0 ? _c : {}, this.isolatedQueryCompiler());
561
+ if (tableName !== undefined) {
562
+ return tableName;
563
+ }
564
+ return `(${(0, sql_compiled_1.getCompiledSQL)(qs.structDef, (_d = qs.prepareResultOptions) !== null && _d !== void 0 ? _d : {}, this.isolatedQueryCompiler())})`;
565
+ }
564
566
  case 'nest_source':
565
567
  return qs.structDef.pipeSQL;
566
568
  case 'query_source': {
567
- const { buildManifest, connectionDigests } = (_d = qs.prepareResultOptions) !== null && _d !== void 0 ? _d : {};
568
- // Check manifest for this source (only if it was marked persistent at definition time)
569
- if (buildManifest && connectionDigests && qs.structDef.persistent) {
570
- const connDigest = (0, malloy_types_1.safeRecordGet)(connectionDigests, qs.structDef.connection);
571
- if (connDigest) {
572
- // Compile with empty opts to get manifest-ignorant SQL for BuildID
573
- const fullRet = this.compileQueryToStages(qs.structDef.query, {}, undefined, false);
574
- const buildId = (0, source_def_utils_1.mkBuildID)(connDigest, fullRet.sql);
575
- const entry = buildManifest.entries[buildId];
576
- if (entry) {
577
- // Found in manifest - use persisted table.
578
- // entry.tableName comes from the manifest, assumed canonical.
579
- return entry.tableName;
580
- }
581
- if (buildManifest.strict) {
582
- const base = `Persist source '${qs.structDef.sourceID}' not found ` +
583
- `in manifest (buildId: ${buildId}); strict manifest mode ` +
584
- 'forbids fallback to live compilation.';
585
- throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError
586
- ? `${base}\n ${buildManifest.loadError}`
587
- : base, 'runtime-manifest-strict-miss', qs.structDef.location);
588
- }
589
- }
569
+ const tableName = (0, sql_compiled_1.persistedTableFor)(qs.structDef, (_e = qs.prepareResultOptions) !== null && _e !== void 0 ? _e : {}, this.isolatedQueryCompiler());
570
+ if (tableName !== undefined) {
571
+ return tableName;
590
572
  }
591
573
  // Not in manifest - compile normally
592
574
  const ret = this.compileQueryToStages(qs.structDef.query, qs.prepareResultOptions, stageWriter, qs.parent !== undefined);
@@ -596,6 +578,14 @@ class QueryQuery extends query_node_1.QueryField {
596
578
  throw new Error(`Cannot create SQL StageWriter from '${(0, malloy_types_1.activeName)(qs.structDef)}' type '${qs.structDef.type}`);
597
579
  }
598
580
  }
581
+ /**
582
+ * A compile callback which writes to its own StageWriter rather than the
583
+ * one this query is building, so the SQL comes back as a string. Both the
584
+ * manifest lookup and inline expansion need a source's SQL in that form.
585
+ */
586
+ isolatedQueryCompiler() {
587
+ return (query, opts) => this.compileQueryToStages(query, opts !== null && opts !== void 0 ? opts : {}, undefined, false).sql;
588
+ }
599
589
  /**
600
590
  * Compile a Query into SQL stages. Used by both query_source compilation
601
591
  * and getCompiledSQL for interpolated sources.
@@ -1993,11 +1983,11 @@ class QueryQueryRaw extends QueryQuery {
1993
1983
  if (this.parent.structDef.type !== 'sql_select') {
1994
1984
  throw new Error('Invalid struct for QueryQueryRaw, currently only supports SQL');
1995
1985
  }
1996
- return stageWriter.addStage((0, sql_compiled_1.getCompiledSQL)(this.parent.structDef, (_a = this.parent.prepareResultOptions) !== null && _a !== void 0 ? _a : {}, (query, opts) => {
1997
- // Compile query to isolated SQL (not into parent's stageWriter)
1998
- const ret = this.compileQueryToStages(query, opts !== null && opts !== void 0 ? opts : {}, undefined, false);
1999
- return ret.sql;
2000
- }));
1986
+ // No manifest lookup for the source itself: a raw pipeline's source is
1987
+ // always the `conn.sql(...)` written at the run site, which is unnamed and
1988
+ // so never persistent. Its `%{ }` dependencies do substitute, through
1989
+ // getCompiledSQL.
1990
+ return stageWriter.addStage((0, sql_compiled_1.getCompiledSQL)(this.parent.structDef, (_a = this.parent.prepareResultOptions) !== null && _a !== void 0 ? _a : {}, this.isolatedQueryCompiler()));
2001
1991
  }
2002
1992
  prepare() {
2003
1993
  // Do nothing!
@@ -1,4 +1,4 @@
1
- import type { PrepareResultOptions, SQLSourceDef, PersistableSourceDef, Query } from './malloy_types';
1
+ import type { PrepareResultOptions, SQLSourceDef, PersistableSourceDef, Query, VirtualMap } from './malloy_types';
2
2
  /**
3
3
  * Callback type for compiling a Query to SQL.
4
4
  * opts is optional - omit for "full SQL" (BuildID computation),
@@ -16,6 +16,45 @@ export type CompileQueryCallback = (query: Query, opts?: PrepareResultOptions) =
16
16
  * @param compileQuery Callback to compile a Query to SQL
17
17
  */
18
18
  export declare function getCompiledSQL(src: SQLSourceDef, opts: PrepareResultOptions, compileQuery: CompileQueryCallback): string;
19
+ /**
20
+ * The options a BuildID's SQL is compiled under — everything the builder and
21
+ * the compiler must both know, and nothing else.
22
+ *
23
+ * Narrow on purpose. A BuildID must not depend on what has already been built
24
+ * or build order would change the key, so this type cannot express a manifest;
25
+ * `mkBuildTargets` takes it for the same reason.
26
+ */
27
+ export interface BuildIdOptions {
28
+ virtualMap?: VirtualMap;
29
+ }
30
+ /**
31
+ * Project compile options down to what a BuildID is computed under.
32
+ *
33
+ * `virtualMap` decides which table a virtual source reads, so it changes the
34
+ * SQL and has to be in the key; the builder supplies its own.
35
+ *
36
+ * `resolvedGivens` is deliberately absent even though it also changes the SQL.
37
+ * The builder has no way to produce one — `Runtime.getBuildTargets` takes no
38
+ * givens and `PersistSource.getSQL` never resolves them — so including it makes
39
+ * the two sides disagree: the compiler folds `$IS_ADMIN` to a literal while the
40
+ * builder re-derives it from the declaration and emits `'admin'='admin'`. Both
41
+ * sides therefore compile givens the same way, by not resolving them. The
42
+ * consequence — a source whose SQL depends on a supplied given cannot be
43
+ * persisted, and says so badly — is #3041.
44
+ */
45
+ export declare function buildIdOptions(opts: PrepareResultOptions): BuildIdOptions;
46
+ /**
47
+ * Ask the manifest what table backs a persistable source.
48
+ *
49
+ * Every place the compiler needs SQL for a persistable source goes through
50
+ * here, so the rule is stated once: a source marked persistent is looked up
51
+ * by BuildID, a hit yields the table, a miss under `strict` throws, and
52
+ * anything else falls through to the source's own SQL.
53
+ *
54
+ * @return The table name, canonical SQL as the manifest supplied it, or
55
+ * undefined when the caller should emit the source's own SQL.
56
+ */
57
+ export declare function persistedTableFor(source: PersistableSourceDef, opts: PrepareResultOptions, compileQuery: CompileQueryCallback): string | undefined;
19
58
  /**
20
59
  * Get the SQL for a PersistableSourceDef.
21
60
  *
@@ -5,6 +5,8 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getCompiledSQL = getCompiledSQL;
8
+ exports.buildIdOptions = buildIdOptions;
9
+ exports.persistedTableFor = persistedTableFor;
8
10
  exports.getSourceSQL = getSourceSQL;
9
11
  const malloy_types_1 = require("./malloy_types");
10
12
  const source_def_utils_1 = require("./source_def_utils");
@@ -47,34 +49,70 @@ function expandSegment(segment, opts, compileQuery) {
47
49
  return expandQuery(segment, opts, compileQuery);
48
50
  }
49
51
  /**
50
- * Expand a PersistableSourceDef, checking manifest for pre-built table.
52
+ * Project compile options down to what a BuildID is computed under.
53
+ *
54
+ * `virtualMap` decides which table a virtual source reads, so it changes the
55
+ * SQL and has to be in the key; the builder supplies its own.
56
+ *
57
+ * `resolvedGivens` is deliberately absent even though it also changes the SQL.
58
+ * The builder has no way to produce one — `Runtime.getBuildTargets` takes no
59
+ * givens and `PersistSource.getSQL` never resolves them — so including it makes
60
+ * the two sides disagree: the compiler folds `$IS_ADMIN` to a literal while the
61
+ * builder re-derives it from the declaration and emits `'admin'='admin'`. Both
62
+ * sides therefore compile givens the same way, by not resolving them. The
63
+ * consequence — a source whose SQL depends on a supplied given cannot be
64
+ * persisted, and says so badly — is #3041.
65
+ */
66
+ function buildIdOptions(opts) {
67
+ return { virtualMap: opts.virtualMap };
68
+ }
69
+ /**
70
+ * Ask the manifest what table backs a persistable source.
71
+ *
72
+ * Every place the compiler needs SQL for a persistable source goes through
73
+ * here, so the rule is stated once: a source marked persistent is looked up
74
+ * by BuildID, a hit yields the table, a miss under `strict` throws, and
75
+ * anything else falls through to the source's own SQL.
76
+ *
77
+ * @return The table name, canonical SQL as the manifest supplied it, or
78
+ * undefined when the caller should emit the source's own SQL.
79
+ */
80
+ function persistedTableFor(source, opts, compileQuery) {
81
+ const { buildManifest, connectionDigests } = opts;
82
+ if (!buildManifest || !connectionDigests || !source.persistent) {
83
+ return undefined;
84
+ }
85
+ const connDigest = (0, malloy_types_1.safeRecordGet)(connectionDigests, source.connection);
86
+ if (connDigest === undefined) {
87
+ return undefined;
88
+ }
89
+ const buildId = (0, source_def_utils_1.mkBuildID)(connDigest, getSourceSQL(source, compileQuery, buildIdOptions(opts)));
90
+ const entry = buildManifest.entries[buildId];
91
+ if (entry) {
92
+ return entry.tableName;
93
+ }
94
+ if (buildManifest.strict) {
95
+ // `sourceID` is deleted, not inherited, when a source is modified, so it
96
+ // either names this source or is absent. `as` and `extends` survive a
97
+ // modification and would name the base, so neither stands in for it.
98
+ const named = source.sourceID
99
+ ? `Persisted source '${source.sourceID}'`
100
+ : 'Persisted source';
101
+ const base = `${named} not found in manifest (buildId: ${buildId}); ` +
102
+ 'strict manifest mode forbids fallback to live compilation.';
103
+ throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError ? `${base}\n ${buildManifest.loadError}` : base, 'runtime-manifest-strict-miss', source.location);
104
+ }
105
+ return undefined;
106
+ }
107
+ /**
108
+ * Expand a PersistableSourceDef as a `%{ }` segment.
51
109
  * Always returns a subquery form: (SELECT * FROM table) or (inline SQL)
52
110
  */
53
111
  function expandPersistableSource(source, opts, compileQuery) {
54
- const { buildManifest, connectionDigests } = opts;
55
- // Try manifest lookup if we have the required info (only for persistent sources)
56
- if (buildManifest && connectionDigests && source.persistent) {
57
- const connDigest = (0, malloy_types_1.safeRecordGet)(connectionDigests, source.connection);
58
- if (connDigest) {
59
- // Get the SQL for this source to compute BuildID (no opts = full SQL)
60
- const sql = getSourceSQL(source, compileQuery);
61
- const buildId = (0, source_def_utils_1.mkBuildID)(connDigest, sql);
62
- const entry = buildManifest.entries[buildId];
63
- if (entry) {
64
- // Found in manifest - substitute with subquery from persisted table.
65
- // entry.tableName is canonical SQL, supplied by the manifest builder.
66
- return `(SELECT * FROM ${entry.tableName})`;
67
- }
68
- // Not in manifest
69
- if (buildManifest.strict) {
70
- const base = `Persist source '${source.sourceID}' not found in manifest ` +
71
- `(buildId: ${buildId}); strict manifest mode forbids fallback ` +
72
- 'to live compilation.';
73
- throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError
74
- ? `${base}\n ${buildManifest.loadError}`
75
- : base, 'runtime-manifest-strict-miss', source.location);
76
- }
77
- }
112
+ // A segment has to be usable as a subquery, so a hit is wrapped.
113
+ const tableName = persistedTableFor(source, opts, compileQuery);
114
+ if (tableName !== undefined) {
115
+ return `(SELECT * FROM ${tableName})`;
78
116
  }
79
117
  // No manifest or not found - expand inline as subquery
80
118
  const sql = getSourceSQL(source, compileQuery, opts);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const MALLOY_VERSION = "0.0.429";
1
+ export declare const MALLOY_VERSION = "0.0.431";
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.429';
5
+ exports.MALLOY_VERSION = '0.0.431';
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.429",
3
+ "version": "0.0.431",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "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"
52
52
  },
53
53
  "dependencies": {
54
- "@malloydata/malloy-filter": "0.0.429",
55
- "@malloydata/malloy-interfaces": "0.0.429",
56
- "@malloydata/malloy-tag": "0.0.429",
54
+ "@malloydata/malloy-filter": "0.0.431",
55
+ "@malloydata/malloy-interfaces": "0.0.431",
56
+ "@malloydata/malloy-tag": "0.0.431",
57
57
  "@noble/hashes": "^1.8.0",
58
58
  "antlr4ts": "^0.5.0-alpha.4",
59
59
  "assert": "^2.0.0",