[[["容易理解","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-09-04 (世界標準時間)。"],[[["\u003cp\u003eBigQuery DataFrames enable the synchronization of datasets between BigQuery and Bigtable, facilitating real-time analytics and machine learning pipelines.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebigframes.streaming API\u003c/code\u003e creates BigQuery jobs that automatically replicate and synchronize data across BigQuery and Bigtable for online serving.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ebigframes.streaming.StreamingDataFrame\u003c/code\u003e allows users to create continuously running jobs that stream data from BigQuery tables into Bigtable.\u003c/p\u003e\n"],["\u003cp\u003eTo use BigQuery DataFrames in a BigQuery notebook, specific IAM roles such as BigQuery User, Notebook Runtime User, and Code Creator are required.\u003c/p\u003e\n"],["\u003cp\u003eWhile there are no direct charges for using the BigQuery BigFrames API, costs are incurred for the underlying resources such as continuous queries, Bigtable, and BigQuery storage.\u003c/p\u003e\n"]]],[],null,["# Synchronize online and offline datasets with BigQuery DataFrames\n\nSynchronize online and offline datasets with\nBigQuery DataFrames\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\nUsing Bigtable with BigQuery, you can build a\n*real-time analytics database* and use it in machine learning (ML) pipelines.\nThis lets you keep your data in sync, supporting data manipulation and model\ndevelopment (offline access) and low-latency application serving (online\naccess).\n\nTo build your real-time analytics database, you can use\n[BigQuery DataFrames](/bigquery/docs/bigquery-dataframes-introduction),\na set of open-source Python libraries for BigQuery data\nprocessing. BigQuery DataFrames lets you develop and train models in\nBigQuery and automatically replicate a copy of the latest data\nvalues used for your ML models in Bigtable for online serving.\n\nThis document provides an overview of using the `bigframes.streaming API` to\ncreate BigQuery jobs that automatically replicate and synchronize\ndatasets across BigQuery and Bigtable. Before you\nread this document, make sure that you understand the following documents:\n\n- [Bigtable overview](/bigtable/docs/overview)\n- [BigQuery overview](/bigquery/docs/introduction)\n- [Build a real-time analytics database with Bigtable and\n BigQuery](/solutions/real-time-analytics-for-databases)\n\nBigQuery DataFrames\n-------------------\n\nBigQuery DataFrames helps you develop and\ntrain models in BigQuery and automatically replicate a copy of\nthe latest data values used for your ML models in Bigtable for\nonline serving. It lets you do the following:\n\n- Develop data transformations in a Pandas-compatible interface (`bigframes.pandas`) directly against BigQuery data\n- Train models using a scikit-learn-like API (`bigframes.ML`)\n- Synchronize the data needed for low-latency inference with Bigtable (`bigframes.streaming`) to support user-facing applications\n\n| **Note:** If you want to batch export from BigQuery to Bigtable using SQL, you can set up a reverse extract-load-transform (ETL). For more information, see [Export data to\n| Bigtable (Reverse ETL)](/bigquery/docs/export-to-bigtable).\n\nBigFrames StreamingDataFrame\n----------------------------\n\n`bigframes.streaming.StreamingDataFrame` is a DataFrame type in the\nBigQuery DataFrames package. It lets you create a\n`StreamingDataFrame` object that can be used to generate a continuously running\njob that streams data from a designated BigQuery table into\nBigtable for online serving. This is done by generating [BigQuery\ncontinuous queries](/bigquery/docs/continuous-queries-introduction).\n\nA `BigFrames StreamingDataFrame` can do the following:\n\n- Create a `StreamingDataFrame` from a designated BigQuery table\n- Optionally, perform additional Pandas operations like select, filter, and preview the content\n- Create and manage streaming jobs to Bigtable\n\nRequired roles\n--------------\n\nTo get the permissions that you need to use BigQuery DataFrames\nin a BigQuery notebook, ask your administrator to grant you the\nfollowing IAM roles:\n\n- [BigQuery User (`roles/bigquery.user`)](/bigquery/docs/access-control#bigquery.user)\n\n- [Notebook Runtime User (`roles/aiplatform.notebookRuntimeUser`)](/vertex-ai/docs/general/access-control#aiplatform.notebookRuntimeUser)\n\n- [Code Creator (`roles/dataform.codeCreator`)](/dataform/docs/access-control#dataform.codeCreator)\n\nTo get the permissions that you need to write data to a Bigtable\ntable, ask your administrator to grant you the following IAM\nroles:\n\n- [Bigtable User (roles/bigtable.user)](/bigtable/docs/access-control#bigtable.user)\n\nGet started\n-----------\n\nBigQuery DataFrames is an open-source package. To install the\nlatest version, run `pip install --upgrade bigframes`.\n\nTo create your first `BigFrames StreamingDataFrame` and synchronize data between\nBigQuery and Bigtable, run following code snippet.\nFor the complete code sample, see the GitHub notebook [BigFrames\nStreamingDataFrame](https://github.com/googleapis/python-bigquery-dataframes/blob/main/notebooks/streaming/streaming_dataframe.ipynb). \n\n import bigframes.streaming as bst\n\n bigframes.options._bigquery_options.project = \"\u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e\"\n\n sdf = bst.read_gbq_table(\"birds.penguins_bigtable_streaming\")\n\n job = sdf.to_bigtable(instance=\"\u003cvar translate=\"no\"\u003eBIGTABLE_INSTANCE\u003c/var\u003e\",\n\n table=\"\u003cvar translate=\"no\"\u003eTABLE\u003c/var\u003e\",\n\n app_profile=None,\n\n truncate=True,\n\n overwrite=True,`\n\n auto_create_column_families=True,\n\n bigtable_options={},\n\n job_id=None,\n\n job_id_prefix= \"test_streaming_\",)\n\n print(job.running())\n\n print(job.error_result)\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e: the ID of your Google Cloud project\n- \u003cvar translate=\"no\"\u003eBIGTABLE_INSTANCE\u003c/var\u003e: the ID of the Bigtable instance that contains the table you are writing to\n- \u003cvar translate=\"no\"\u003eTABLE\u003c/var\u003e: the ID of the Bigtable table that you are writing to\n\nOnce the job is initialized, it runs as a continuous query in\nBigQuery and streams any data changes to Bigtable.\n\nCosts\n-----\n\nThere are no additional charges for using the BigQuery BigFrames\nAPI, but you are charged for the underlying resources used for\ncontinuous queries, Bigtable, and BigQuery.\n\nContinuous queries use [BigQuery capacity compute\npricing](/bigquery/pricing#capacity_compute_analysis_pricing),\nwhich is measured in [slots](/bigquery/docs/slots). To\nrun continuous queries, you must have a\n[reservation](/bigquery/docs/reservations-workload-management)\nthat uses the [Enterprise or Enterprise Plus\nedition](/bigquery/docs/editions-intro) and a\n[reservation\nassignment](/bigquery/docs/reservations-intro#assignments)\nthat uses the `CONTINUOUS` job type.\n\nUsage of other BigQuery resources, such as data ingestion and\nstorage, are charged at the rates shown in [BigQuery\npricing](/bigquery/pricing).\n\nUsage of Bigtable services that receive continuous query\nresults are charged at the [Bigtable\npricing](/bigtable/pricing) rates.\n\nLimitations\n-----------\n\nAll\n[feature](/bigquery/docs/continuous-queries-introduction#limitations)\nand\n[location](/bigquery/docs/continuous-queries-introduction#locations)\nlimitations associated with continuous queries are also applicable for\nstreaming DataFrames.\n\nWhat's next\n-----------\n\n- [Getting started with Feast on Google Cloud](/blog/products/databases/getting-started-with-feast-on-google-cloud)\n- [Streamlining ML Development with Feast](/blog/products/databases/how-feast-feature-store-streamlines-ml-development)\n- [Query Bigtable data stored in an external table.](/bigquery/docs/external-data-bigtable)\n- [Export data from BigQuery to Bigtable.](/bigquery/docs/export-to-bigtable)"]]