[[["わかりやすい","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 UTC。"],[],[],null,["# Export to BigQuery\n\n| **Beta**\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\nThis document describes some attributes of the BigQuery dataset that is\ncreated when a sink exports traces from Cloud Trace to BigQuery.\n\nSchema\n------\n\nThe schema for your table that stores trace data is determined by the\nTrace V2 API definition of\n[Span](/trace/docs/reference/v2/rest/v2/projects.traces/batchWrite#Span).\n\nTrace keeps track of your table columns and patches the table\nwhen a new span contains fields that can't be stored in the existing table.\nA patch operation is required when an arriving span contains entries not\npreviously seen. For example, if an arriving span contains a new\n[Attribute](/trace/docs/reference/v2/rest/v2/Attributes), the table is patched.\n\nData retention\n--------------\n\nYou configure the data retention policies of your BigQuery tables.\nFor information about managing tables and table data, see\n[Working with tables](/bigquery/docs/tables-intro).\n\nTable type\n----------\n\nIf you configure a sink to export traces to BigQuery,\nTrace configures an\n[ingestion-time partitioned table](/bigquery/docs/creating-partitioned-tables).\nFor detailed information on partitioned tables, including how to create,\nmanaged, query, and delete these tables, see\n[Working with partitioned tables](/bigquery/docs/managing-partitioned-tables).\n\n### Sample queries\n\nIn the following queries, \u003cvar translate=\"no\"\u003eDATASET\u003c/var\u003e is the name of the\nBigQuery dataset, and \u003cvar translate=\"no\"\u003eMY_TABLE\u003c/var\u003e is the name of a table\nin that dataset.\n\n- To display all columns in the table for the date of\n November 20, 2019 while limiting the result to 10 rows, run the query:\n\n ```sql\n SELECT\n *\n FROM\n `DATASET.MY_TABLE`\n WHERE\n DATE(_PARTITIONTIME) = \"2019-11-20\" LIMIT 10\n ```\n- To display all of the partitions available in the table, run the\n query:\n\n ```sql\n SELECT\n _PARTITIONTIME as pt\n FROM\n `DATASET.MY_TABLE`\n GROUP BY 1\n ```\n\n### HipsterShop query\n\nHipsterShop is a demo application available on\n[GitHub](https://github.com/GoogleCloudPlatform/microservices-demo).\n\nThe following is a sample query that illustrates how you can use\nBigQuery queries to gather information that isn't readily\navailable using the Trace interface.\n\nThe inner query finds all spans that match the specified regular expression\nthat were received on December 2, 2019.\nThe outer query selects for display the following:\n\n- name\n- number of spans that match\n- number of distinct trace IDs\n- 50th, 90th, and 99th quantiles\n- HTTP path\n- Error message\n\nand displays the results sorted by the trace counts: \n\n```sql\nSELECT t0.span.displayName.value, count(t0.span.spanId) as spanCount, count(distinct traceId) as traceCount,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(50)] as p50,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(95)] as p95,\nAPPROX_QUANTILES(milliseconds, 100)[OFFSET(99)] as p99,\nt0.span.attributes.attributeMap._http_path,\nt0.span.attributes.attributeMap._error_message\nFROM (\nSELECT *,\nREGEXP_EXTRACT(span.name, r\"./traces/([a-f0-9]+).\") as traceId,\nTIMESTAMP_DIFF(span.endTime,span.startTime, MILLISECOND) as milliseconds\nFROM `hipstershop-demo.Hipstershop_trace_export.cloud_trace`\nWHERE DATE(_PARTITIONTIME) = \"2019-12-02\") AS t0\nWHERE t0.span.parentSpanId is NULL\nGROUP by t0.span.displayName.value, t0.span.attributes.attributeMap._http_path,t0.span.attributes.attributeMap._error_message\nORDER BY traceCount DESC\nLIMIT 1000\n \n```\n\nFor one particular installation of this application, the query result\nis as shown:\n\nView trace data\n---------------\n\nTo view your trace data by using the\n[BigQuery interface](/bigquery/docs/bigquery-web-ui),\nselect the table with your exported traces."]]