hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.08k stars 2.76k forks source link

console: connector execution plan shows an error #10388

Open harishnair96 opened 2 months ago

harishnair96 commented 2 months ago

Component

Console

What is the current behaviour?

Going to Connector Execution Plan of the sample e commerce project shows an error:

Screenshot 2024-07-15 at 4 51 37 PM
julian-mayorga commented 2 months ago

Thanks for the bug report @harishnair96!

Could you tell me what query you sent in order to see that error on the execution plan?

For example, I tried with the following query and could successfully see its execution plan.

{
  analytics_browsingHistory {
    userId
  }
}

https://github.com/user-attachments/assets/2b2ce84f-ef68-4c2e-bcb9-294b7d03978e

harishnair96 commented 2 months ago

@julian-mayorga Here is an example

https://github.com/user-attachments/assets/cb1e45b1-119c-4ab0-896f-f9829b0a4577

julian-mayorga commented 2 months ago

Thanks Harish! Will dig deeper into the issue

julian-mayorga commented 2 months ago

https://github.com/user-attachments/assets/76ffd683-09f3-420a-a370-50200e7880a3

Still cannot reproduce this issue. Went to the ecommerce example and followed your exact same steps.

Can I ask you another favor? Could you go to the network tab and copy the response of the request to /explain? It'd help me debug this problem.

soorajshankar commented 1 month ago

I can reproduce this, and looks like the error comes from the engine (or ndc) here is the /explain response

{
  "explain": {
    "type": "modelSelect",
    "value": {
      "modelName": "analytics_browsingHistory",
      "ndcRequest": {
        "type": "query",
        "value": {
          "version": "v0.1.x",
          "collection": "browsing_history",
          "query": {
            "fields": {
              "productId": {
                "type": "column",
                "column": "product_id",
                "fields": null
              },
              "userId": {
                "type": "column",
                "column": "user_id",
                "fields": null
              },
              "viewedAt": {
                "type": "column",
                "column": "viewed_at",
                "fields": null
              }
            }
          },
          "arguments": {},
          "collection_relationships": {}
        }
      },
      "ndcExplain": {
        "type": "response",
        "value": {
          "version": "v0.1.x",
          "details": {
            "Execution Plan": "error decoding response body",
            "Parameterized SQL Query": "EXPLAIN\nSELECT\n  toJSONString(\n    groupArray(\n      cast(\n        \"_rowset\".\"_rowset\",\n        'Tuple(rows Array(Tuple(\"productId\" String, \"userId\" String, \"viewedAt\" String)))'\n      )\n    )\n  ) AS \"rowsets\"\nFROM\n  (\n    SELECT\n      tuple(\n        groupArray(\n          tuple(\n            \"_row\".\"_field_productId\",\n            \"_row\".\"_field_userId\",\n            \"_row\".\"_field_viewedAt\"\n          )\n        )\n      ) AS \"_rowset\"\n    FROM\n      (\n        SELECT\n          \"_origin\".\"product_id\" AS \"_field_productId\",\n          \"_origin\".\"user_id\" AS \"_field_userId\",\n          \"_origin\".\"viewed_at\" AS \"_field_viewedAt\"\n        FROM\n          \"default\".\"browsing_history\" AS \"_origin\"\n      ) AS \"_row\"\n  ) AS \"_rowset\" FORMAT TabSeparatedRaw;",
            "Parameters": "[]",
            "SQL Query": "EXPLAIN\nSELECT\n  toJSONString(\n    groupArray(\n      cast(\n        \"_rowset\".\"_rowset\",\n        'Tuple(rows Array(Tuple(\"productId\" String, \"userId\" String, \"viewedAt\" String)))'\n      )\n    )\n  ) AS \"rowsets\"\nFROM\n  (\n    SELECT\n      tuple(\n        groupArray(\n          tuple(\n            \"_row\".\"_field_productId\",\n            \"_row\".\"_field_userId\",\n            \"_row\".\"_field_viewedAt\"\n          )\n        )\n      ) AS \"_rowset\"\n    FROM\n      (\n        SELECT\n          \"_origin\".\"product_id\" AS \"_field_productId\",\n          \"_origin\".\"user_id\" AS \"_field_userId\",\n          \"_origin\".\"viewed_at\" AS \"_field_viewedAt\"\n        FROM\n          \"default\".\"browsing_history\" AS \"_origin\"\n      ) AS \"_row\"\n  ) AS \"_rowset\" FORMAT TabSeparatedRaw;"
          }
        }
      }
    }
  }
}

here is the steps to reproduce this

  1. Go to the sample project https://console.hasura.io/project/vast-buzzard-8147/build/37008832ab/graphql

  2. Write the following GQL query

    query MyQuery {
    analytics_browsingHistory {
    productId
    userId
    viewedAt
    }
    }
  3. click on the explain, go to the connector execution plan, you should see the above error.

  4. Error is not from console - its coming from upstream.

soorajshankar commented 1 month ago

Looks like this happens to the fields that are coming from clickhouse database only, marking this as a clickhouse connector issue.