adnanhemani commented on code in PR #4816:
URL: https://github.com/apache/polaris/pull/4816#discussion_r3439440326


##########
spec/polaris-catalog-apis/semantic-models-api.yaml:
##########
@@ -0,0 +1,369 @@
+#
+# 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.
+#
+
+---
+paths:
+
+  /polaris/v1/{prefix}/namespaces/{namespace}/semantic-models:
+    parameters:
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/prefix'
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/namespace'
+
+    post:
+      tags:
+        - Semantic Model API
+      summary: Create a semantic model in the given namespace
+      operationId: createSemanticModel
+      description: |
+        Creates a semantic model in the specified namespace.
+
+        A semantic model is an Open Semantic Interchange (OSI) document 
describing
+        datasets, fields, relationships, metrics, and AI context for a logical 
analytics surface above
+        physical tables and views.
+
+      requestBody:
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/CreateSemanticModelRequest'
+      responses:
+        200:
+          $ref: '#/components/responses/CreateSemanticModelResponse'
+        400:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse'
+        401:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse'
+        403:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
+        404:
+          description: Not Found - The namespace specified does not exist
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                NamespaceNotFound:
+                  $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/examples/NoSuchNamespaceError'
+        409:
+          description: Conflict - A semantic model with this name already 
exists in the namespace
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                SemanticModelAlreadyExists:
+                  $ref: '#/components/examples/SemanticModelAlreadyExistsError'
+        503:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse'
+        5XX:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse'
+
+    get:
+      tags:
+        - Semantic Model API
+      summary: List semantic models in the given namespace
+      operationId: listSemanticModels
+      description: |
+        List semantic-model identifiers under a namespace.
+      parameters:
+        - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/page-token'
+        - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/page-size'
+
+      responses:
+        200:
+          $ref: '#/components/responses/ListSemanticModelsResponse'
+        400:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse'
+        401:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse'
+        403:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
+        404:
+          description: Not Found - The namespace specified does not exist
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                NamespaceNotFound:
+                  $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/examples/NoSuchNamespaceError'
+        503:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse'
+        5XX:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse'
+
+  
/polaris/v1/{prefix}/namespaces/{namespace}/semantic-models/{semantic-model-name}:
+    parameters:
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/prefix'
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/namespace'
+      - $ref: '#/components/parameters/semantic-model-name'
+
+    get:
+      tags:
+        - Semantic Model API
+      summary: Load a semantic model
+      operationId: loadSemanticModel
+      description: Load a semantic model from the catalog.
+      responses:
+        200:
+          $ref: '#/components/responses/LoadSemanticModelResponse'
+        400:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse'
+        401:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse'
+        403:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
+        404:
+          description: Not Found - the requested semantic model does not exist
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                SemanticModelToGetDoesNotExist:
+                  $ref: '#/components/examples/NoSuchSemanticModelError'
+        503:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse'
+        5XX:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse'
+
+    put:
+      tags:
+        - Semantic Model API
+      summary: Update a semantic model
+      operationId: updateSemanticModel
+      description: |
+        Replace a semantic model's document with a new one.
+      requestBody:
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/UpdateSemanticModelRequest'
+
+      responses:
+        200:
+          $ref: '#/components/responses/UpdateSemanticModelResponse'
+        400:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse'
+        401:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse'
+        403:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
+        404:
+          description: Not Found - the requested semantic model does not exist
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                SemanticModelToUpdateDoesNotExist:
+                  $ref: '#/components/examples/NoSuchSemanticModelError'
+        503:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse'
+        5XX:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse'
+
+    delete:
+      tags:
+        - Semantic Model API
+      summary: Drop a semantic model from the catalog
+      operationId: dropSemanticModel
+      description: Remove a semantic model from the catalog.
+      responses:
+        204:
+          description: Success, no content
+        400:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/BadRequestErrorResponse'
+        401:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/UnauthorizedResponse'
+        403:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ForbiddenResponse'
+        404:
+          description: Not Found - the requested semantic model does not exist
+          content:
+            application/json:
+              schema:
+                $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/IcebergErrorResponse'
+              examples:
+                SemanticModelToDeleteDoesNotExist:
+                  $ref: '#/components/examples/NoSuchSemanticModelError'
+        503:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServiceUnavailableResponse'
+        5XX:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/responses/ServerErrorResponse'
+
+components:
+  parameters:
+    semantic-model-name:
+      name: semantic-model-name
+      in: path
+      required: true
+      schema:
+        $ref: '#/components/schemas/SemanticModelName'
+
+  schemas:
+
+    SemanticModelName:
+      type: string
+      description:
+        A semantic model name. A valid name consists of uppercase and 
lowercase letters (A-Z, a-z),
+        digits (0-9), hyphens (-), and underscores (_).
+      pattern: '^[A-Za-z0-9\-_]+$'
+      example: 'tpcds_retail_model'
+
+    SemanticModelDocument:
+      type: object
+      description: An Open Semantic Interchange (OSI) document body.
+      required:
+        - version
+        - semantic_model
+      properties:
+        version:
+          type: string
+          description: The OSI spec version.
+          example: "0.1.1"
+        semantic_model:
+          type: string
+          description: The OSI semantic model serialized as a JSON string.
+      example:
+        version: "0.1.1"
+        semantic_model: '{"name":"tpcds_retail_model","description":"retail 
analytics","datasets":[{"name":"store_sales","source":"public.store_sales","primary_key":["ss_item_sk","ss_ticket_number"]}],"metrics":[{"name":"total_sales","expression":{"dialects":[{"dialect":"ANSI_SQL","expression":"SUM(ss_ext_sales_price)"}]}}]}'
+
+    SemanticModelIdentifier:
+      type: object
+      required:
+        - namespace
+        - name
+      properties:
+        namespace:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/Namespace'
+        name:
+          $ref: '#/components/schemas/SemanticModelName'
+
+    CreateSemanticModelRequest:
+      type: object
+      required:
+        - name
+        - document
+      properties:
+        name:
+          $ref: '#/components/schemas/SemanticModelName'
+        document:
+          $ref: '#/components/schemas/SemanticModelDocument'
+
+    UpdateSemanticModelRequest:
+      type: object
+      required:
+        - document
+      properties:
+        document:
+          $ref: '#/components/schemas/SemanticModelDocument'
+
+    LoadSemanticModelResponse:
+      type: object
+      properties:
+        document:
+          $ref: '#/components/schemas/SemanticModelDocument'
+
+    ListSemanticModelsResponse:
+      type: object
+      properties:
+        next-page-token:
+          $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/schemas/PageToken'
+        identifiers:
+          type: array
+          uniqueItems: true
+          items:
+            $ref: '#/components/schemas/SemanticModelIdentifier'
+
+  responses:
+    CreateSemanticModelResponse:
+      description: Semantic model object result after creating a semantic model
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/LoadSemanticModelResponse'
+
+    LoadSemanticModelResponse:
+      description: Semantic model object result when loading a semantic model
+      content:
+        application/json:
+          schema:
+            $ref: '#/components/schemas/LoadSemanticModelResponse'

