{"title":"BigQuery","description":"Add BigQuery as an external catalog in Altertable for unified analytics. Configure service account credentials and required roles to query BigQuery data.","order":100,"askSuggestions":["Which roles does a read-only service account need?","What if my organization blocks service account keys?","Which roles let Altertable write to BigQuery?"],"navigation":true,"body":{"code":"var Component=(()=>{var g=Object.create;var t=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),q=(r,e)=>{for(var o in e)t(r,o,{get:e[o],enumerable:!0})},s=(r,e,o,i)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let c of p(e))!m.call(r,c)&&c!==o&&t(r,c,{get:()=>e[c],enumerable:!(i=y(e,c))||i.enumerable});return r};var A=(r,e,o)=>(o=r!=null?g(b(r)):{},s(e||!r||!r.__esModule?t(o,\"default\",{value:r,enumerable:!0}):o,r)),C=r=>s(t({},\"__esModule\",{value:!0}),r);var d=f((S,l)=>{l.exports=_jsx_runtime});var I={};q(I,{default:()=>u,frontmatter:()=>v});var n=A(d()),v={title:\"BigQuery\",description:\"Add BigQuery as an external catalog in Altertable for unified analytics. Configure service account credentials and required roles to query BigQuery data.\",order:100,askSuggestions:[\"Which roles does a read-only service account need?\",\"What if my organization blocks service account keys?\",\"Which roles let Altertable write to BigQuery?\"]};function h(r){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",h4:\"h4\",li:\"li\",ol:\"ol\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...r.components},{DocsPreviewDocument:o,DocsPreviewSection:i,Screenshot:c}=e;return o||a(\"DocsPreviewDocument\",!0),i||a(\"DocsPreviewSection\",!0),c||a(\"Screenshot\",!0),(0,n.jsxs)(o,{anchors:\"bigquery prerequisites 1-enable-the-bigquery-api 2-check-organization-policies 3-create-a-service-account read-only-access-default read-write-access connecting-to-altertable\",children:[(0,n.jsxs)(i,{sectionId:\"bigquery\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"bigquery\",children:\"BigQuery\"}),`\n`,(0,n.jsx)(e.p,{children:\"Add your BigQuery project as an external catalog in Altertable to query and analyze it alongside your other data sources.\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"prerequisites\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"prerequisites\",children:\"Prerequisites\"}),`\n`,(0,n.jsx)(e.p,{children:\"Before connecting BigQuery to Altertable, you'll need to configure your Google Cloud project:\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"1-enable-the-bigquery-api\",anchors:\"\",ancestors:\"prerequisites\",index:\"2\",children:[(0,n.jsx)(e.h3,{id:\"1-enable-the-bigquery-api\",children:\"1. Enable the BigQuery API\"}),`\n`,(0,n.jsx)(e.p,{children:\"Enable the BigQuery API within your Google Cloud project.\"}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"2-check-organization-policies\",anchors:\"\",ancestors:\"prerequisites\",index:\"3\",children:[(0,n.jsx)(e.h3,{id:\"2-check-organization-policies\",children:\"2. Check Organization Policies\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Ensure your organization doesn't have the \",(0,n.jsx)(e.code,{children:\"constraints/iam.disableServiceAccountKeyCreation\"}),\" policy enforced:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`# Check at project level\ngcloud resource-manager org-policies describe constraints/iam.disableServiceAccountKeyCreation --project=PROJECT_ID\n\n# Or check at organization level\ngcloud resource-manager org-policies describe constraints/iam.disableServiceAccountKeyCreation --organization=ORG_ID\n`})}),`\n`,(0,n.jsx)(e.p,{children:\"If enforced, you can disable it with:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`gcloud resource-manager org-policies disable-enforce constraints/iam.disableServiceAccountKeyCreation --project=PROJECT_ID\n`})}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"3-create-a-service-account\",anchors:\"\",ancestors:\"prerequisites\",index:\"4\",children:[(0,n.jsx)(e.h3,{id:\"3-create-a-service-account\",children:\"3. Create a Service Account\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Create a service account (\",(0,n.jsx)(e.a,{href:\"https://docs.cloud.google.com/iam/docs/keys-create-delete#creating\",children:\"learn how to create and download a service account key\"}),\") and grant it roles for the access you need.\"]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"read-only-access-default\",anchors:\"\",ancestors:\"prerequisites 3-create-a-service-account\",index:\"5\",children:[(0,n.jsx)(e.h4,{id:\"read-only-access-default\",children:\"Read-only access (default)\"}),`\n`,(0,n.jsx)(e.p,{children:\"Grant these 3 roles:\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Data Viewer\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.dataViewer\"}),\"): Read data and metadata. Grant it on the datasets Altertable needs to read.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Job User\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.jobUser\"}),\"): Run jobs, including queries. Grant it on the project used to run queries.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Read Session User\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.readSessionUser\"}),\"): Create and use read sessions through the BigQuery Storage Read API. Grant it on the project used to run queries.\"]}),`\n`]}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"read-write-access\",anchors:\"\",ancestors:\"prerequisites 3-create-a-service-account\",index:\"6\",children:[(0,n.jsx)(e.h4,{id:\"read-write-access\",children:\"Read-write access\"}),`\n`,(0,n.jsx)(e.p,{children:\"Grant these 3 roles when Altertable also needs to write data:\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Data Editor\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.dataEditor\"}),\"): Read and write data, and create, update, and delete tables. Grant it on the datasets Altertable needs to read and write, or on the project if it also needs to create datasets.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Job User\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.jobUser\"}),\"): Run jobs, including queries. Grant it on the project used to run queries.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"BigQuery Read Session User\"}),\" (\",(0,n.jsx)(e.code,{children:\"roles/bigquery.readSessionUser\"}),\"): Create and use read sessions through the BigQuery Storage Read API. Grant it on the project used to run queries.\"]}),`\n`]}),`\n`,(0,n.jsxs)(e.p,{children:[\"See \",(0,n.jsx)(e.a,{href:\"https://docs.cloud.google.com/bigquery/docs/access-control\",children:\"Google Cloud's BigQuery IAM roles\"}),\" for the full permissions of each role.\"]}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:\"If you cannot grant the roles\"}),\", ensure your admin user has the \",(0,n.jsx)(e.code,{children:\"orgpolicy.policyAdmin\"}),\" role:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`gcloud organizations add-iam-policy-binding ORG_ID \\\\\n  --member=\"user:YOUR_ADMIN_USER_EMAIL\" \\\\\n  --role=\"roles/orgpolicy.policyAdmin\"\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:\"Grant missing roles\"}),\" with:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`gcloud projects add-iam-policy-binding PROJECT_ID \\\\\n  --member=\"serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com\" \\\\\n  --role=\"THE_MISSING_ROLE\"\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.strong,{children:\"Validate the roles\"}),\" with:\"]}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`gcloud projects get-iam-policy PROJECT_ID \\\\\n  --flatten=\"bindings[].members\" \\\\\n  --filter=\"bindings.members:serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com\" \\\\\n  --format=\"table(bindings.role)\"\n`})}),`\n`]}),(0,n.jsxs)(i,{sectionId:\"connecting-to-altertable\",anchors:\"\",ancestors:\"\",index:\"7\",children:[(0,n.jsx)(e.h2,{id:\"connecting-to-altertable\",children:\"Connecting to Altertable\"}),`\n`,(0,n.jsx)(e.p,{children:\"To add a new BigQuery external catalog:\"}),`\n`,(0,n.jsxs)(e.ol,{children:[`\n`,(0,n.jsxs)(e.li,{children:[\"Navigate to the \",(0,n.jsx)(e.strong,{children:\"Catalogs\"}),\" section in the dashboard\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Click \",(0,n.jsx)(e.strong,{children:\"New catalog\"})]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Select \",(0,n.jsx)(e.strong,{children:\"BigQuery\"}),\" as the engine\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Fill in the connection details:\",`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Name\"}),\": A descriptive name for your catalog\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Service Account Credentials\"}),\": Upload your service account JSON key file\"]}),`\n`]}),`\n`]}),`\n`,(0,n.jsxs)(e.li,{children:[\"Click \",(0,n.jsx)(e.strong,{children:\"Save\"})]}),`\n`]}),`\n`,(0,n.jsx)(c,{story:\"components-connectionform--big-query-empty\",caption:\"New BigQuery connection form\",width:\"1408\",height:\"1508\"}),`\n`,(0,n.jsx)(e.p,{children:\"Once added, you can start querying your BigQuery data through Altertable's SQL engine.\"})]})]})}function u(r={}){let{wrapper:e}=r.components||{};return e?(0,n.jsx)(e,{...r,children:(0,n.jsx)(h,{...r})}):h(r)}function a(r,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+r+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return C(I);})();\n;return Component;"},"_id":"docs/lakehouse/external-catalogs/bigquery.mdx","_raw":{"sourceFilePath":"docs/lakehouse/external-catalogs/bigquery.mdx","sourceFileName":"bigquery.mdx","sourceFileDir":"docs/lakehouse/external-catalogs","contentType":"mdx","flattenedPath":"docs/lakehouse/external-catalogs/bigquery"},"type":"Docs","path":"/lakehouse/external-catalogs/bigquery","level":3,"parent":"lakehouse/external-catalogs"}