/** * Copyright (c) 2025-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { DataCubeSource } from '@finos/legend-data-cube'; import type { V1_PureModelContextData } from '@finos/legend-graph'; import { SerializationFactory, usingConstantValueSchema, usingModelSchema, type PlainObject, } from '@finos/legend-shared'; import { createModelSchema, list, optional, primitive } from 'serializr'; export const LAKEHOUSE_PRODUCER_DATA_CUBE_SOURCE_TYPE = 'lakehouseProducer'; export class LakehouseProducerDataCubeSource extends DataCubeSource { model!: PlainObject; runtime!: string; paths!: string[]; warehouse!: string; deploymentId: number | undefined; } export class LakehouseProducerIcebergCachedDataCubeSource extends DataCubeSource { model!: PlainObject; runtime!: string; db!: string; schema!: string; table!: string; paths!: string[]; deploymentId: number | undefined; } export class IcebergConfig { catalogUrl!: string; static readonly serialization = new SerializationFactory( createModelSchema(IcebergConfig, { catalogUrl: primitive(), }), ); } export class RawLakehouseProducerDataCubeSource { ingestDefinitionUrn!: string; warehouse!: string; ingestServerUrl!: string; paths!: string[]; deploymentId?: number; user?: string; icebergConfig?: IcebergConfig; query?: string; static readonly serialization = new SerializationFactory( createModelSchema(RawLakehouseProducerDataCubeSource, { _type: usingConstantValueSchema(LAKEHOUSE_PRODUCER_DATA_CUBE_SOURCE_TYPE), ingestDefinitionUrn: primitive(), warehouse: primitive(), ingestServerUrl: primitive(), paths: list(primitive()), deploymentId: optional(primitive()), user: optional(primitive()), icebergConfig: optional( usingModelSchema(IcebergConfig.serialization.schema), ), query: optional(primitive()), }), ); }