[[["わかりやすい","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-04-22 UTC。"],[[["\u003cp\u003eDataform allows you to preview the output of SQL queries in your workspace before executing them in BigQuery.\u003c/p\u003e\n"],["\u003cp\u003ePreviewing a query in Dataform involves running a temporary job in BigQuery, with results displayed in the Dataform workspace, and the temporary table is automatically deleted within 24 hours.\u003c/p\u003e\n"],["\u003cp\u003eThe Query results panel in Dataform provides detailed information about previewed queries, including job details, query results, and JSON output.\u003c/p\u003e\n"],["\u003cp\u003eDataform lets you preview both table creation queries and assertion queries within SQLX table definition files.\u003c/p\u003e\n"],["\u003cp\u003eRunning query preview incurs billing in BigQuery, because it runs a temporary job in BigQuery using your user credentials, while workflow execution uses your service account credentials.\u003c/p\u003e\n"]]],[],null,["# Preview SQL queries\n\nThis document shows you how to preview output of a SQL query in a\nDataform workspace before executing the query to BigQuery.\n\nAbout query preview in Dataform\n-------------------------------\n\nWhen you develop a query in a SQLX or JavaScript file with [Dataform core](/dataform/docs/overview#dataform-core), Dataform\ncompiles the query to SQL in real-time. To test the output of the compiled SQL\nquery before you run it to BigQuery, you can run preview of the\nquery in your Dataform workspace.\n\nWhen you run preview of a query, Dataform runs a job in\nBigQuery to run your compiled query in a temporary destination\ntable and display query results in your workspace. You can inspect the output of\nthe query before you trigger execution to publish your table to\nBigQuery. The temporary table with the previewed query is automatically\ndeleted in up to 24 hours. For more information about BigQuery jobs,\nsee [Manage jobs](/bigquery/docs/managing-jobs).\n\nRunning query preview in Dataform incurs billing in BigQuery.\nFor more information about BigQuery pricing, see [BigQuery\nPricing](/bigquery/pricing).\n\nDuring query preview, Dataform uses your user credentials to run jobs\nin BigQuery. However, during workflow execution Dataform uses\nyour service account credentials to create or update assets in\nBigQuery.\n\nDataform displays results of all queries previewed during the current\nbrowser session in the **Query results** panel in your workspace. In the **Query\nresults** panel, you can view the following information about each query\npreviewed during the current browser session:\n\n- Job information\n - BigQuery job ID\n - User running the preview\n - Location where the job is run, taken from your [workflow settings file](/dataform/docs/manage-repository#configure-workflow-settings)\n - Creation, start, and end times of the BigQuery job\n - Duration of the BigQuery job\n - Bytes processed\n - Bytes billed in BigQuery\n - Job priority\n - Use of [legacy SQL](/bigquery/docs/reference/standard-sql/introduction) in the query\n - Temporary destination table of the query\n- Results of the query\n- JSON representation of the query output\n\nMoreover, in the **Query results** panel, you can navigate to the source file of\neach previewed query, and navigate to BigQuery Studio to view the preview\njob.\n\nBefore you begin\n----------------\n\n1. In the Google Cloud console, go to the **Dataform** page.\n\n [Go to the Dataform page](https://console.cloud.google.com/bigquery/dataform)\n2. Select or [create a repository](/dataform/docs/create-repository).\n\n3. Select or [create a development workspace](/dataform/docs/create-workspace).\n\n4. Create a SQL query, for example,\n [create a table](/dataform/docs/create-tables#create-table).\n\n### Required roles\n\n\nTo get the permissions that\nyou need to preview queries,\n\nask your administrator to grant you the\nfollowing IAM roles on your project:\n\n- Dataform Editor (`roles/dataform.editor`) - workspaces\n- BigQuery Job User (`roles/bigquery.jobUser`) - 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\nPreview a query\n---------------\n\nTo inspect query results in Dataform before execution, run preview of a\nquery in your workspace. If the file being edited contains multiple queries,\nselect the query that you want to preview. You can preview one query at a time.\n\nRunning preview is a little different for tables with assertions. For more\ninformation, see [Preview a table with assertions](#preview-assertions-table).\n\nTo preview a SQL query and view query results in a Dataform\nworkspace, follow these steps:\n\n1. In the **Files** pane, expand `definitions/`.\n2. Select a SQLX or JavaScript file.\n3. Click **Run** .\n 1. If the file contains multiple queries, in the drop-down, select the query that you want to preview.\n4. Inspect results of the preview in the **Query results** panel.\n 1. To inspect job details, select the **Job information** tab.\n 2. To inspect query results, select the **Results** tab.\n 3. To view the JSON output of the query, select the **JSON** tab.\n 4. To view the preview job in SQL workspace, click the more_vert **More** menu \\\u003e **View job in SQL workspace**.\n\n### Preview a table with assertions\n\nIn a SQLX table definition file with assertions, you can preview the table\ncreation query and the defined assertion queries.\n\nDataform treats the table definition query as the default query. To\npreview the table creation query, click **Run** in your workspace. To preview an\nassertion query, you need to select it in a drop-down next to the\n**Run** button. You can preview one query at a time.\n\nTo preview a query in a table definition file with assertions in a\nDataform workspace, follow these steps:\n\n1. In the **Files** pane, expand `definitions/`.\n2. Select a definition file of a table with assertions.\n3. Run preview:\n - To preview the table creation query, click **Run**.\n - To preview an assertion query, click the drop-down icon next to **Run**, and then select the query that you want to preview.\n4. Inspect results of the preview in the **Query results** panel.\n 1. To inspect job details, select the **Job information** tab.\n 2. To inspect query results, select the **Results** tab.\n 3. To view the JSON output of the query, select the **JSON** tab.\n 4. To view the preview job in SQL workspace, click the more_vert **More** menu \\\u003e **View job in SQL workspace**.\n\nWhat's next\n-----------\n\n- To learn more about BigQuery pricing, see [BigQuery Pricing](/bigquery/pricing).\n- To learn more about Dataform pricing, see [Pricing](/dataform/pricing).\n- To learn more about workspaces in Dataform, see [Create a development workspace](/dataform/docs/create-workspace).\n- To learn how to test table queries with assertions, see [Test tables with assertions](/dataform/docs/assertions)."]]