Copilot commented on code in PR #4826:
URL: https://github.com/apache/polaris/pull/4826#discussion_r3449797095


##########
site/content/in-dev/unreleased/configuration/config-sections/smallrye-polaris_lineage.md:
##########
@@ -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.
+#
+title: smallrye-polaris_lineage
+build:
+  list: never
+  render: never
+---
+
+| Property | Default Value | Type | Description |
+|----------|---------------|------|-------------|
+| `polaris.lineage.enabled` | `false` | `boolean` |  |
+| `polaris.lineage.persistence.enabled` | `false` | `boolean` |  |
+| `polaris.lineage.persistence.type` | `relational-jdbc` | `string` |  |
+| `polaris.lineage.dataset-resolution.enabled` | `false` | `boolean` |  |

Review Comment:
   This new config section (`smallrye-polaris_lineage`) does not appear to be 
included anywhere in the configuration reference (e.g., 
`site/content/in-dev/unreleased/configuration/configuration-reference.md` 
currently includes many `smallrye-polaris_*` sections but not this one). If the 
lineage settings are intended to be discoverable in the rendered docs, please 
add an include for this section in the appropriate place.



##########
runtime/service/src/main/java/org/apache/polaris/service/lineage/DefaultLineageService.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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 java.time.Instant;
+import org.apache.polaris.core.config.FeatureConfiguration;
+import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.context.RealmContext;
+import org.apache.polaris.core.lineage.LineageGraph;
+import org.apache.polaris.core.lineage.LineageIngestRequest;
+import org.apache.polaris.core.lineage.LineagePersistence;
+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;
+  private final LineagePersistence persistence;
+
+  @Inject
+  public DefaultLineageService(
+      CallContext callContext, LineageConfiguration configuration, 
LineagePersistence persistence) {
+    this.callContext = callContext;
+    this.configuration = configuration;
+    this.persistence = persistence;
+  }
+
+  @Override
+  public void ingest(LineageIngestRequest request) {
+    ensureEnabled();
+    RealmContext realmContext = callContext.getRealmContext();
+    Instant lastEventAt = request.eventTime().orElseGet(Instant::now);
+    persistence.upsertDatasets(realmContext, request.datasets());
+    persistence.replaceDatasetEdges(realmContext, request.edges(), 
lastEventAt);
+    persistence.upsertColumnEdges(realmContext, request.columnEdges(), 
lastEventAt);
+  }
+
+  @Override
+  public LineageGraph query(LineageQueryRequest request) {
+    ensureEnabled();
+    return persistence.loadLineage(callContext.getRealmContext(), request);
+  }
+
+  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.");
+    }

Review Comment:
   `LineageConfiguration` defines `polaris.lineage.persistence.enabled`/`type`, 
but `DefaultLineageService.ensureEnabled()` only checks 
`polaris.lineage.enabled` and the realm feature flag. As a result, operators 
can set `polaris.lineage.persistence.enabled=false` (the default) and still hit 
persistence calls (ultimately failing in `DisabledLineagePersistence`) with a 
less actionable error, and the `persistence.*` settings are effectively unused. 
Consider gating `ingest/query` on `configuration.persistence().enabled()` (and 
possibly surfacing a dedicated error message that points at 
`polaris.lineage.persistence.enabled`) or removing the unused config until it 
is wired.



##########
polaris-core/src/main/java/org/apache/polaris/core/lineage/LineageData.java:
##########
@@ -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");
+  }

Review Comment:
   `LineageData` validates most record components as non-null, but `subType` is 
the only `String` component not checked (and it is not modeled as 
`Optional`/annotated `@Nullable`). This makes the nullability contract 
ambiguous and can lead to unexpected nulls flowing into lineage query 
responses. Either enforce non-null for `subType` in the canonical constructor 
or explicitly model it as optional/nullable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to