-
Notifications
You must be signed in to change notification settings - Fork 460
OpenLineage : Add core lineage service scaffolding #4705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iting0321
wants to merge
8
commits into
apache:main
Choose a base branch
from
iting0321:ol-core-spi-domain-model-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b9265f0
add Core SPI and domain model
d630a09
update the node type
c073aae
add lineage data field
b85e227
fix the DefaultLineageServiceTest.java for feature is dark coverage
c8bd140
refactor LineagePersistence
a793842
remove jakarta.annotation.Nullable
00c432a
add lineage feature configurations to documentation
bf4c5d9
remove persistence-related model
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageData.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| import java.util.Objects; | ||
| import java.util.OptionalLong; | ||
|
|
||
| /** Dataset metadata returned in a lineage query response. */ | ||
| public record LineageData( | ||
| OptionalLong catalogId, | ||
| OptionalLong datasetId, | ||
| String namespace, | ||
| String name, | ||
| String subType, | ||
| OptionalLong createdAt, | ||
| OptionalLong updatedAt) { | ||
| public LineageData { | ||
| Objects.requireNonNull(catalogId, "catalogId must be non-null"); | ||
| Objects.requireNonNull(datasetId, "datasetId must be non-null"); | ||
| Objects.requireNonNull(namespace, "namespace must be non-null"); | ||
| Objects.requireNonNull(name, "name must be non-null"); | ||
| Objects.requireNonNull(createdAt, "createdAt must be non-null"); | ||
| Objects.requireNonNull(updatedAt, "updatedAt must be non-null"); | ||
| } | ||
|
|
||
| public LineageData( | ||
| long catalogId, | ||
| long datasetId, | ||
| String namespace, | ||
| String name, | ||
| String subType, | ||
| long createdAt, | ||
| long updatedAt) { | ||
| this( | ||
| OptionalLong.of(catalogId), | ||
| OptionalLong.of(datasetId), | ||
| namespace, | ||
| name, | ||
| subType, | ||
| OptionalLong.of(createdAt), | ||
| OptionalLong.of(updatedAt)); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageDirection.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| /** Supported directions for lineage queries. */ | ||
| public enum LineageDirection { | ||
| UPSTREAM, | ||
| DOWNSTREAM, | ||
| BOTH | ||
| } |
29 changes: 29 additions & 0 deletions
29
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageFieldMapping.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** A source-to-target field mapping returned for column-granularity queries. */ | ||
| public record LineageFieldMapping(String sourceField, String targetField) { | ||
| public LineageFieldMapping { | ||
| Objects.requireNonNull(sourceField, "sourceField must be non-null"); | ||
| Objects.requireNonNull(targetField, "targetField must be non-null"); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageGranularity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| /** Supported query granularities for lineage lookups. */ | ||
| public enum LineageGranularity { | ||
| DATASET, | ||
| COLUMN | ||
| } |
32 changes: 32 additions & 0 deletions
32
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageGraph.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| /** Normalized response model for lineage queries. */ | ||
| public record LineageGraph( | ||
| LineageNode node, List<LineageNode> upstream, List<LineageNode> downstream) { | ||
| public LineageGraph { | ||
| Objects.requireNonNull(node, "node must be non-null"); | ||
| upstream = List.copyOf(Objects.requireNonNull(upstream, "upstream must be non-null")); | ||
| downstream = List.copyOf(Objects.requireNonNull(downstream, "downstream must be non-null")); | ||
| } | ||
| } | ||
41 changes: 41 additions & 0 deletions
41
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| /** A node returned in a lineage query response. */ | ||
| public record LineageNode( | ||
| String id, | ||
| LineageNodeType type, | ||
| LineageData data, | ||
| boolean opaque, | ||
| List<LineageFieldMapping> fieldMappings) { | ||
| public LineageNode { | ||
| Objects.requireNonNull(id, "id must be non-null"); | ||
| Objects.requireNonNull(type, "type must be non-null"); | ||
| fieldMappings = | ||
| List.copyOf(Objects.requireNonNull(fieldMappings, "fieldMappings must be non-null")); | ||
| } | ||
|
Comment on lines
+31
to
+36
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
|
||
| public LineageNode(String id, LineageNodeType type, LineageData data, boolean opaque) { | ||
| this(id, type, data, opaque, List.of()); | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageNodeType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| /** Node kinds surfaced by normalized lineage queries. */ | ||
| public enum LineageNodeType { | ||
| DATASET, | ||
| COLUMN | ||
| } |
31 changes: 31 additions & 0 deletions
31
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageQueryRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** Request model for normalized lineage lookups. */ | ||
| public record LineageQueryRequest( | ||
| String nodeId, LineageDirection direction, LineageGranularity granularity) { | ||
| public LineageQueryRequest { | ||
| Objects.requireNonNull(nodeId, "nodeId must be non-null"); | ||
| Objects.requireNonNull(direction, "direction must be non-null"); | ||
| Objects.requireNonNull(granularity, "granularity must be non-null"); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.core.lineage; | ||
|
|
||
| /** Service boundary for lineage operations used by transport-layer adapters. */ | ||
| public interface LineageService { | ||
| LineageGraph query(LineageQueryRequest request); | ||
| } |
59 changes: 59 additions & 0 deletions
59
runtime/service/src/main/java/org/apache/polaris/service/lineage/DefaultLineageService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
| package org.apache.polaris.service.lineage; | ||
|
|
||
| import jakarta.enterprise.context.RequestScoped; | ||
| import jakarta.inject.Inject; | ||
| import org.apache.polaris.core.config.FeatureConfiguration; | ||
| import org.apache.polaris.core.context.CallContext; | ||
| import org.apache.polaris.core.lineage.LineageGraph; | ||
| import org.apache.polaris.core.lineage.LineageQueryRequest; | ||
| import org.apache.polaris.core.lineage.LineageService; | ||
|
|
||
| @RequestScoped | ||
| public class DefaultLineageService implements LineageService { | ||
| private final CallContext callContext; | ||
| private final LineageConfiguration configuration; | ||
|
|
||
| @Inject | ||
| public DefaultLineageService(CallContext callContext, LineageConfiguration configuration) { | ||
| this.callContext = callContext; | ||
| this.configuration = configuration; | ||
| } | ||
|
|
||
| @Override | ||
| public LineageGraph query(LineageQueryRequest request) { | ||
| ensureEnabled(); | ||
| throw new UnsupportedOperationException("Lineage query is not implemented yet."); | ||
| } | ||
|
|
||
| private void ensureEnabled() { | ||
| if (!configuration.enabled()) { | ||
| throw new UnsupportedOperationException( | ||
| "Lineage is disabled: set polaris.lineage.enabled=true to enable it."); | ||
| } | ||
|
|
||
| if (!callContext.getRealmConfig().getConfig(FeatureConfiguration.ENABLE_LINEAGE)) { | ||
| throw new UnsupportedOperationException( | ||
| "Lineage realm feature is disabled: enable " | ||
| + FeatureConfiguration.ENABLE_LINEAGE.key() | ||
| + " in the realm feature configuration."); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed