Skip to content
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

"The 'kind' value 'MultiHash' specified in the partition key definition is invalid. Please choose 'Hash' partition type." #1733

Open
jacksorjacksor opened this issue Sep 20, 2023 · 6 comments
Assignees
Labels
cosmos engine issues that require change in engine code hacktoberfest

Comments

@jacksorjacksor
Copy link

Hi there!
I'm using DAB to query a CosmosDB NoSQL container with partition keys of:

id: ID
/TenantId: String
/EntityType: String
/EntityId: String

Example:
image

The items within this table have been assigned the model of "Location"

I am trying to create an item using the "createLocation" function generated by DAB, with a mutation such as the below:

mutation{
  createLocation(item:{
    TenantId: "1",
    EntityType: "FromDAB",
    EntityId: "1",
    Address: "HelloGitHub"
  }) {
    TenantId
    EntityType
    EntityId
    Address
  }
}

However I get a 404 message with the error:

The 'kind' value 'MultiHash' specified in the partition key definition is invalid. Please choose 'Hash' partition type.

Please could you let me know how I can use the "createLocation" mutation correctly to create an item within my database?

Thanks!

Rich

@sajeetharan
Copy link
Member

@jacksorjacksor How are you passing the partition key? Can you provide a sample?

@jacksorjacksor
Copy link
Author

Hi @sajeetharan / @neeraj-sharma2592, thanks for getting back to me.

How are you passing the partition key?

At this point I don't believe that I am passing in the partition key. Where should I do that as part of DAB's usage?

Can you provide a sample?

I've included:

  • schema.gql [manually created]
  • config.dab [created through dab init]
  • sample item from Cosmos DB

Let me know if any other samples would be appropriate.

Rich

schema.gql

type Location @model{
    id: ID
    TenantId: String
    EntityType: String
    EntityId: String
    Address: String
    Buildings: [Building]
}

type Building{
    id: ID
    Name: String
    Levels: [Level]
}

type Level{
    id: ID
    Name: String
}

dab-config.json

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.8.50/dab.draft.schema.json",
  "data-source": {
    "database-type": "cosmosdb_nosql",
    "connection-string": "AccountEndpoint=[REDACTED]",
    "options": {
      "database": "RichDb01",
      "container": "MRP",
      "schema": "schema.gql"
    }
  },
  "runtime": {
    "rest": {
      "enabled": false,
      "path": "/api"
    },
    "graphql": {
      "enabled": true,
      "path": "/graphql",
      "allow-introspection": true
    },
    "host": {
      "cors": {
        "origins": [],
        "allow-credentials": false
      },
      "authentication": {
        "provider": "StaticWebApps"
      },
      "mode": "development"
    }
  },
  "entities": {
    "Location": {
      "source": "MRP",
      "permissions": [
        {
          "role": "anonymous",
          "actions": ["*"]
        }
      ]
    }
  }
}

Sample item from Cosmos DB

{
    "id": "1-Location-1",
    "TenantId": "1",
    "EntityType": "Location",
    "EntityId": "1",
    "Address": "44 My Road, My Address, Postcode",
    "Buildings": [
        {
            "id": "1-Location-1-Building-1",
            "Name": "My First Building",
            "Levels": [
                {
                    "id": "1-Location-1-Building-1-Level-1",
                    "Name": "Level 1"
                }
            ]
        },
        {
            "id": "1-Location-1-Building-2",
            "Name": "My Second Building",
            "Levels": [
                {
                    "id": "1-Location-1-Building-2-Level-1",
                    "Name": "Level 1"
                }
            ]
        }
    ],
    // metadata (removed)
}

@sajeetharan sajeetharan added hacktoberfest engine issues that require change in engine code labels Oct 9, 2023
@sajeetharan
Copy link
Member

@jacksorjacksor Thanks a lot for providing the config and the sample. It's a limitation of DAB for Azure Cosmos DB as we currently use 3.20.0 which does not support hierarchical partitioning.

We are in the process of upgrading our SDK within DAB engine and will keep you posted.

Another question : were you able to perform query operation with Hierarchical Petitioning enabled?

@jacksorjacksor
Copy link
Author

@sajeetharan Hi there - huge apologies for the delay.

I'm able to run a basic ReadItemAsync() query on the Cosmos DB Emulator (on a container with a hierarchical partition key) through using the .NET SDK v3, but not through the Data Explorer.

Has there been any updates on whether DAB is supporting Hierarchical Partitioning?

@sajeetharan
Copy link
Member

sajeetharan commented Jan 31, 2024

@sajeetharan Hi there - huge apologies for the delay.

I'm able to run a basic ReadItemAsync() query on the Cosmos DB Emulator (on a container with a hierarchical partition key) through using the .NET SDK v3, but not through the Data Explorer.

Has there been any updates on whether DAB is supporting Hierarchical Partitioning?

Hi @jacksorjacksor, .Net SDK > 3.33.0 Supports Hierarchical Partitioning, as you mentioned that's the reason you see it working with emulator, DAB uses the .Net SDK version 3.20, we investigated supporting Hierarchical partitioning as a feature through DAB with Mutation and Queries, which requires a upgrading the SDK as well as design change. Our tentative ETA to support this is by April 2024. Let me know if you can wait till that.

@jacksorjacksor
Copy link
Author

@sajeetharan ok great, thanks for the confirmation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cosmos engine issues that require change in engine code hacktoberfest
Projects
None yet
Development

No branches or pull requests

4 participants