semanticdb-v2 2.0.0-alpha.10 → 2.0.0-alpha.11

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,4 +1,4 @@
1
- import type { LogicformType } from '../logicform-types';
1
+ import { type LogicformType } from '../logicform-types';
2
2
  import type { ExecuteOptions, ExecuteResult, ExecuteSuccessResult, InternalExecuteOptions } from './types';
3
3
  export declare const executeWithProvider: (inputLogicform: LogicformType, inputOptions: InternalExecuteOptions) => Promise<ExecuteSuccessResult>;
4
4
  export declare const execute: (inputLogicform: LogicformType, inputOptions: ExecuteOptions) => Promise<ExecuteResult>;
@@ -4,11 +4,12 @@ import type { OperatorRegistry } from '../operators/index';
4
4
  import type { CoreComputeProvider, DataRow } from '../physical/index';
5
5
  import type { LogicalPlan } from '../planner/index';
6
6
  import type { SchemaMappingRegistry } from '../schema-mappings/index';
7
- import type { SqlExecutionSourceReporter } from './execute-query';
7
+ import type { PhysicalQuerySource, SqlExecutionSourceReporter } from './execute-query';
8
8
  import type { InternalExecuteOptions } from './types';
9
9
  export declare const coordinatorConnectionId = "__semanticdb_coordinator__";
