이 문서에서는 쿼리를 BigQuery에 실행하기 전에 Dataform 작업공간에서 SQL 쿼리의 출력을 미리 보는 방법을 보여줍니다.
Dataform의 쿼리 미리보기 정보
Dataform Core를 사용하여 SQLX 또는 자바스크립트 파일에서 쿼리를 개발할 때 Dataform은 실시간으로 쿼리를 SQL로 컴파일합니다. 컴파일된 SQL 쿼리를 BigQuery에 실행하기 전에 출력을 테스트하려면 Dataform 작업공간에서 쿼리 미리보기를 실행하면 됩니다.
쿼리 미리보기를 실행하면 Dataform이 BigQuery에서 작업을 실행하여 임시 대상 테이블에서 컴파일된 쿼리를 실행하고 작업공간에 쿼리 결과를 표시합니다. 실행을 트리거하여 테이블을 BigQuery에 게시하기 전에 쿼리 출력을 검사할 수 있습니다. 미리보기된 쿼리가 있는 임시 테이블은 최대 24시간 후에 자동으로 삭제됩니다. BigQuery 작업에 대한 자세한 내용은 BigQuery 작업 소개를 참조하세요.
Dataform에서 쿼리 미리보기를 실행하면 BigQuery에서 요금이 청구됩니다.
BigQuery 가격 책정에 대한 자세한 내용은 BigQuery 가격 책정을 참조하세요.
쿼리 미리보기 중에 Dataform은 사용자 인증 정보를 사용하여 BigQuery에서 작업을 실행합니다. 하지만 워크플로 실행 중에 Dataform은 서비스 계정 사용자 인증 정보를 사용하여 BigQuery에서 애셋을 만들거나 업데이트합니다.
Dataform은 작업공간의 쿼리 결과 패널에 현재 브라우저 세션 중에 미리보기된 모든 쿼리의 결과를 표시합니다. 쿼리 결과 패널에서 현재 브라우저 세션 중에 미리보기된 각 쿼리에 대한 다음 정보를 볼 수 있습니다.
[[["이해하기 쉬움","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-02-11(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)."]]