@finos/legend-graph 32.3.2 → 32.3.3
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/lib/graph/BasicModel.d.ts +2 -1
- package/lib/graph/BasicModel.d.ts.map +1 -1
- package/lib/graph/BasicModel.js +3 -2
- package/lib/graph/BasicModel.js.map +1 -1
- package/lib/graph/Core_HashUtils.d.ts +4 -0
- package/lib/graph/Core_HashUtils.d.ts.map +1 -1
- package/lib/graph/Core_HashUtils.js +4 -0
- package/lib/graph/Core_HashUtils.js.map +1 -1
- package/lib/graph/DependencyManager.d.ts +2 -0
- package/lib/graph/DependencyManager.d.ts.map +1 -1
- package/lib/graph/DependencyManager.js +2 -0
- package/lib/graph/DependencyManager.js.map +1 -1
- package/lib/graph/MetaModelConst.d.ts +2 -1
- package/lib/graph/MetaModelConst.d.ts.map +1 -1
- package/lib/graph/MetaModelConst.js +1 -0
- package/lib/graph/MetaModelConst.js.map +1 -1
- package/lib/graph/PureModel.d.ts +3 -0
- package/lib/graph/PureModel.d.ts.map +1 -1
- package/lib/graph/PureModel.js +10 -0
- package/lib/graph/PureModel.js.map +1 -1
- package/lib/graph/helpers/STO_Internal_Relational_Helper.d.ts +29 -0
- package/lib/graph/helpers/STO_Internal_Relational_Helper.d.ts.map +1 -0
- package/lib/graph/helpers/STO_Internal_Relational_Helper.js +66 -0
- package/lib/graph/helpers/STO_Internal_Relational_Helper.js.map +1 -0
- package/lib/graph/helpers/STO_Relational_Helper.d.ts +3 -2
- package/lib/graph/helpers/STO_Relational_Helper.d.ts.map +1 -1
- package/lib/graph/helpers/STO_Relational_Helper.js +14 -5
- package/lib/graph/helpers/STO_Relational_Helper.js.map +1 -1
- package/lib/graph/metamodel/pure/data/EmbeddedData.d.ts +16 -0
- package/lib/graph/metamodel/pure/data/EmbeddedData.d.ts.map +1 -1
- package/lib/graph/metamodel/pure/data/EmbeddedData.js +34 -0
- package/lib/graph/metamodel/pure/data/EmbeddedData.js.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/function/test/{FunctionStoreTestData.d.ts → FunctionTestData.d.ts} +4 -4
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionTestData.d.ts.map +1 -0
- package/lib/graph/metamodel/pure/packageableElements/function/test/{FunctionStoreTestData.js → FunctionTestData.js} +4 -4
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionTestData.js.map +1 -0
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionTestSuite.d.ts +2 -2
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionTestSuite.d.ts.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionTestSuite.js.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/runtime/Runtime.d.ts.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/runtime/Runtime.js +1 -1
- package/lib/graph/metamodel/pure/packageableElements/runtime/Runtime.js.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/Database.d.ts +11 -0
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/Database.d.ts.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/Database.js +17 -0
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/Database.js.map +1 -1
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.d.ts +28 -0
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.d.ts.map +1 -0
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.js +34 -0
- package/lib/graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.js.map +1 -0
- package/lib/graph-manager/action/changeDetection/DomainObserverHelper.d.ts +2 -2
- package/lib/graph-manager/action/changeDetection/DomainObserverHelper.d.ts.map +1 -1
- package/lib/graph-manager/action/changeDetection/DomainObserverHelper.js +1 -1
- package/lib/graph-manager/action/changeDetection/DomainObserverHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js +4 -0
- package/lib/graph-manager/protocol/pure/v1/V1_PureGraphManager.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/data/V1_EmbeddedData.d.ts +16 -0
- package/lib/graph-manager/protocol/pure/v1/model/data/V1_EmbeddedData.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/data/V1_EmbeddedData.js +34 -0
- package/lib/graph-manager/protocol/pure/v1/model/data/V1_EmbeddedData.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/{V1_FunctionStoreTestData.d.ts → V1_FunctionTestData.d.ts} +3 -3
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestData.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/{V1_FunctionStoreTestData.js → V1_FunctionTestData.js} +4 -4
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestData.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestSuite.d.ts +2 -2
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestSuite.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestSuite.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.d.ts +2 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.js +2 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_IncludeStore.d.ts +23 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_IncludeStore.d.ts.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_IncludeStore.js +30 -0
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_IncludeStore.js.map +1 -0
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_CoreTransformerHelper.d.ts +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_CoreTransformerHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_CoreTransformerHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DataElementTransformer.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DataElementTransformer.js +22 -2
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DataElementTransformer.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.d.ts +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.js +19 -2
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.js +3 -3
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_RuntimeTransformer.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_RuntimeTransformer.js +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_RuntimeTransformer.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ClassMappingSecondPassBuilder.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ClassMappingSecondPassBuilder.js +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ClassMappingSecondPassBuilder.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.js +13 -3
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.d.ts +3 -3
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.js +33 -6
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_PropertyMappingBuilder.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_PropertyMappingBuilder.js +3 -3
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_PropertyMappingBuilder.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DataElementBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DataElementBuilderHelper.js +16 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DataElementBuilderHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DatabaseBuilderHelper.d.ts +4 -2
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DatabaseBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DatabaseBuilderHelper.js +56 -18
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DatabaseBuilderHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DomainBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DomainBuilderHelper.js +5 -5
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DomainBuilderHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_RelationalClassMappingBuilderHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_RelationalClassMappingBuilderHelper.js +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_RelationalClassMappingBuilderHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DataElementSerializationHelper.d.ts +5 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DataElementSerializationHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DataElementSerializationHelper.js +19 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DataElementSerializationHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.js +12 -0
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.js.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_FunctionSerializationHelper.d.ts.map +1 -1
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_FunctionSerializationHelper.js +27 -10
- package/lib/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_FunctionSerializationHelper.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/src/graph/BasicModel.ts +6 -2
- package/src/graph/Core_HashUtils.ts +4 -0
- package/src/graph/DependencyManager.ts +8 -0
- package/src/graph/MetaModelConst.ts +1 -0
- package/src/graph/PureModel.ts +19 -0
- package/src/graph/helpers/STO_Internal_Relational_Helper.ts +97 -0
- package/src/graph/helpers/STO_Relational_Helper.ts +30 -9
- package/src/graph/metamodel/pure/data/EmbeddedData.ts +42 -0
- package/src/graph/metamodel/pure/packageableElements/function/test/{FunctionStoreTestData.ts → FunctionTestData.ts} +4 -4
- package/src/graph/metamodel/pure/packageableElements/function/test/FunctionTestSuite.ts +2 -2
- package/src/graph/metamodel/pure/packageableElements/runtime/Runtime.ts +1 -4
- package/src/graph/metamodel/pure/packageableElements/store/relational/model/Database.ts +27 -0
- package/src/graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.ts +48 -0
- package/src/graph-manager/action/changeDetection/DomainObserverHelper.ts +3 -3
- package/src/graph-manager/protocol/pure/v1/V1_PureGraphManager.ts +4 -0
- package/src/graph-manager/protocol/pure/v1/model/data/V1_EmbeddedData.ts +45 -0
- package/src/graph-manager/protocol/pure/v1/model/packageableElements/function/test/{V1_FunctionStoreTestData.ts → V1_FunctionTestData.ts} +3 -3
- package/src/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionTestSuite.ts +2 -2
- package/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_Database.ts +3 -0
- package/src/graph-manager/protocol/pure/v1/model/packageableElements/store/relational/model/V1_IncludeStore.ts +32 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_CoreTransformerHelper.ts +1 -1
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DataElementTransformer.ts +41 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts +30 -3
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts +5 -5
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_RuntimeTransformer.ts +1 -4
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ClassMappingSecondPassBuilder.ts +5 -1
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_ElementSecondPassBuilder.ts +29 -2
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.ts +71 -11
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_PropertyMappingBuilder.ts +6 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DataElementBuilderHelper.ts +22 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DatabaseBuilderHelper.ts +89 -17
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_DomainBuilderHelper.ts +11 -8
- package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/helpers/V1_RelationalClassMappingBuilderHelper.ts +8 -1
- package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DataElementSerializationHelper.ts +32 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_DatabaseSerializationHelper.ts +25 -0
- package/src/graph-manager/protocol/pure/v1/transformation/pureProtocol/serializationHelpers/V1_FunctionSerializationHelper.ts +45 -17
- package/src/index.ts +4 -1
- package/tsconfig.json +5 -2
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionStoreTestData.d.ts.map +0 -1
- package/lib/graph/metamodel/pure/packageableElements/function/test/FunctionStoreTestData.js.map +0 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionStoreTestData.d.ts.map +0 -1
- package/lib/graph-manager/protocol/pure/v1/model/packageableElements/function/test/V1_FunctionStoreTestData.js.map +0 -1
|
@@ -23,6 +23,9 @@ import {
|
|
|
23
23
|
ModelStoreData,
|
|
24
24
|
ModelEmbeddedData,
|
|
25
25
|
ModelInstanceData,
|
|
26
|
+
RelationElementsData,
|
|
27
|
+
type RelationElement,
|
|
28
|
+
type RelationRowTestData,
|
|
26
29
|
} from '../../../../../../../graph/metamodel/pure/data/EmbeddedData.js';
|
|
27
30
|
import {
|
|
28
31
|
type RelationalCSVDataTable,
|
|
@@ -38,6 +41,9 @@ import {
|
|
|
38
41
|
V1_ModelStoreData,
|
|
39
42
|
V1_ModelEmbeddedData,
|
|
40
43
|
V1_ModelInstanceData,
|
|
44
|
+
V1_RelationElementsData,
|
|
45
|
+
V1_RelationElement,
|
|
46
|
+
V1_RelationRowTestData,
|
|
41
47
|
} from '../../../model/data/V1_EmbeddedData.js';
|
|
42
48
|
import {
|
|
43
49
|
V1_RelationalCSVData,
|
|
@@ -103,6 +109,39 @@ const V1_transformModelStoreData = (
|
|
|
103
109
|
return modelStoreDataElement;
|
|
104
110
|
};
|
|
105
111
|
|
|
112
|
+
const V1_transformRelationRowTestData = (
|
|
113
|
+
element: RelationRowTestData,
|
|
114
|
+
context: V1_GraphTransformerContext,
|
|
115
|
+
): V1_RelationRowTestData => {
|
|
116
|
+
const relationRowTestData = new V1_RelationRowTestData();
|
|
117
|
+
relationRowTestData.values = element.values;
|
|
118
|
+
return relationRowTestData;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const V1_transformRelationElement = (
|
|
122
|
+
element: RelationElement,
|
|
123
|
+
context: V1_GraphTransformerContext,
|
|
124
|
+
): V1_RelationElement => {
|
|
125
|
+
const relationElement = new V1_RelationElement();
|
|
126
|
+
relationElement.paths = element.paths;
|
|
127
|
+
relationElement.columns = element.columns;
|
|
128
|
+
relationElement.rows = element.rows.map((row) =>
|
|
129
|
+
V1_transformRelationRowTestData(row, context),
|
|
130
|
+
);
|
|
131
|
+
return relationElement;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const V1_transformRelationElementsData = (
|
|
135
|
+
element: RelationElementsData,
|
|
136
|
+
context: V1_GraphTransformerContext,
|
|
137
|
+
): V1_RelationElementsData => {
|
|
138
|
+
const relationElementsDataElement = new V1_RelationElementsData();
|
|
139
|
+
relationElementsDataElement.relationElements = element.relationElements.map(
|
|
140
|
+
(relationElement) => V1_transformRelationElement(relationElement, context),
|
|
141
|
+
);
|
|
142
|
+
return relationElementsDataElement;
|
|
143
|
+
};
|
|
144
|
+
|
|
106
145
|
export const V1_transformExternalFormatData = (
|
|
107
146
|
element: ExternalFormatData,
|
|
108
147
|
): V1_ExternalFormatData => {
|
|
@@ -180,6 +219,8 @@ export function V1_transformEmbeddedData(
|
|
|
180
219
|
return V1_transformModelStoreData(metamodel, context);
|
|
181
220
|
} else if (metamodel instanceof ExternalFormatData) {
|
|
182
221
|
return V1_transformExternalFormatData(metamodel);
|
|
222
|
+
} else if (metamodel instanceof RelationElementsData) {
|
|
223
|
+
return V1_transformRelationElementsData(metamodel, context);
|
|
183
224
|
} else if (metamodel instanceof DataElementReference) {
|
|
184
225
|
return V1_transformDataElementReference(metamodel, context);
|
|
185
226
|
} else if (metamodel instanceof RelationalCSVData) {
|
package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DatabaseTransformer.ts
CHANGED
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { UnsupportedOperationError } from '@finos/legend-shared';
|
|
18
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
INTERNAL__LakehouseGeneratedDatabase,
|
|
20
|
+
type Database,
|
|
21
|
+
} from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
|
|
19
22
|
import {
|
|
20
23
|
type RelationalDataType,
|
|
21
24
|
Real,
|
|
@@ -61,6 +64,7 @@ import {
|
|
|
61
64
|
import type { ColumnMapping } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/ColumnMapping.js';
|
|
62
65
|
import type { View } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/View.js';
|
|
63
66
|
import type { Schema } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Schema.js';
|
|
67
|
+
import { type IncludeStore } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.js';
|
|
64
68
|
import {
|
|
65
69
|
type V1_RelationalDataType,
|
|
66
70
|
V1_VarChar,
|
|
@@ -114,6 +118,7 @@ import {
|
|
|
114
118
|
import { V1_PackageableElementPointer } from '../../../model/packageableElements/V1_PackageableElement.js';
|
|
115
119
|
import type { TabularFunction } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/TabularFunction.js';
|
|
116
120
|
import { V1_TabularFunction } from '../../../model/packageableElements/store/relational/model/V1_TabularFunction.js';
|
|
121
|
+
import { V1_IncludeStore } from '../../../model/packageableElements/store/relational/model/V1_IncludeStore.js';
|
|
117
122
|
|
|
118
123
|
const transformRelationalDataType = (
|
|
119
124
|
type: RelationalDataType,
|
|
@@ -194,9 +199,17 @@ export const V1_transformTableAliasToTablePointer = (
|
|
|
194
199
|
},
|
|
195
200
|
): V1_TablePtr => {
|
|
196
201
|
const tablePtr = new V1_TablePtr();
|
|
202
|
+
const ownerRef = tableAlias.relation.ownerReference;
|
|
197
203
|
tablePtr.database = options?.TEMPORARY__resolveToFullPath
|
|
198
|
-
?
|
|
199
|
-
: (
|
|
204
|
+
? ownerRef.value.path
|
|
205
|
+
: (ownerRef.valueForSerialization ?? '');
|
|
206
|
+
// make sure reference is to the owner not the generated database
|
|
207
|
+
if (
|
|
208
|
+
ownerRef.value instanceof INTERNAL__LakehouseGeneratedDatabase &&
|
|
209
|
+
ownerRef.valueForSerialization === ownerRef.value.OWNER.path
|
|
210
|
+
) {
|
|
211
|
+
tablePtr.database = ownerRef.valueForSerialization;
|
|
212
|
+
}
|
|
200
213
|
// NOTE: Sometimes, we interpret this, so to maintain roundtrip stability, we need to handle this differrently
|
|
201
214
|
// See https://github.com/finos/legend-studio/issues/295
|
|
202
215
|
tablePtr.mainTableDb = tablePtr.database;
|
|
@@ -458,6 +471,16 @@ const transformSchema = (
|
|
|
458
471
|
return schema;
|
|
459
472
|
};
|
|
460
473
|
|
|
474
|
+
const transformIncludeStore = (element: IncludeStore): V1_IncludeStore => {
|
|
475
|
+
const v1IncludeStore = new V1_IncludeStore();
|
|
476
|
+
v1IncludeStore.packageableElementPointer = new V1_PackageableElementPointer(
|
|
477
|
+
undefined,
|
|
478
|
+
element.packageableElementPointer.valueForSerialization ?? '',
|
|
479
|
+
);
|
|
480
|
+
v1IncludeStore.storeType = element.storeType;
|
|
481
|
+
return v1IncludeStore;
|
|
482
|
+
};
|
|
483
|
+
|
|
461
484
|
export const V1_transformDatabase = (
|
|
462
485
|
element: Database,
|
|
463
486
|
context: V1_GraphTransformerContext,
|
|
@@ -484,5 +507,9 @@ export const V1_transformDatabase = (
|
|
|
484
507
|
store.valueForSerialization ?? '',
|
|
485
508
|
),
|
|
486
509
|
);
|
|
510
|
+
database.includedStoreSpecifications =
|
|
511
|
+
element.includedStoreSpecifications.map((includeStore) =>
|
|
512
|
+
transformIncludeStore(includeStore),
|
|
513
|
+
);
|
|
487
514
|
return database;
|
|
488
515
|
};
|
package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_DomainTransformer.ts
CHANGED
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
V1_FunctionTest,
|
|
72
72
|
} from '../../../model/packageableElements/function/test/V1_FunctionTest.js';
|
|
73
73
|
import { UnsupportedOperationError } from '@finos/legend-shared';
|
|
74
|
-
import {
|
|
74
|
+
import { V1_FunctionTestData } from '../../../model/packageableElements/function/test/V1_FunctionTestData.js';
|
|
75
75
|
import { V1_transformEmbeddedData } from './V1_DataElementTransformer.js';
|
|
76
76
|
import { V1_transformTestAssertion } from './V1_TestTransformer.js';
|
|
77
77
|
import { V1_DefaultValue } from '../../../model/packageableElements/domain/V1_DefaultValue.js';
|
|
@@ -354,11 +354,11 @@ const V1_transformFunctionSuite = (
|
|
|
354
354
|
testSuite.doc = element.doc;
|
|
355
355
|
if (element.testData?.length) {
|
|
356
356
|
testSuite.testData = element.testData.map((elementData) => {
|
|
357
|
-
const pTestData = new
|
|
357
|
+
const pTestData = new V1_FunctionTestData();
|
|
358
358
|
pTestData.doc = elementData.doc;
|
|
359
|
-
pTestData.
|
|
360
|
-
|
|
361
|
-
elementData.
|
|
359
|
+
pTestData.packageableElementPointer = V1_transformElementReferencePointer(
|
|
360
|
+
undefined,
|
|
361
|
+
elementData.element,
|
|
362
362
|
);
|
|
363
363
|
pTestData.data = V1_transformEmbeddedData(elementData.data, context);
|
|
364
364
|
return pTestData;
|
package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/from/V1_RuntimeTransformer.ts
CHANGED
|
@@ -98,10 +98,7 @@ const transformEngineRuntime = (
|
|
|
98
98
|
connection.connectionPointer,
|
|
99
99
|
);
|
|
100
100
|
val.storePointers = connection.storePointers.map((s) =>
|
|
101
|
-
V1_transformElementReferencePointer(
|
|
102
|
-
PackageableElementPointerType.STORE,
|
|
103
|
-
s,
|
|
104
|
-
),
|
|
101
|
+
V1_transformElementReferencePointer(undefined, s),
|
|
105
102
|
);
|
|
106
103
|
return val;
|
|
107
104
|
});
|
|
@@ -247,7 +247,11 @@ export class V1_ClassMappingSecondPassBuilder
|
|
|
247
247
|
}
|
|
248
248
|
let mainTableAlias: TableAlias | undefined;
|
|
249
249
|
if (classMapping.mainTable) {
|
|
250
|
-
const relation = this.context.resolveRelation(
|
|
250
|
+
const relation = this.context.resolveRelation(
|
|
251
|
+
classMapping.mainTable,
|
|
252
|
+
undefined,
|
|
253
|
+
true,
|
|
254
|
+
);
|
|
251
255
|
mainTableAlias = new TableAlias();
|
|
252
256
|
mainTableAlias.relation = relation;
|
|
253
257
|
mainTableAlias.name = relation.value.name;
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
LogEvent,
|
|
25
25
|
guaranteeType,
|
|
26
26
|
guaranteeNonNullable,
|
|
27
|
+
returnUndefOnError,
|
|
27
28
|
} from '@finos/legend-shared';
|
|
28
29
|
import { Stereotype } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Stereotype.js';
|
|
29
30
|
import { Tag } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/Tag.js';
|
|
@@ -63,7 +64,10 @@ import {
|
|
|
63
64
|
V1_buildMappingInclude,
|
|
64
65
|
} from './helpers/V1_MappingBuilderHelper.js';
|
|
65
66
|
import { V1_buildFlatDataSection } from './helpers/V1_FlatDataStoreBuilderHelper.js';
|
|
66
|
-
import {
|
|
67
|
+
import {
|
|
68
|
+
V1_buildSchema,
|
|
69
|
+
V1_initInternalLakehouseGeneratedDatabase,
|
|
70
|
+
} from './helpers/V1_DatabaseBuilderHelper.js';
|
|
67
71
|
import {
|
|
68
72
|
V1_buildConfigurationProperty,
|
|
69
73
|
V1_buildScopeElement,
|
|
@@ -94,7 +98,10 @@ import type { V1_ExecutionEnvironmentInstance } from '../../../model/packageable
|
|
|
94
98
|
import { V1_buildExecutionParameters } from './V1_ExecutionEnvironmentBuilderHelper.js';
|
|
95
99
|
import type { V1_INTERNAL__UnknownPackageableElement } from '../../../model/packageableElements/V1_INTERNAL__UnknownPackageableElement.js';
|
|
96
100
|
import type { V1_INTERNAL__UnknownFunctionActivator } from '../../../model/packageableElements/function/V1_INTERNAL__UnknownFunctionActivator.js';
|
|
97
|
-
import {
|
|
101
|
+
import {
|
|
102
|
+
PackageableElementExplicitReference,
|
|
103
|
+
PackageableElementImplicitReference,
|
|
104
|
+
} from '../../../../../../../graph/metamodel/pure/packageableElements/PackageableElementReference.js';
|
|
98
105
|
import { generateFunctionPrettyName } from '../../../../../../../graph/helpers/PureLanguageHelper.js';
|
|
99
106
|
import type { DSL_Mapping_PureProtocolProcessorPlugin_Extension } from '../../../../extensions/DSL_Mapping_PureProtocolProcessorPlugin_Extension.js';
|
|
100
107
|
import {
|
|
@@ -136,6 +143,7 @@ import {
|
|
|
136
143
|
V1_buildDataProductLink,
|
|
137
144
|
} from './helpers/V1_DataProductBuilder.js';
|
|
138
145
|
import type { V1_IngestDefinition } from '../../../model/packageableElements/ingest/V1_IngestDefinition.js';
|
|
146
|
+
import { IncludeStore } from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.js';
|
|
139
147
|
|
|
140
148
|
export class V1_ElementSecondPassBuilder
|
|
141
149
|
implements V1_PackageableElementVisitor<void>
|
|
@@ -507,6 +515,25 @@ export class V1_ElementSecondPassBuilder
|
|
|
507
515
|
database.includes = element.includedStores.map((includedStore) =>
|
|
508
516
|
this.context.resolveDatabase(includedStore.path),
|
|
509
517
|
);
|
|
518
|
+
database.includedStoreSpecifications =
|
|
519
|
+
element.includedStoreSpecifications.map((v1IncludeStore) => {
|
|
520
|
+
const storePath = v1IncludeStore.packageableElementPointer.path;
|
|
521
|
+
const storeElement = guaranteeNonNullable(
|
|
522
|
+
returnUndefOnError(() =>
|
|
523
|
+
this.context.graph.getIngestDefinition(storePath),
|
|
524
|
+
) ??
|
|
525
|
+
returnUndefOnError(() =>
|
|
526
|
+
this.context.graph.getDataProduct(storePath),
|
|
527
|
+
),
|
|
528
|
+
`Ingest/Data Product ${storePath} not found`,
|
|
529
|
+
);
|
|
530
|
+
const includedStore = new IncludeStore(
|
|
531
|
+
PackageableElementImplicitReference.create(storeElement, storePath),
|
|
532
|
+
v1IncludeStore.storeType,
|
|
533
|
+
);
|
|
534
|
+
V1_initInternalLakehouseGeneratedDatabase(includedStore, database);
|
|
535
|
+
return includedStore;
|
|
536
|
+
});
|
|
510
537
|
database.schemas = element.schemas.map((schema) =>
|
|
511
538
|
V1_buildSchema(schema, database, this.context),
|
|
512
539
|
);
|
package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_GraphBuilderContext.ts
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
guaranteeNonNullable,
|
|
26
26
|
assertNonEmptyString,
|
|
27
27
|
guaranteeType,
|
|
28
|
+
returnUndefOnError,
|
|
29
|
+
AssertionError,
|
|
28
30
|
} from '@finos/legend-shared';
|
|
29
31
|
import { GenericType } from '../../../../../../../graph/metamodel/pure/packageableElements/domain/GenericType.js';
|
|
30
32
|
import type { PackageableElement } from '../../../../../../../graph/metamodel/pure/packageableElements/PackageableElement.js';
|
|
@@ -49,7 +51,10 @@ import type { ConcreteFunctionDefinition } from '../../../../../../../graph/meta
|
|
|
49
51
|
import type { Store } from '../../../../../../../graph/metamodel/pure/packageableElements/store/Store.js';
|
|
50
52
|
import type { Service } from '../../../../../../../graph/metamodel/pure/packageableElements/service/Service.js';
|
|
51
53
|
import type { FlatData } from '../../../../../../../graph/metamodel/pure/packageableElements/store/flatData/model/FlatData.js';
|
|
52
|
-
import type {
|
|
54
|
+
import type {
|
|
55
|
+
Database,
|
|
56
|
+
INTERNAL__LakehouseGeneratedDatabase,
|
|
57
|
+
} from '../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
|
|
53
58
|
import type { PackageableConnection } from '../../../../../../../graph/metamodel/pure/packageableElements/connection/PackageableConnection.js';
|
|
54
59
|
import type { PackageableRuntime } from '../../../../../../../graph/metamodel/pure/packageableElements/runtime/PackageableRuntime.js';
|
|
55
60
|
import type { FileGenerationSpecification } from '../../../../../../../graph/metamodel/pure/packageableElements/fileGeneration/FileGenerationSpecification.js';
|
|
@@ -430,6 +435,10 @@ export class V1_GraphBuilderContext {
|
|
|
430
435
|
|
|
431
436
|
resolveRelation = (
|
|
432
437
|
tablePtr: V1_TablePtr,
|
|
438
|
+
contextDatabse?:
|
|
439
|
+
| Map<string, INTERNAL__LakehouseGeneratedDatabase>
|
|
440
|
+
| undefined,
|
|
441
|
+
allowImplicitToGeneratedDatabse?: boolean | undefined,
|
|
433
442
|
): ViewImplicitReference | TableImplicitReference => {
|
|
434
443
|
assertNonEmptyString(
|
|
435
444
|
tablePtr.database,
|
|
@@ -443,13 +452,47 @@ export class V1_GraphBuilderContext {
|
|
|
443
452
|
tablePtr.table,
|
|
444
453
|
`Table pointer 'table' field is missing or empty`,
|
|
445
454
|
);
|
|
446
|
-
const ownerReference = this.resolveDatabase(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
tablePtr.schema,
|
|
450
|
-
tablePtr.table,
|
|
455
|
+
const ownerReference = this.resolveDatabase(
|
|
456
|
+
tablePtr.database,
|
|
457
|
+
contextDatabse,
|
|
451
458
|
);
|
|
452
|
-
|
|
459
|
+
|
|
460
|
+
try {
|
|
461
|
+
const value = V1_getRelation(
|
|
462
|
+
ownerReference.value,
|
|
463
|
+
tablePtr.schema,
|
|
464
|
+
tablePtr.table,
|
|
465
|
+
);
|
|
466
|
+
return createImplicitRelationReference(ownerReference, value);
|
|
467
|
+
} catch (error) {
|
|
468
|
+
if (
|
|
469
|
+
allowImplicitToGeneratedDatabse &&
|
|
470
|
+
ownerReference.value.includedStoreSpecifications.length > 0
|
|
471
|
+
) {
|
|
472
|
+
const generatedDatabase =
|
|
473
|
+
ownerReference.value.includedStoreSpecifications.find((_s) =>
|
|
474
|
+
_s.generatedDatabase.schemas.find(
|
|
475
|
+
(_schema) => _schema.name === tablePtr.schema,
|
|
476
|
+
),
|
|
477
|
+
)?.generatedDatabase ??
|
|
478
|
+
guaranteeNonNullable(
|
|
479
|
+
ownerReference.value.includedStoreSpecifications[0]
|
|
480
|
+
?.generatedDatabase,
|
|
481
|
+
);
|
|
482
|
+
const value = V1_getRelation(
|
|
483
|
+
generatedDatabase,
|
|
484
|
+
tablePtr.schema,
|
|
485
|
+
tablePtr.table,
|
|
486
|
+
);
|
|
487
|
+
// we want the reference to be of the table pointer database
|
|
488
|
+
const ref = PackageableElementImplicitReference.create(
|
|
489
|
+
generatedDatabase,
|
|
490
|
+
tablePtr.database,
|
|
491
|
+
);
|
|
492
|
+
return createImplicitRelationReference(ref, value);
|
|
493
|
+
}
|
|
494
|
+
throw error;
|
|
495
|
+
}
|
|
453
496
|
};
|
|
454
497
|
|
|
455
498
|
resolveJoin = (joinPtr: V1_JoinPointer): JoinImplicitReference => {
|
|
@@ -559,11 +602,28 @@ export class V1_GraphBuilderContext {
|
|
|
559
602
|
);
|
|
560
603
|
resolveDatabase = (
|
|
561
604
|
path: string,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
605
|
+
generatedDatabasesInScope?:
|
|
606
|
+
| Map<string, INTERNAL__LakehouseGeneratedDatabase>
|
|
607
|
+
| undefined,
|
|
608
|
+
): PackageableElementImplicitReference<Database> => {
|
|
609
|
+
const element = returnUndefOnError(() =>
|
|
610
|
+
this.createImplicitPackageableElementReference(
|
|
611
|
+
path,
|
|
612
|
+
this.graph.getDatabase,
|
|
613
|
+
),
|
|
566
614
|
);
|
|
615
|
+
if (element) {
|
|
616
|
+
return element;
|
|
617
|
+
}
|
|
618
|
+
if (generatedDatabasesInScope?.has(path)) {
|
|
619
|
+
const generatedDb = generatedDatabasesInScope.get(path);
|
|
620
|
+
if (generatedDb) {
|
|
621
|
+
return PackageableElementImplicitReference.create(generatedDb, path);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
throw new AssertionError(`Can't find database ${path}`);
|
|
625
|
+
};
|
|
626
|
+
|
|
567
627
|
resolveMapping = (
|
|
568
628
|
path: string,
|
|
569
629
|
): PackageableElementImplicitReference<Mapping> =>
|
package/src/graph-manager/protocol/pure/v1/transformation/pureGraph/to/V1_PropertyMappingBuilder.ts
CHANGED
|
@@ -695,6 +695,8 @@ export class V1_PropertyMappingBuilder
|
|
|
695
695
|
this.context,
|
|
696
696
|
this.tableAliasIndex,
|
|
697
697
|
[],
|
|
698
|
+
undefined,
|
|
699
|
+
true,
|
|
698
700
|
),
|
|
699
701
|
new V1_GraphTransformerContextBuilder(
|
|
700
702
|
this.context.extensions.plugins,
|
|
@@ -928,6 +930,8 @@ export class V1_PropertyMappingBuilder
|
|
|
928
930
|
this.context,
|
|
929
931
|
this.tableAliasIndex,
|
|
930
932
|
[],
|
|
933
|
+
undefined,
|
|
934
|
+
true,
|
|
931
935
|
),
|
|
932
936
|
);
|
|
933
937
|
embedded.propertyMappings = protocol.classMapping.propertyMappings.map(
|
|
@@ -992,6 +996,8 @@ export class V1_PropertyMappingBuilder
|
|
|
992
996
|
this.context,
|
|
993
997
|
this.tableAliasIndex,
|
|
994
998
|
[],
|
|
999
|
+
undefined,
|
|
1000
|
+
true,
|
|
995
1001
|
),
|
|
996
1002
|
);
|
|
997
1003
|
otherwiseEmbedded.propertyMappings =
|
|
@@ -22,6 +22,9 @@ import {
|
|
|
22
22
|
ModelStoreData,
|
|
23
23
|
ModelEmbeddedData,
|
|
24
24
|
ModelInstanceData,
|
|
25
|
+
RelationElementsData,
|
|
26
|
+
RelationElement,
|
|
27
|
+
RelationRowTestData,
|
|
25
28
|
} from '../../../../../../../../graph/metamodel/pure/data/EmbeddedData.js';
|
|
26
29
|
import {
|
|
27
30
|
RelationalCSVData,
|
|
@@ -36,6 +39,7 @@ import {
|
|
|
36
39
|
type V1_ExternalFormatData,
|
|
37
40
|
type V1_ModelStoreData,
|
|
38
41
|
V1_ModelEmbeddedData,
|
|
42
|
+
type V1_RelationElementsData,
|
|
39
43
|
} from '../../../../model/data/V1_EmbeddedData.js';
|
|
40
44
|
import type { V1_RelationalCSVData } from '../../../../model/data/V1_RelationalCSVData.js';
|
|
41
45
|
import type { V1_GraphBuilderContext } from '../V1_GraphBuilderContext.js';
|
|
@@ -86,6 +90,24 @@ class V1_EmbeddedDataBuilder implements V1_EmbeddedDataVisitor<EmbeddedData> {
|
|
|
86
90
|
return metamodel;
|
|
87
91
|
}
|
|
88
92
|
|
|
93
|
+
visit_RelationElementsData(data: V1_RelationElementsData): EmbeddedData {
|
|
94
|
+
const metamodel = new RelationElementsData();
|
|
95
|
+
metamodel.relationElements = data.relationElements.map(
|
|
96
|
+
(relationElement) => {
|
|
97
|
+
const v = new RelationElement();
|
|
98
|
+
v.columns = relationElement.columns;
|
|
99
|
+
v.paths = relationElement.paths;
|
|
100
|
+
v.rows = relationElement.rows.map((row) => {
|
|
101
|
+
const r = new RelationRowTestData();
|
|
102
|
+
r.values = row.values;
|
|
103
|
+
return r;
|
|
104
|
+
});
|
|
105
|
+
return v;
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
return metamodel;
|
|
109
|
+
}
|
|
110
|
+
|
|
89
111
|
visit_ModelStoreData(modelStoreData: V1_ModelStoreData): EmbeddedData {
|
|
90
112
|
const metamodel = new ModelStoreData();
|
|
91
113
|
if (modelStoreData.modelData?.length) {
|
|
@@ -23,8 +23,12 @@ import {
|
|
|
23
23
|
guaranteeType,
|
|
24
24
|
assertTrue,
|
|
25
25
|
isNonNullable,
|
|
26
|
+
AssertionError,
|
|
26
27
|
} from '@finos/legend-shared';
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
Database,
|
|
30
|
+
INTERNAL__LakehouseGeneratedDatabase,
|
|
31
|
+
} from '../../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/Database.js';
|
|
28
32
|
import {
|
|
29
33
|
getAllIncludedDatabases,
|
|
30
34
|
getColumn,
|
|
@@ -135,6 +139,12 @@ import { TablePtr } from '../../../../../../../../graph/metamodel/pure/packageab
|
|
|
135
139
|
import type { TabularFunction } from '../../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/TabularFunction.js';
|
|
136
140
|
import type { V1_TabularFunction } from '../../../../model/packageableElements/store/relational/model/V1_TabularFunction.js';
|
|
137
141
|
import { V1_buildTaggedValue } from './V1_DomainBuilderHelper.js';
|
|
142
|
+
import type { IncludeStore } from '../../../../../../../../graph/metamodel/pure/packageableElements/store/relational/model/IncludeStore.js';
|
|
143
|
+
import {
|
|
144
|
+
buildGeneratedIndex,
|
|
145
|
+
getOrCreateSchemaFromGeneratedDatabase,
|
|
146
|
+
getOrCreateTableFromGeneratedSchema,
|
|
147
|
+
} from '../../../../../../../../graph/helpers/STO_Internal_Relational_Helper.js';
|
|
138
148
|
|
|
139
149
|
const _schemaExists = (
|
|
140
150
|
db: Database,
|
|
@@ -169,32 +179,80 @@ const schemaExists = (database: Database, _schema: string): boolean =>
|
|
|
169
179
|
DEFAULT_DATABASE_SCHEMA_NAME === _schema ||
|
|
170
180
|
_schemaExists(database, _schema, new Set<Database>());
|
|
171
181
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
182
|
+
const V1_findSchemaInGeneratedDatabase = (
|
|
183
|
+
schemaName: string,
|
|
184
|
+
db: INTERNAL__LakehouseGeneratedDatabase,
|
|
185
|
+
): Schema | undefined => {
|
|
186
|
+
let schema = db.schemas.find((s) => s.name === schemaName);
|
|
187
|
+
if (!schema) {
|
|
188
|
+
schema = new Schema(schemaName, db);
|
|
189
|
+
db.schemas.push(schema);
|
|
190
|
+
}
|
|
191
|
+
db.schemas.push(schema);
|
|
192
|
+
return schema;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const V1_findSchema = (database: Database, _schema: string): void => {
|
|
196
|
+
if (schemaExists(database, _schema)) {
|
|
197
|
+
return;
|
|
198
|
+
} else if (database instanceof INTERNAL__LakehouseGeneratedDatabase) {
|
|
199
|
+
V1_findSchemaInGeneratedDatabase(_schema, database);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
throw new AssertionError(
|
|
175
203
|
`Can't find schema '${_schema}' in database '${database}'`,
|
|
176
204
|
);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
function findRelationInSchema(
|
|
208
|
+
schema: Schema,
|
|
209
|
+
tableName: string,
|
|
210
|
+
): Relation | undefined {
|
|
211
|
+
let relation: Relation | undefined = schema.tables.find(
|
|
212
|
+
(table) => table.name === tableName,
|
|
213
|
+
);
|
|
214
|
+
if (!relation) {
|
|
215
|
+
relation = schema.views.find((view) => view.name === tableName);
|
|
216
|
+
}
|
|
217
|
+
if (!relation) {
|
|
218
|
+
relation = schema.tabularFunctions.find(
|
|
219
|
+
(tabularFunction) => tabularFunction.name === tableName,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return relation;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export const V1_initInternalLakehouseGeneratedDatabase = (
|
|
226
|
+
includedStore: IncludeStore,
|
|
227
|
+
owner: Database,
|
|
228
|
+
): INTERNAL__LakehouseGeneratedDatabase => {
|
|
229
|
+
const generatedDatabase = new INTERNAL__LakehouseGeneratedDatabase(
|
|
230
|
+
includedStore.packageableElementPointer.value,
|
|
231
|
+
owner,
|
|
232
|
+
);
|
|
233
|
+
const defaultSchema = new Schema(
|
|
234
|
+
DEFAULT_DATABASE_SCHEMA_NAME,
|
|
235
|
+
generatedDatabase,
|
|
236
|
+
);
|
|
237
|
+
generatedDatabase.schemas.push(defaultSchema);
|
|
238
|
+
includedStore.generatedDatabase = generatedDatabase;
|
|
239
|
+
return generatedDatabase;
|
|
240
|
+
};
|
|
177
241
|
|
|
178
242
|
export const V1_findRelation = (
|
|
179
243
|
database: Database,
|
|
180
244
|
schemaName: string,
|
|
181
245
|
tableName: string,
|
|
182
246
|
): Relation | undefined => {
|
|
247
|
+
if (database instanceof INTERNAL__LakehouseGeneratedDatabase) {
|
|
248
|
+
const schema = getOrCreateSchemaFromGeneratedDatabase(schemaName, database);
|
|
249
|
+
return getOrCreateTableFromGeneratedSchema(tableName, schema);
|
|
250
|
+
}
|
|
183
251
|
const relations: Relation[] = [];
|
|
184
252
|
getAllIncludedDatabases(database).forEach((db) => {
|
|
185
253
|
const schema = db.schemas.find((_schema) => _schema.name === schemaName);
|
|
186
254
|
if (schema) {
|
|
187
|
-
|
|
188
|
-
(table) => table.name === tableName,
|
|
189
|
-
);
|
|
190
|
-
if (!relation) {
|
|
191
|
-
relation = schema.views.find((view) => view.name === tableName);
|
|
192
|
-
}
|
|
193
|
-
if (!relation) {
|
|
194
|
-
relation = schema.tabularFunctions.find(
|
|
195
|
-
(tabularFunction) => tabularFunction.name === tableName,
|
|
196
|
-
);
|
|
197
|
-
}
|
|
255
|
+
const relation = findRelationInSchema(schema, tableName);
|
|
198
256
|
if (relation) {
|
|
199
257
|
relations.push(relation);
|
|
200
258
|
}
|
|
@@ -257,6 +315,8 @@ export const V1_buildRelationalOperationElement = (
|
|
|
257
315
|
context: V1_GraphBuilderContext,
|
|
258
316
|
tableAliasIndex: Map<string, TableAlias>,
|
|
259
317
|
selfJoinTargets: TableAliasColumn[],
|
|
318
|
+
generatedDbs?: Map<string, INTERNAL__LakehouseGeneratedDatabase> | undefined,
|
|
319
|
+
allowImplicitToGeneratedDatabase?: boolean | undefined,
|
|
260
320
|
): RelationalOperationElement => {
|
|
261
321
|
if (operationalElement instanceof V1_TableAliasColumn) {
|
|
262
322
|
if (operationalElement.table.table === SELF_JOIN_TABLE_NAME) {
|
|
@@ -265,7 +325,11 @@ export const V1_buildRelationalOperationElement = (
|
|
|
265
325
|
selfJoinTargets.push(selfJoin);
|
|
266
326
|
return selfJoin;
|
|
267
327
|
}
|
|
268
|
-
const relation = context.resolveRelation(
|
|
328
|
+
const relation = context.resolveRelation(
|
|
329
|
+
operationalElement.table,
|
|
330
|
+
generatedDbs,
|
|
331
|
+
allowImplicitToGeneratedDatabase,
|
|
332
|
+
);
|
|
269
333
|
const aliasName = `${operationalElement.table.schema}.${operationalElement.tableAlias}`;
|
|
270
334
|
if (!tableAliasIndex.has(aliasName)) {
|
|
271
335
|
const tAlias = new TableAlias();
|
|
@@ -274,7 +338,7 @@ export const V1_buildRelationalOperationElement = (
|
|
|
274
338
|
tableAliasIndex.set(aliasName, tAlias);
|
|
275
339
|
}
|
|
276
340
|
const columnReference = ColumnImplicitReference.create(
|
|
277
|
-
context.resolveDatabase(operationalElement.table.database),
|
|
341
|
+
context.resolveDatabase(operationalElement.table.database, generatedDbs),
|
|
278
342
|
getColumn(relation.value, operationalElement.column),
|
|
279
343
|
);
|
|
280
344
|
const tableAliasColumn = new TableAliasColumn();
|
|
@@ -297,6 +361,7 @@ export const V1_buildRelationalOperationElement = (
|
|
|
297
361
|
context,
|
|
298
362
|
new Map<string, TableAlias>(),
|
|
299
363
|
selfJoinTargets,
|
|
364
|
+
generatedDbs,
|
|
300
365
|
);
|
|
301
366
|
}
|
|
302
367
|
return elementWithJoins;
|
|
@@ -308,6 +373,7 @@ export const V1_buildRelationalOperationElement = (
|
|
|
308
373
|
context,
|
|
309
374
|
tableAliasIndex,
|
|
310
375
|
selfJoinTargets,
|
|
376
|
+
generatedDbs,
|
|
311
377
|
),
|
|
312
378
|
);
|
|
313
379
|
return dynFunc;
|
|
@@ -320,6 +386,7 @@ export const V1_buildRelationalOperationElement = (
|
|
|
320
386
|
context,
|
|
321
387
|
tableAliasIndex,
|
|
322
388
|
selfJoinTargets,
|
|
389
|
+
generatedDbs,
|
|
323
390
|
),
|
|
324
391
|
);
|
|
325
392
|
}
|
|
@@ -334,6 +401,7 @@ export const V1_buildRelationalOperationElement = (
|
|
|
334
401
|
context,
|
|
335
402
|
tableAliasIndex,
|
|
336
403
|
selfJoinTargets,
|
|
404
|
+
generatedDbs,
|
|
337
405
|
),
|
|
338
406
|
);
|
|
339
407
|
}
|
|
@@ -649,6 +717,7 @@ export const V1_buildDatabaseJoin = (
|
|
|
649
717
|
context,
|
|
650
718
|
tableAliasIndex,
|
|
651
719
|
selfJoinTargets,
|
|
720
|
+
buildGeneratedIndex(database),
|
|
652
721
|
),
|
|
653
722
|
);
|
|
654
723
|
const aliases = Array.from(tableAliasIndex.values());
|
|
@@ -687,6 +756,9 @@ export const V1_buildDatabaseJoin = (
|
|
|
687
756
|
col = existingRelationalElement.value.columns.find(
|
|
688
757
|
(c) => c instanceof Column && c.name === columnName,
|
|
689
758
|
) as Column | undefined;
|
|
759
|
+
} else if (database instanceof INTERNAL__LakehouseGeneratedDatabase) {
|
|
760
|
+
col = new Column();
|
|
761
|
+
col.name = columnName as string;
|
|
690
762
|
}
|
|
691
763
|
assertNonNullable(col, `Can't find column '${columnName}' in the table`);
|
|
692
764
|
// NOTE: this should be `implicit` because we do some inferencing
|