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

Incorrect bigquery dialect rewrite #397

Closed
brandboat opened this issue Dec 4, 2023 · 2 comments
Closed

Incorrect bigquery dialect rewrite #397

brandboat opened this issue Dec 4, 2023 · 2 comments
Labels

Comments

@brandboat
Copy link
Contributor

ERROR: com.google.cloud.bigquery.BigQueryException: OFFSET is not a function. It can only be used for array element access using array[OFFSET(position)] at [28:70]

{
  "catalog": "canner-cml",
  "schema": "hubspot",
  "models": [
    {
      "name": "Customer",
      "refSql": "select * from \"canner-cml\".hubspot.hubspot__companies",
      "columns": [
        {
          "name": "id",
          "type": "INTEGER",
          "isCalculated" : false,
          "notNull" : true,
          "expression": "company_id"
        },
        {
          "name": "company_name",
          "type": "STRING",
          "isCalculated" : false,
          "notNull" : false,
          "expression": "company_name"
        },
        {
          "name": "total_deal_size",
          "type": "FLOAT",
          "isCalculated" : true,
          "notNull" : false,
          "expression": "sum(deals.amount)"
        },
        {
          "name": "deals",
          "type": "Deal",
          "relationship": "CustomerDeals",
          "isCalculated" : false,
          "notNull" : true
        }
      ],
      "primaryKey": "id"
    },
    {
      "name": "Deal",
      "refSql": "select * from \"canner-cml\".hubspot.hubspot__deals",
      "columns": [
        {
          "name": "company_id",
          "type": "INTEGER",
          "isCalculated" : false,
          "notNull" : false,
          "expression": "company_id"
        },
        {
          "name": "deal_name",
          "type": "STRING",
          "isCalculated" : false,
          "notNull" : false,
          "expression": "deal_name"
        },
        {
          "name": "owner_name",
          "type": "STRING",
          "isCalculated" : false,
          "notNull" : false,
          "expression": "owner_full_name"
        },
        {
          "name": "amount",
          "type": "FLOAT",
          "isCalculated": false,
          "notNull": false,
          "expression": "amount"
        }
      ]
    },
    {
      "name": "Ticket",
      "refSql": "select * from \"canner-cml\".hubspot.hubspot__tickets",
      "columns": [
        {
          "name": "id",
          "type": "INTEGER",
          "isCalculated" : false,
          "notNull" : true,
          "expression": "ticket_id"
        },
        {
          "name": "owner_name",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "owner_full_name"
        },
        {
          "name": "closed_date",
          "type": "DATE",
          "isCalculated": false,
          "notNull": false,
          "expression": "closed_date"
        },
        {
          "name": "created_date",
          "type": "DATE",
          "isCalculated": false,
          "notNull": false,
          "expression": "created_date"
        },
        {
          "name": "first_agent_reply_date",
          "type": "DATE",
          "isCalculated": false,
          "notNull": false,
          "expression": "first_agent_reply_at"
        },
        {
          "name": "ticket_status",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "pipeline_stage_label"
        },
        {
          "name": "ticket_category",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "ticket_category"
        },
        {
          "name": "is_closed",
          "type": "BOOLEAN",
          "isCalculated": false,
          "notNull": false,
          "expression": "is_closed"
        },
        {
          "name": "company_name",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "SPLIT(ARRAY_TO_STRING(company_names, ';'), ';')[OFFSET(0)]"
        },
        {
          "name": "company_id",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "SPLIT(ARRAY_TO_STRING(company_ids, ';'), ';')[OFFSET(0)]"
        },
        {
          "name": "subject",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "ticket_subject"
        },
        {
          "name": "content",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "ticket_content"
        },
        {
          "name": "severity",
          "type": "STRING",
          "isCalculated": false,
          "notNull": false,
          "expression": "ticket_priority"
        }
      ]
    }
  ],
  "relationships": [
    {
      "name": "CustomerDeals",
      "models": [ "Customer", "Deal" ],
      "joinType": "ONE_TO_MANY",
      "condition": "Customer.id = Deal.company_id"
    }
  ],
  "metrics": [],
  "enumDefinitions": [],
  "views": []
}
@brandboat
Copy link
Contributor Author

currently there is a workaround, convert [OFFSET(0)] to [0]

@goldmedal
Copy link
Collaborator

legacy issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants