SELECTc.customer_id,c.name,rq.first_order_dateFROMmydataset.customersAScLEFTOUTERJOINEXTERNAL_QUERY('connection_id','''SELECT CUSTOMER_ID, MIN(ORDER_DATE) AS first_order_date FROM ORDERS GROUP BY CUSTOMER_ID''')ASrqONrq.customer_id=c.customer_idGROUPBYc.customer_id,c.name,rq.first_order_date;
-- List all views in a schema.SELECT*FROMEXTERNAL_QUERY('connection_id','''SELECT VIEW_NAME FROM SYS.VIEWS WHERE SCHEMA_NAME = 'MY_SCHEMA'''');
-- List all columns in a view.SELECT*FROMEXTERNAL_QUERY('connection_id','''SELECT COLUMN_NAME, DATA_TYPE_NAME FROM SYS.VIEW_COLUMNS WHERE SCHEMA_NAME = 'MY_SCHEMA' AND VIEW_NAME = 'my_view' ORDER BY POSITION''');
料金
連携クエリの実行にかかる費用は、次の 3 つの要因に基づきます。
SAP Datasphere でクエリを実行する際のコンピューティング費用。
SAP Datasphere から BigQuery にクエリ結果を転送する際の帯域幅費用。
BigQuery でクエリを実行するコンピューティング費用。
SAP Datasphere に関連する費用は、使用する SAP サービスの種類によって異なります。帯域幅コストを抑えるため、クエリは、最終結果の計算に不要な列と行をすべて除外するように、EXTERNAL_QUERY に記述することをおすすめします。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-17 UTC。"],[[["\u003cp\u003eBigQuery's SAP Datasphere federation allows real-time querying of data in SAP Datasphere without data replication.\u003c/p\u003e\n"],["\u003cp\u003eFederated queries to SAP Datasphere are executed using the \u003ccode\u003eEXTERNAL_QUERY\u003c/code\u003e function within BigQuery, with results transferred back to BigQuery.\u003c/p\u003e\n"],["\u003cp\u003eThis feature is currently in a Pre-GA phase and has limitations, including querying only relational views exposed for consumption, potential higher latency, and no SQL pushdown support.\u003c/p\u003e\n"],["\u003cp\u003eUsers require the BigQuery Connection User IAM role to query SAP Datasphere and must have an existing shared connection.\u003c/p\u003e\n"],["\u003cp\u003eThe cost of federated queries is based on compute in both SAP Datasphere and BigQuery, and bandwidth for transferring results.\u003c/p\u003e\n"]]],[],null,["# SAP Datasphere federated queries\n================================\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n| **Note:** To get support or provide feedback for this preview feature, contact [bq-sap-federation-support@google.com](mailto:bq-sap-federation-support@google.com).\n\nAs a data analyst, you can query relational data in SAP Datasphere from BigQuery using federated queries.\n\nBigQuery SAP Datasphere federation lets BigQuery query data residing in SAP Datasphere in real time, without copying or moving data.\n\nTo run a SQL query in SAP Datasphere, specify that SQL query within BigQuery in a `EXTERNAL_QUERY` function. The results are then transferred from SAP Datasphere to BigQuery.\n\nLimitations\n-----------\n\n- You can only query relational views that are [exposed for consumption](https://help.sap.com/docs/SAP_DATASPHERE/43509d67b8b84e66a30851e832f66911/d7d56284bb5148c887ac4054689bfbca.html?locale=en-US). Other objects in SAP Datasphere are not accessible to the query federated through `EXTERNAL_QUERY`.\n- The federated query latency might be noticeably higher than the same query if it was executed directly in SAP Datasphere.\n- The first query that uses SAP Datasphere connection in a given project might take more than a minute to run.\n- No additional [SQL pushdowns](/bigquery/docs/federated-queries-intro#sql_pushdowns) are supported for SAP Datasphere.\n- The SAP Datasphere SQL query must specify aliases for columns that contain function results.\n- When the usage of Compute Engine API in the query project is restricted by [VPC Service Controls](/vpc-service-controls/docs/overview), the federated query will fail.\n\nBefore you begin\n----------------\n\nEnsure that your BigQuery administrator has [created a SAP Datasphere connection](/bigquery/docs/connect-to-sap-datasphere)\nand [shared](/bigquery/docs/connect-to-sap-datasphere#share_connections)\nit with you.\n\n### Required roles\n\n\nTo get the permissions that\nyou need to query SAP Datasphere,\n\nask your administrator to grant you the\n\n\n[BigQuery Connection User](/iam/docs/roles-permissions/bigquery#bigquery.connectionUser) (`roles/bigquery.connectionUser`)\nIAM role on the project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nQuery data\n----------\n\nTo send a federated query to SAP Datasphere from a GoogleSQL query, use the\n[EXTERNAL_QUERY function](/bigquery/docs/reference/standard-sql/federated_query_functions#external_query).\n\nThe following example is a federated query that joins a table in SAP Datasphere named `ORDERS` and a table in BigQuery named `mydataset.customers`. \n\n SELECT c.customer_id, c.name, rq.first_order_date\n FROM mydataset.customers AS c\n LEFT OUTER JOIN EXTERNAL_QUERY(\n 'connection_id',\n '''SELECT CUSTOMER_ID, MIN(ORDER_DATE) AS first_order_date\n FROM ORDERS\n GROUP BY CUSTOMER_ID''') AS rq\n ON rq.customer_id = c.customer_id\n GROUP BY c.customer_id, c.name, rq.first_order_date;\n\nView a SAP Datasphere table schema\n----------------------------------\n\nThe following examples use the [EXTERNAL_QUERY function](/bigquery/docs/reference/standard-sql/federated_query_functions#external_query) to retrieve database metadata from the\n`SYS` schema in SAP Datasphere. \n\n -- List all views in a schema.\n SELECT * FROM EXTERNAL_QUERY(\n 'connection_id',\n '''SELECT VIEW_NAME FROM SYS.VIEWS\n WHERE SCHEMA_NAME = 'MY_SCHEMA'''');\n\n -- List all columns in a view.\n SELECT * FROM EXTERNAL_QUERY(\n 'connection_id',\n '''SELECT COLUMN_NAME, DATA_TYPE_NAME\n FROM SYS.VIEW_COLUMNS\n WHERE SCHEMA_NAME = 'MY_SCHEMA' AND\n VIEW_NAME = 'my_view'\n ORDER BY POSITION''');\n\nPricing\n-------\n\nThe cost of running a federated query is based on three factors:\n\n- The compute cost of executing the query in SAP Datasphere.\n- The bandwidth cost of transferring the query results from SAP Datasphere to BigQuery.\n- The compute cost of executing the query in BigQuery.\n\nAny SAP Datasphere related costs depend on the type of SAP service you use. To\nlimit the bandwidth cost, we recommend that you write the query in the\n`EXTERNAL_QUERY` so that it excludes all columns and rows that are not needed to\ncompute the final result.\n\nThere is no additional cost for running federated queries in BigQuery.\nFor more information about BigQuery pricing, see [Pricing](/bigquery/pricing).\n\nWhat's next\n-----------\n\n- Learn about [federated queries](/bigquery/docs/federated-queries-intro).\n- Learn about [unsupported data types](/bigquery/docs/reference/standard-sql/federated_query_functions#unsupported_data_types)."]]