Review Comment:
   Should this be a required property?



##########
spec/polaris-catalog-apis/semantic-models-api.yaml:
##########
@@ -0,0 +1,369 @@
+#
+# 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.
+#
+
+---
+paths:
+
+  /polaris/v1/{prefix}/namespaces/{namespace}/semantic-models:
+    parameters:
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/prefix'
+      - $ref: 
'../iceberg-rest-catalog-open-api.yaml#/components/parameters/namespace'
+
+    post:
+      tags:
+        - Semantic Model API
+      summary: Create a semantic model in the given namespace
+      operationId: createSemanticModel
+      description: |
+        Creates a semantic model in the specified namespace.
+
+        A semantic model is an Open Semantic Interchange (OSI) document 
describing
+        datasets, fields, relationships, metrics, and AI context for a logical 
analytics surface above
+        physical tables and views.
+
+      requestBody:
+        required: true
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/CreateSemanticModelRequest'
+      responses:
+        200:

Review Comment:
   Should this potentially be 201 rather than 200?



##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1534,22 +1436,17 @@ public ConfigResponse getConfig() {
     Map<String, String> properties =
         
PolarisEntity.of(resolvedReferenceCatalog.getEntity()).getPropertiesAsMap();
 
+    String prefix = prefixParser().catalogNameToPrefix(catalogName());
     return ConfigResponse.builder()
         .withDefaults(properties) // catalog properties are defaults
-        .withOverrides(
-            ImmutableMap.of(
-                "prefix",
-                prefixParser().catalogNameToPrefix(catalogName()),
-                // Polaris does not handle custom namespace separators;
-                // always communicate the default namespace separator to 
clients.
-                RESTCatalogProperties.NAMESPACE_SEPARATOR,
-                NamespaceUtils.DEFAULT_NAMESPACE_SEPARATOR_ENCODED))
+        .withOverrides(ImmutableMap.of("prefix", prefix))
         .withEndpoints(
             ImmutableList.<Endpoint>builder()
                 .addAll(DEFAULT_ENDPOINTS)
                 .addAll(VIEW_ENDPOINTS)
                 
.addAll(PolarisEndpoints.getSupportedGenericTableEndpoints(realmConfig()))
                 
.addAll(PolarisEndpoints.getSupportedPolicyEndpoints(realmConfig()))
+                
.addAll(PolarisEndpoints.getSupportedSemanticModelEndpoints(realmConfig()))

Review Comment:
   If this is an issue to send these endpoints, then we should discuss on the 
mailing list to keep all or remove all IMO.



-- 
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