10
10
  export interface FederatedCompiledQuery {
11
11
  readonly compiled: CompiledQuery;
12
+ readonly sources: readonly PhysicalQuerySource[];
12
13
  readonly connectionId: string;
13
14
  readonly provider: CoreComputeProvider;
14
15
  readonly type: 'computation' | 'total';
@@ -9,7 +9,7 @@ import type { Permissions } from '../permissions/index';
9
9
  import type { ResolvedSemanticSchema, SemanticTypeRegistry } from '../semantic-types/index';
10
10
  import type { EntityFetchRequest } from './result-hydrator/index';
11
11
  import type { SemanticDBPlugin } from '../plugins/index';
12
- import type { SqlExecutionSourceReporter } from './execute-query';
12
+ import type { PhysicalQuerySource, SqlExecutionSourceReporter } from './execute-query';
13
13
  import type { LocaleRegistry } from '../i18n/index';
14
14
  interface FetchEntityOptions {
15
15
  readonly version: string;
@@ -26,7 +26,7 @@ interface FetchEntityOptions {
26
26
  readonly preferredConnectionId?: string;
27
27
  readonly cache?: QueryCacheExecutionOptions;
28
28
  readonly signal?: AbortSignal;
29
- readonly onCompiled?: (compiled: CompiledQuery, logicform: LogicformType, provider: CoreComputeProvider, connectionId?: string) => SqlExecutionSourceReporter | undefined;
29
+ readonly onCompiled?: (compiled: CompiledQuery, logicform: LogicformType, provider: CoreComputeProvider, connectionId: string | undefined, sources: readonly PhysicalQuerySource[]) => SqlExecutionSourceReporter | undefined;
30
30
  }
31
31
  export declare const fetchEntities: (request: EntityFetchRequest, options: FetchEntityOptions) => Promise<DataRow[]>;
32
32
  export {};
@@ -1,3 +1,3 @@
1
1
  export { execute } from './execute';
2
2
  export { closeConnections } from './connection-registry';
3
- export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './types';
3
+ export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlSchemaMapping, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './types';
@@ -0,0 +1,17 @@
1
+ import type { LogicformType, QueryType } from '../logicform-types';
2
+ import type { OperatorRegistry } from '../operators/index';
3
+ import type { CreateLogicalPlanOptions, LogicalPlan } from '../planner/index';
4
+ import type { SchemaMappingRegistry } from '../schema-mappings/index';
5
+ import type { LogicformPartitionShard, ResolvedSemanticSchema } from '../semantic-types/index';
6
+ /** Intersect range filters so the grain checker sees the effective shard boundary. */
7
+ export declare const partitionQuery: (original: QueryType | undefined, additional: QueryType) => QueryType;
8
+ export declare const validatePartitionShards: (schema: ResolvedSemanticSchema, shards: readonly LogicformPartitionShard[], mappings: SchemaMappingRegistry) => void;
9
+ export interface PartitionedPlans {
10
+ readonly current: LogicalPlan;
11
+ readonly comparison?: LogicalPlan;
12
+ readonly mappingIds: readonly string[];
13
+ }
14
+ export declare const createPartitionedPlans: (logicform: LogicformType, schema: ResolvedSemanticSchema, shards: readonly LogicformPartitionShard[], operators: OperatorRegistry, mappings: SchemaMappingRegistry, options: CreateLogicalPlanOptions, comparison?: {
15
+ readonly logicform: LogicformType;
16
+ readonly queryForCurrentShard: (query: QueryType) => QueryType;
17
+ }) => PartitionedPlans;
@@ -2,7 +2,7 @@ import type { OperatorDefinition, OperatorExecutionContext, OperatorRegistry } f
2
2
  import type { CoreComputeProvider, DataRow, ProviderRegistry, SqlParameters } from '../physical/index';
3
3
  import type { DatabaseConnection } from '../physical/index';
4
4
  import type { LogicalPlan, QueryLineage } from '../planner/index';
5
- import type { SchemaMappingDefinition, SchemaMappingRegistry, SchemaMappingSelection } from '../schema-mappings/index';
5
+ import type { SchemaMappingDefinition, SchemaMappingRegistry } from '../schema-mappings/index';
6
6
  import type { ResolvedSemanticSchema, SemanticSchemaDraft, SemanticTypeRegistry, TimeWatermarkPolicy } from '../semantic-types/index';
7
7
  import type { LogicformType, PublicLogicformType } from '../logicform-types';
8
8
  import type { QueryCacheConfiguration, QueryCacheExecutionOptions } from '../cache/index';
@@ -91,6 +91,10 @@ export interface ExecuteOptions extends ExecuteBaseOptions {
91
91
  }
92
92
  /** Internal execution seam used by executor tests after a provider has been resolved. */
93
93
  export interface InternalExecuteOptions extends Omit<ExecuteBaseOptions, 'operators'> {
94
+ /** Schema hooks already active in an internal execution, for recursion detection. */
95
+ readonly partitionStack?: readonly string[];
96
+ /** A pinned internal execution does not repartition this Schema. */
97
+ readonly partitionDisabledSchemaIds?: readonly string[];
94
98
  readonly operators?: OperatorRegistry;
95
99
  /** The public execution boundary has already merged built-in, plugin, and explicit Operators. */
96
100
  readonly operatorsResolved?: boolean;
@@ -117,14 +121,6 @@ export interface ExecuteSuccessResult {
117
121
  readonly normedLogicform: PublicLogicformType;
118
122
  readonly sqls: readonly ExecutedSql[];
119
123
  readonly lineage: QueryLineage;
120
- readonly provider: CoreComputeProvider['kind'];
121
- /** Physical connections that contributed rows to this result. */
122
- readonly providers: readonly {
123
- readonly connectionId: string;
124
- readonly provider: CoreComputeProvider['kind'];
125
- }[];
126
- /** Physical mapping decisions, including why every non-selected candidate lost. */
127
- readonly schemaMappingSelections: readonly SchemaMappingSelection[];
128
124
  /** Plugin-owned materialization for a custom LogicForm output type. */
129
125
  readonly output?: unknown;
130
126
  }
@@ -135,12 +131,18 @@ export interface ExecuteFailureResult {
135
131
  readonly schema?: ResolvedSemanticSchema;
136
132
  readonly normedLogicform: PublicLogicformType;
137
133
  readonly sqls: readonly ExecutedSql[];
138
- readonly provider?: CoreComputeProvider['kind'];
139
134
  readonly lineage?: QueryLineage;
140
135
  }
141
136
  export type ExecuteResult = ExecuteSuccessResult | ExecuteFailureResult;
142
137
  export type ExecutedSqlType = 'computation' | 'semantic-resolution' | 'total';
143
138
  export type SqlExecutionSource = 'cache' | 'database';
139
+ export interface ExecutedSqlSchemaMapping {
140
+ readonly schemaId: string;
141
+ /** Schema Mapping id, or its source when no explicit id was configured. */
142
+ readonly mappingId: string;
143
+ readonly connectionId: string;
144
+ readonly source: string;
145
+ }
144
146
  export interface ExecutedSql {
145
147
  /** Why this SQL participates in the LogicForm execution. */
146
148
  readonly type: ExecutedSqlType;
@@ -151,6 +153,8 @@ export interface ExecutedSql {
151
153
  readonly explain: string;
152
154
  /** Normalized LogicForm represented by this SQL statement. */
153
155
  readonly logicform: PublicLogicformType;
156
+ /** Physical Schema Mappings read directly by this SQL; empty for coordinator or materialized-row SQL. */
157
+ readonly schemaMappings: readonly ExecutedSqlSchemaMapping[];
154
158
  /** Parameterized SQL used for provider execution and cache identity. */
155
159
  readonly sql: string;
156
160
  readonly parameters: SqlParameters;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { getLogicformPropertyReferences, isDimensionInLogicform } from './logicform/index';
2
+ export type { LogicformPropertyReference } from './logicform/index';
1
3
  export { createLocaleRegistry, defaultLocaleRegistry, LocaleRegistry, enUS, zhCN, } from './i18n/index';
2
4
  export type { LocaleDefinition, LocaleInput, LocaleTranslate } from './i18n/index';
3
5
  export declare const Logicform: Readonly<{
@@ -8,7 +10,7 @@ export { SemanticDBError } from './errors';
8
10
  export { builtinSemanticTypes, createSemanticTypeRegistry, resolveSchema, SemanticTypeRegistry, validateResolvedSchema, } from './semantic-types/index';
9
11
  export { builtinOperators, createOperatorRegistry, OperatorRegistry, resolveOperator, } from './operators/index';
10
12
  export type { LegacySchemaPluginContext, MappingGranularityContext, MappingGranularityPlugin, OutputHandlerContext, OutputHandlerDefinition, IntervalSemanticProperties, IntervalSemanticsDefinition, PlannerPeriodDefinition, PlannerPeriodEvaluation, RelationSemanticsDefinition, RelationTemporalPlan, TimeWatermarkLogicformContext, PropertyMetadataPlugin, QueryOperatorCompileContext, QueryOperatorAuthorizeContext, QueryOperatorDefinition, QueryOperatorNormalizeContext, QueryOperatorPhysicalSource, QueryOperatorPlanContext, QueryOperatorPlanResult, SchemaMetadataPlugin, SchemaMappingPlugin, SemanticDBPlugin, } from './plugins/index';
11
- export { SchemaMappingRegistry, fromYiAskSchemaMapping, } from './schema-mappings/index';
13
+ export { SchemaMappingRegistry, fromYiAskSchemaMapping, getSupportedDimensions, } from './schema-mappings/index';
12
14
  export type { AbsoluteDateValue, CompareOperator, DatePartQueryComparison, DatePartQueryOperand, DateTimeValue, DateValue, EntityIdType, ExpressionItemType, LogicformType, NumericQueryComparison, NumericQueryOperand, PublicLogicformType, PeriodShiftTime, PredItemType, QueryLogicalOperand, QueryExpressionType, RelationQueryType, QueryType, QueryValueType, QueryValueTypeWithCompareOperator, RelativeDateValue, RepresentationType, } from './logicform-types';
13
15
  export type { RecursiveQueryType } from './plugins/index';
14
16
  export type { PrimalType, PropertyHierarchyDefinition, PropertySqlDefinition, ResolvedSemanticProperty, ResolvedSemanticSchema, SemanticTypeNormalizeContext, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, SemanticTypeResultContext, SemanticTypeResultProperty, TimeGranularity, TimeWatermarkPolicy, } from './semantic-types/index';
@@ -19,7 +21,7 @@ export type { OperatorDefinition, OperatorDefaultNameContext, OperatorExecutionC
19
21
  export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingPredDefinition, SchemaMappingPredMatch, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, YiAskSchemaMappingItem, YiAskSchemaMappingRecord, } from './schema-mappings/index';
20
22
  export { QueryCacheManager } from './cache/index';
21
23
  export type { InvalidateQueryCacheSourceOptions, QueryCacheConfiguration, } from './cache/index';
22
- export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './executor/index';
24
+ export type { ExecuteOptions, ExecuteFailureResult, ExecuteProgressEvent, ExecuteResult, ExecuteSuccessResult, ExecutedSql, ExecutedSqlSchemaMapping, ExecutedSqlType, SqlExecutionSource, PartialExecuteResult, ProgressCallback, } from './executor/index';
23
25
  export type { ColumnPermissions, Permissions, SchemaPermissions, } from './permissions/index';
24
26
  export type { CreateLogicalPlanOptions, LogicalPlan, QueryLineage, } from './planner/index';
25
27
  export { PlannerSemanticRegistry, createPlannerSemanticRegistry, } from './planner/index';
@@ -0,0 +1,16 @@
1
+ import type { LogicformType } from '../logicform-types';
2
+ export interface LogicformPropertyReference {
3
+ readonly reference: string;
4
+ readonly use: 'query' | 'pred' | 'groupby';
5
+ }
6
+ /** Property references in this v2 LogicForm node, retaining their use site. */
7
+ export declare const getLogicformPropertyReferences: (logicform: LogicformType) => readonly LogicformPropertyReference[];
8
+ /**
9
+ * Whether this v2 LogicForm node uses an exact property path in its query,
10
+ * PredItems, or groupby. A related-property filter such as
11
+ * `产品: { schema: 'product', query: { 品类: 'PA' } }` uses `产品_品类`,
12
+ * not the `产品` entity itself. A `from` or full query subquery has its own
13
+ * field scope and is not traversed. Normalize first when comparing property
14
+ * names with IDs or aliases.
15
+ */
16
+ export declare const isDimensionInLogicform: (logicform: LogicformType, dimension: string) => boolean;
@@ -0,0 +1,2 @@
1
+ export { getLogicformPropertyReferences, isDimensionInLogicform } from './dimensions';
2
+ export type { LogicformPropertyReference } from './dimensions';
@@ -25,7 +25,7 @@ export interface NormalizeLogicformOptions {
25
25
  }>;
26
26
  /** Internal root query used to resolve automatic `$case` boundaries. */
27
27
  readonly autoCaseQuery?: LogicformType['query'];
28
- readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
28
+ readonly resolveFromSchema?: (normalizedFrom: LogicformType, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema | Promise<ResolvedSemanticSchema>;
29
29
  readonly canProjectProperty?: (schema: ResolvedSemanticSchema, property: ResolvedSemanticProperty) => boolean;
30
30
  /** Internal recursion hook installed by normalizeLogicform. */
31
31
  readonly normalizeNestedLogicform?: (logicform: LogicformType) => Promise<LogicformType>;
@@ -1,5 +1,5 @@
1
1
  import type { PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, TimeGranularity, ComparableCategoryDefinition } from '../semantic-types/index';
2
- import type { LogicformType, PredItemType } from '../logicform-types';
2
+ import type { LogicformType, PredItemType, QueryType } from '../logicform-types';
3
3
  import type { DataRow } from '../physical/index';
4
4
  import type { Expression, LogicalPlan } from '../planner/index';
5
5
  import type { LocaleTranslate } from '../i18n/index';
@@ -205,6 +205,10 @@ export interface OperatorQueryComponent {
205
205
  readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
206
206
  /** SQL-side transformations that align this component's group keys with the base component. */
207
207
  readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
208
+ /** Shift an already partitioned current query into this comparison period. */
209
+ readonly partitionQuery?: (currentShardQuery: QueryType) => QueryType;
210
+ /** Unshifted metric used to choose the same Mapping for a standalone comparison. */
211
+ readonly partitionCurrentLogicform?: LogicformType;
208
212
  }
209
213
  export interface OperatorComponentQuery {
210
214
  /** Final result-column name for this child component. */
@@ -213,6 +217,9 @@ export interface OperatorComponentQuery {
213
217
  readonly prepare?: boolean;
214
218
  readonly mapResult?: (rows: readonly DataRow[]) => DataRow[];
215
219
  readonly groupKeyShifts?: readonly OperatorGroupKeyShift[];
220
+ /** Name of the current-period component whose selected Mapping this query inherits. */
221
+ readonly comparisonOf?: string;
222
+ readonly partitionQuery?: (currentShardQuery: QueryType) => QueryType;
216
223
  /**
217
224
  * Group output names used to join this component back to the first component.
218
225
  * When omitted, the compiler joins on the groupby outputs shared by both components.
@@ -0,0 +1,6 @@
1
+ import type { SemanticDBPlugin } from '../plugins/index';
2
+ import type { SchemaMappingDefinition } from '../schema-mappings/index';
3
+ import type { ResolvedSemanticSchema } from '../semantic-types/index';
4
+ import type { LogicalPlan } from './types';
5
+ /** Materialize physical Mapping outputs before evaluating Schema UDFs. */
6
+ export declare const buildMappingSourcePlan: (schema: ResolvedSemanticSchema, mapping: SchemaMappingDefinition, plugins?: readonly SemanticDBPlugin[]) => LogicalPlan;
@@ -10,6 +10,10 @@ import type { LogicalPlan } from './types';
10
10
  export declare const createResultSchema: (plan: LogicalPlan, sourceSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
11
11
  export declare const createDerivedSourceSchema: (sourcePlan: LogicalPlan, outerSchema: ResolvedSemanticSchema) => ResolvedSemanticSchema;
12
12
  export interface CreateLogicalPlanOptions {
13
+ /** Normalized nested LogicForms whose asynchronous partition plans were prepared by the executor. */
14
+ readonly preplannedPartitions?: ReadonlyMap<string, LogicalPlan>;
15
+ /** Restrict the root physical Schema to one candidate during partition planning. */
16
+ readonly mappingCandidates?: readonly string[];
13
17
  readonly plugins?: readonly SemanticDBPlugin[];
14
18
  readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
15
19
  /** Prefer physical mappings colocated with the execution's main connection. */
@@ -16,10 +16,13 @@ export interface SelectedSchemaMapping {
16
16
  export interface MappedPropertySource {
17
17
  readonly column: string;
18
18
  readonly sourceRef?: string;
19
+ readonly sql?: string;
19
20
  }
21
+ export declare const hasPropertySql: (mapping: SchemaMappingDefinition) => boolean;
20
22
  export declare const mappedPropertyColumn: (mapping: SchemaMappingDefinition, schema: ResolvedSemanticSchema, reference: string) => string | undefined;
21
23
  export declare const mappedPropertySource: (mapping: SchemaMappingDefinition, schema: ResolvedSemanticSchema, reference: string) => MappedPropertySource | undefined;
22
24
  export declare const selectSchemaMapping: (logicform: LogicformType, schema: ResolvedSemanticSchema, mappings: SchemaMappingRegistry, options?: {
25
+ readonly mappingCandidates?: readonly string[];
23
26
  readonly preferredConnectionId?: string;
24
27
  readonly resolveSchema?: (schemaId: string) => ResolvedSemanticSchema;
25
28
  /** Extra plugins used by this execution; must also be supplied when registering plugin grains. */
@@ -128,6 +128,8 @@ export interface JoinPlan {
128
128
  readonly targetConnectionId?: string;
129
129
  readonly targetSource: string;
130
130
  readonly targetSourceSql?: string;
131
+ /** Two projection layers for the target Schema Mapping and its UDFs. */
132
+ readonly targetMappingSourcePlan?: LogicalPlan;
131
133
  readonly targetAlias: string;
132
134
  readonly targetColumn: string;
133
135
  readonly targetSql?: string;
@@ -226,10 +228,20 @@ export interface LogicalPlan {
226
228
  readonly connectionId?: string;
227
229
  /** Trusted derived-table SQL supplied by the selected physical mapping. */
228
230
  readonly sourceSql?: string;
231
+ /** Two projection layers for the physical Mapping and Schema UDFs. */
232
+ readonly mappingSourcePlan?: LogicalPlan;
229
233
  /** Physical mapping selected by the Planner for this logical Schema. */
230
234
  readonly mappingId?: string;
231
235
  /** Child relations combined by their compatible group identity. */
232
236
  readonly subplans?: readonly LogicalPlan[];
237
+ /** Vertically combine disjoint aggregate shards by summing matching output groups. */
238
+ readonly sumPartition?: true;
239
+ /** Enumerated group values corresponding to subplans, combined vertically. */
240
+ readonly splitGroup?: {
241
+ readonly name: string;
242
+ readonly values: readonly string[];
243
+ readonly groupNames: readonly string[];
244
+ };
233
245
  /** Optional query plan compiled as the derived-table source of this plan. */
234
246
  readonly sourcePlan?: LogicalPlan;
235
247
  /** Normalized LogicForm corresponding to sourcePlan when generated rewrites need execution. */
@@ -1,4 +1,5 @@
1
1
  export { SchemaMappingRegistry } from './registry';
2
+ export { getSupportedDimensions } from './supported-dimensions';
2
3
  export { parseDailyExpireAt } from './freshness';
3
4
  export { isMappingTimeGranularity, isSchemaMappingGranularity, } from './granularity';
4
5
  export type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingEnrichmentKey, SchemaMappingItem, SchemaMappingGranularity, SchemaMappingGranularityExtensions, SchemaMappingPointTemporalDefinition, SchemaMappingSelection, RejectedSchemaMapping, SourceFreshnessPolicy, } from './types';
@@ -7,6 +7,7 @@ export declare class SchemaMappingRegistry {
7
7
  register(definition: SchemaMappingDefinition): this;
8
8
  get(schemaId: string, connectionId?: string): SchemaMappingDefinition;
9
9
  list(schemaId: string): readonly SchemaMappingDefinition[];
10
+ findById(schemaId: string, mappingId: string): SchemaMappingDefinition | undefined;
10
11
  definitions(): readonly SchemaMappingDefinition[];
11
12
  findSource(schemaId: string, source: string, connectionId?: string): SchemaMappingDefinition | undefined;
12
13
  }
@@ -0,0 +1,10 @@
1
+ import type { SchemaTypeDraft } from 'semanticdb-core';
2
+ import type { SemanticSchemaDraft } from '../semantic-types/index';
3
+ import type { SchemaMappingRegistry } from './registry';
4
+ /**
5
+ * Dimensions declared by at least one physical Mapping for this Schema.
6
+ * Returns canonical property-name paths. This is a discoverability union:
7
+ * metric coverage, time grain, and combinations of dimensions still require
8
+ * planning a concrete LogicForm.
9
+ */
10
+ export declare const getSupportedDimensions: (schemaId: string, schemas: Readonly<Record<string, SemanticSchemaDraft | SchemaTypeDraft>>, schemaMappings: SchemaMappingRegistry) => readonly string[];
@@ -18,7 +18,8 @@ export type SourceFreshnessPolicy = {
18
18
  export interface SchemaMappingPredMatch {
19
19
  /** Defaults to the owning mapping's Schema. */
20
20
  readonly schema?: string;
21
- readonly operator: string;
21
+ /** Restricts the match to one operator. Missing matches any aggregate operator. */
22
+ readonly operator?: string;
22
23
  readonly pred: string;
23
24
  /** Required conjunctive conditions across the LogicForm and PredItem queries. */
24
25
  readonly query?: QueryType;
@@ -30,9 +31,12 @@ export interface SchemaMappingPredDefinition {
30
31
  }
31
32
  export interface SchemaMappingItem {
32
33
  readonly sourceColumn?: string;
34
+ /** Trusted physical SQL expression, evaluated before the Schema Property's udf.sql. */
35
+ readonly propertySql?: string;
33
36
  /** Enrichment id that owns sourceColumn. Missing means the mapping's base source. */
34
37
  readonly sourceRef?: string;
35
38
  readonly mappingType?: 'property' | 'predItem' | 'ignored';
39
+ /** Direct targets for a property item; one property path (ID/name segments) for a predItem. */
36
40
  readonly propertyTarget?: readonly string[];
37
41
  readonly predItem?: PredItemType;
38
42
  /** Finest physical grain of a mapped Property. */
@@ -81,6 +85,8 @@ export interface SchemaMappingDefinition {
81
85
  export interface RejectedSchemaMapping {
82
86
  readonly mappingId: string;
83
87
  readonly reason: string;
88
+ /** Dimension Properties required by the query but unavailable on this Mapping. */
89
+ readonly missingDimensions?: readonly string[];
84
90
  }
85
91
  /** Planner diagnostics for one physical Schema mapping decision. */
86
92
  export interface SchemaMappingSelection {
@@ -3,6 +3,7 @@ import type { PredItemType } from '../logicform-types';
3
3
  import type { SchemaMappingDefinition, SchemaMappingEnrichmentDefinition, SchemaMappingGranularity } from './types';
4
4
  export interface YiAskSchemaMappingItem {
5
5
  readonly sourceColumn?: string;
6
+ readonly propertySql?: string;
6
7
  readonly sourceRef?: string;
7
8
  readonly mappingType?: 'property' | 'predItem' | 'ignored';
8
9
  readonly propertyTarget?: readonly string[];
@@ -5,7 +5,7 @@ export { SemanticTypeRegistry } from './registry';
5
5
  export { resolveSchema } from './resolve-schema';
6
6
  export { validateResolvedSchema } from './validate-resolved-schema';
7
7
  export { normalizePrimalQuery } from './primal-types/index';
8
- export type { ComparableCategoryDefinition, PropertyHierarchyDefinition, PropertySqlDefinition, PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, LegacySemanticSchemaMetadata, ResolvedSemanticSchemaMetadata, SemanticSchemaMetadata, SemanticTypeNormalizeContext, SemanticPeriodEvaluationContext, SemanticTypeResultContext, SemanticTypeResultProperty, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, TimeGranularity, TimeWatermarkPolicy, } from './types';
8
+ export type { ComparableCategoryDefinition, PropertyHierarchyDefinition, PropertySqlDefinition, LogicformPartition, LogicformPartitionContext, LogicformPartitionShard, PrimalType, ResolvedSemanticProperty, ResolvedSemanticSchema, LegacySemanticSchemaMetadata, ResolvedSemanticSchemaMetadata, SemanticSchemaMetadata, SemanticTypeNormalizeContext, SemanticPeriodEvaluationContext, SemanticTypeResultContext, SemanticTypeResultProperty, SemanticPropertyDraft, SemanticSchemaDraft, SemanticTypeDefinition, TimeGranularity, TimeWatermarkPolicy, } from './types';
9
9
  export declare const createSemanticTypeRegistry: (plugins?: readonly SemanticDBPlugin[]) => SemanticTypeRegistry;
10
10
  /** Copies a caller-owned Registry and appends plugin types without mutating the input. */
11
11
  export declare const addPluginSemanticTypes: (registry: SemanticTypeRegistry, plugins: readonly SemanticDBPlugin[]) => SemanticTypeRegistry;
@@ -1,5 +1,6 @@
1
1
  import type { PropertyTypeDraft, SchemaTypeDraft } from 'semanticdb-core';
2
- import type { LogicformType, PredItemType } from '../logicform-types';
2
+ import type dayjs from 'dayjs';
3
+ import type { LogicformType, PredItemType, QueryType } from '../logicform-types';
3
4
  /** Canonical primitive types use `entity`; `object` remains a legacy input alias. */
4
5
  export type PrimalType = 'string' | 'number' | 'boolean' | 'date' | 'entity' | 'object';
5
6
  export type TimeGranularity = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
@@ -21,6 +22,31 @@ export interface PropertyHierarchyDefinition {
21
22
  readonly up?: string;
22
23
  readonly down?: string;
23
24
  }
25
+ /** One additive query slice. Candidates are tried in order and must cover the slice. */
26
+ export interface LogicformPartitionShard {
27
+ readonly query: QueryType;
28
+ readonly mappingCandidates: readonly string[];
29
+ }
30
+ export interface LogicformPartitionContext {
31
+ readonly dayjs: typeof dayjs;
32
+ /** Alias for dayjs; this does not provide the Moment.js API. */
33
+ readonly moment: typeof dayjs;
34
+ readonly schemas: Readonly<Record<string, ResolvedSemanticSchema>>;
35
+ readonly schemaMappings: readonly {
36
+ readonly id?: string;
37
+ readonly schemaId: string;
38
+ readonly priority?: number;
39
+ }[];
40
+ /** Runs within the same execution context. A pinned mapping bypasses its Schema partition hook. */
41
+ readonly execute: (logicform: LogicformType, options?: {
42
+ readonly mappingId?: string;
43
+ }) => Promise<{
44
+ readonly result: readonly Readonly<Record<string, unknown>>[];
45
+ }>;
46
+ }
47
+ export type LogicformPartition = (logicform: LogicformType, context: LogicformPartitionContext) => Promise<{
48
+ readonly shards: readonly LogicformPartitionShard[];
49
+ }>;
24
50
  /** Extension point for plugin-owned Schema draft metadata. */
25
51
  export interface SemanticSchemaMetadata {
26
52
  }
@@ -52,12 +78,14 @@ export interface SemanticSchemaDraft extends Omit<SchemaTypeDraft, '_id' | 'id'
52
78
  readonly id: string;
53
79
  /** Marks the single Schema whose complete rows are loaded as calendar execution context. */
54
80
  readonly is_calendar?: boolean;
81
+ readonly partition?: LogicformPartition;
55
82
  readonly properties: readonly SemanticPropertyDraft[];
56
83
  }
57
84
  export interface ResolvedSemanticSchema extends Omit<SchemaTypeDraft, '_id' | 'id' | 'sid' | 'properties' | 'db' | 'from' | 'fromSQL' | 'projections' | keyof SemanticSchemaMetadata | keyof LegacySemanticSchemaMetadata>, ResolvedSemanticSchemaMetadata {
58
85
  readonly [key: string]: unknown;
59
86
  readonly id: string;
60
87
  readonly is_calendar?: boolean;
88
+ readonly partition?: LogicformPartition;
61
89
  readonly properties: readonly ResolvedSemanticProperty[];
62
90
  }
63
91
  export interface SemanticTypeNormalizeContext {