tencent cloud

Tencent Cloud DataBuddy

Quick Start for Data Analysts

ダウンロード
フォーカスモード
フォントサイズ
最終更新日: 2026-10-09 16:08:24
AI翻訳
Tip
Estimated duration: 60 minutes. Learning objective: Using a sales performance analysis scenario as an example, run through the complete data analysis pipeline end to end, from table creation and data loading → ad hoc SQL analysis → result visualization → dashboard creation → publishing and subscription.

Scenario Introduction

You are a newly hired data analyst. The business team wants to quickly view sales performance by region and product, and to open a fixed dashboard every day to check the latest data.
This tutorial will walk you through:
1. Use SQL analysis to create a sample sales table and write several days of demo data into it.
2. Complete the first batch of ad hoc queries: basic exploration, aggregation by region, time-based trends, window ranking, and parameterized reuse.
3. Convert query results into charts with one click, and export them as Excel files for reporting.
4. Save the queries to a dashboard that combines four components: KPI cards, bar charts, line charts, and tables.
5. Add a global filter and publish the dashboard.
After completing this tutorial, you will master the full set of operations that data analysts perform most frequently in DataBuddy on a daily basis.

Prerequisites

Before starting this tutorial, make sure the following prerequisites are met:
You have activated the DataBuddy service and completed workspace initialization.
The current account has the Workspace Member role or higher permissions in the target workspace. For details about role permissions, see Members and Permission Management.
The workspace is bound to an interactive analysis cluster resource, which is used for ad hoc SQL queries and dashboard queries. For more information, see Compute Resource Overview.
The workspace is bound to a data lakehouse Catalog (default: DataLakeCatalog), and the current account has database creation, table creation, read and write permissions on the Catalog.
The default email address is bound to the current account and will be used in the subscription push verification step.
Tip
This tutorial does not rely on any external data sources. All sample data is written to the data lakehouse by using SQL INSERT statements. If your workspace already has real business tables, you can replace the table names with your business tables starting from Step 3 and skip Step 2.

Tutorial Data Model

All SQL statements in this tutorial are based on a single sales_data table:
Field
Type
Description
date
STRING
Sales date (YYYY-MM-DD)
product
STRING
Product name.
region
STRING
Sales region: North / South / East / West
quantity
INT
Sales quantity
revenue
DOUBLE
Sales amount
Tip
To avoid table name conflicts when multiple users run this tutorial at the same time, replace <your_name> with your own name prefix, such as alice_database or alice_sales_data.

Step 1: Entering SQL Analysis

SQL Analytics is the unified entry point for data analysts to perform ad hoc queries, visualization, and result export.
1. Log in to the DataBuddy console and select the workspace you want to enter.
2. Select Data Exploration in the left sidebar.
3. Click New SQL in the upper-left corner. Enter a file name, for example, quickstart_sales.sql. Select a parent folder, click OK, and then enter the SQL editor.
4. In the upper-right corner of the editor:
Compute Resource: Select Interactive Analysis Cluster from the drop-down list.
Default Catalog: Select DataLakeCatalog. After this setting, you can omit the Catalog prefix in SQL statements.

Step 2: Creating a Database and Sample Tables

Write and run the following SQL statements in the editor in sequence. To run a selected snippet, press ⌘ + Enter. Windows users can press Ctrl + Enter.
-- Create a database. Replace your_name with your own name prefix.
CREATE DATABASE IF NOT EXISTS DataLakeCatalog.your_name_database;
-- Create a table.
CREATE TABLE IF NOT EXISTS DataLakeCatalog.your_name_database.sales_data (
date STRING,
product STRING,
region STRING,
quantity INT,
revenue DOUBLE
);
-- Write 15 rows of sample data.
INSERT INTO DataLakeCatalog.your_name_database.sales_data VALUES
('2025-01-01', 'Widget A', 'North', 239, 6915.68),
('2025-01-01', 'Widget B', 'South', 185, 12430.50),
('2025-01-01', 'Widget C', 'East', 327, 28025.76),
('2025-01-01', 'Widget D', 'North', 340, 8986.75),
('2025-01-01', 'Widget E', 'East', 421, 25079.72),
('2025-01-02', 'Widget A', 'West', 150, 4350.00),
('2025-01-02', 'Widget B', 'North', 275, 18562.50),
('2025-01-02', 'Widget C', 'South', 310, 26556.00),
('2025-01-02', 'Widget D', 'East', 198, 5237.10),
('2025-01-02', 'Widget E', 'West', 460, 27416.00),
('2025-01-03', 'Widget A', 'East', 305, 8845.00),
('2025-01-03', 'Widget B', 'West', 220, 14850.00),
('2025-01-03', 'Widget C', 'North', 290, 24824.00),
('2025-01-03', 'Widget D', 'South', 175, 4627.50),
('2025-01-03', 'Widget E', 'North', 388, 23124.80);
-- Verification: 15 rows should be returned.
SELECT COUNT(*) AS total_rows FROM DataLakeCatalog.your_name_database.sales_data;
Note:
Database creation and data writes require the CREATE and INSERT permissions on the Catalog. If a permission error occurs, contact the workspace administrator or see Structured Data_Catalog.

Step 3: Performing the First Ad Hoc Query

Next, use a set of typical analysis statements to familiarize yourself with the editor, the results area, and the logs.

3.1 Basic Data Profiling

DESCRIBE DataLakeCatalog.your_name_database.sales_data;
SELECT * FROM DataLakeCatalog.your_name_database.sales_data LIMIT 10;
After execution, the editor displays the run information in three tabs below:
Tab
Content.
Result
Query result table that supports sorting, field display, search, filtering, copying, downloading, and visualization.
Logs
Spark execution logs and error stacks.
Code
Query statement of the current run.

3.2 Aggregating by Region (Running Multiple Statements at Once)

Paste the following SQL statements in full, and then click Run All in the toolbar.
-- Regional sales overview (used as the dataset for dashboard KPIs and bar charts)
SELECT
region,
SUM(quantity) AS total_quantity,
SUM(revenue) AS total_revenue,
ROUND(AVG(revenue / quantity), 2) AS avg_unit_price
FROM DataLakeCatalog.your_name_database.sales_data
GROUP BY region
ORDER BY total_revenue DESC;
When multiple statements are run, each SQL statement generates a separate result Tab for easy switching and viewing.
Tip
Is your SQL not formatted neatly? Click Format in the toolbar (or press ⌘ + ⇧ + F) to automatically standardize indentation, line breaks, and keyword capitalization. For more information, see SQL IDE Basics.

3.3 Time Trends

-- Daily sales trend (used as the dataset for dashboard line charts)
SELECT
date,
SUM(revenue) AS daily_revenue,
SUM(quantity) AS daily_quantity
FROM DataLakeCatalog.your_name_database.sales_data
GROUP BY date
ORDER BY date;

3.4 Window Ranking

-- Product sales ranking by region (used as the dataset for the dashboard table component)
SELECT
region,
product,
SUM(revenue) AS product_revenue,
RANK() OVER (PARTITION BY region ORDER BY SUM(revenue) DESC) AS revenue_rank
FROM DataLakeCatalog.your_name_database.sales_data
GROUP BY region, product
ORDER BY region, revenue_rank;

3.5 Parameterized Reuse

Convert the SQL with hard-coded dates into a reusable parameterized query:
-- Parameterization: filter by region and time window
SELECT
region,
product,
SUM(revenue) AS total_revenue
FROM DataLakeCatalog.your_name_database.sales_data
WHERE region = '${target_region}'
AND date BETWEEN '${start_date}' AND '${end_date}'
GROUP BY region, product
ORDER BY total_revenue DESC;
Click the Parameter icon in the SQL editor toolbar. In the dialog that appears, the parameter names in the code are automatically detected. Enter the parameter values target_region=North, start_date=2025-01-01, and end_date=2025-01-31, and then click OK.
Tip
For details about parameterization syntax, runtime value resolution rules, and priority relationships with workflow parameters, see Parameter Configuration and Parameter Usage.

3.6 Saving and Favoriting

Click Save in the toolbar (or press ⌘ + S) to create a manual version (up to 200 are retained) for easy rollback. Click Favorite to add the current query to your personal favorites, allowing you to load it with one click the next time you open the SQL Analytics homepage.

Step 4: Converting Query Results into Charts with One Click

The queries in sections 3.2 and 3.3 are suitable for visualization and can be completed without switching to the dashboard.
1. Switch to the result Tab of 3.2 Aggregate by Region.
2. In the result area, click the Create Chart icon to go to the chart panel.
3. At the top of the chart panel, select Bar Chart.
4. Drag fields in the configuration panel on the right:
X-axis, Category: region.
Y-axis, Measure: total_revenue. For the aggregation method, select No Aggregation because the SQL query is already aggregated.
Click the OK icon in the lower-right corner. After you save the chart, its configuration is retained with the current SQL file and automatically restored the next time you open the file.
Switch to the result Tab of 3.3 Time Trend and repeat the previous steps. Select Line Chart, set the X-axis to date and the Y-axis to daily_revenue.

Step 5: Exporting Query Results (Optional)

To deliver data to offline reports or external collaborators:
1. At the top of the result Tab, click Download.
2. The download scope is divided into preview data and all data.
3. Select the export format:
CSV: UTF-8 encoded, offering the best cross-platform compatibility.
Excel (.xlsx): Retains column types and display formats for easy editing.
TXT: Tab-separated.
1. Click Download. The file is named according to <SQL file name>_<query ID>_<time>.<ext> and then downloaded to your local machine.
Tip
The number of rows per download and the file size are limited by platform specifications, and the data volume cannot exceed 500 MB. For full data delivery, use the "Write to Target Table, Offline Sync Export" solution instead.

Step 6: Saving Query Results as Dashboard Examples

Before you start configuring the dashboard, make sure you have completed the following preparations:
You have successfully completed the preceding steps in SQL. The current account has permissions to create dashboards and access relevant data tables. Compute resources are available. The field names, dataset names, and table names in the examples are for illustration only. During actual configuration, use the data table structure in the current workspace as the standard.

6.1 Creating a Dashboard

1. Choose Data Analysis > Dashboards in the left sidebar.
2. Click Create Dashboard in the upper-right corner of the dashboard list page to enter edit mode.
3. Click the top title and name the dashboard Sales Performance Daily Report - <your_name>.
4. In the Compute Resources dropdown at the top of the canvas, select an appropriate available resource group and wait until its status changes to Available.

6.2 Adding a Dataset

Click Data in the top navigation bar to go to the data configuration page. In the left panel, click the Create from SQL icon, paste the SQL from 3.2 Aggregate by Region (keeping only one SELECT), and click Run. After confirming that results are returned, click More and rename the dataset to ds_region_summary.
Create the following items in sequence using the same method:
Data set name
Source SQL
ds_region_summary
3.2 Aggregate by region
ds_daily_trend
3.3 Daily sales trend
ds_product_rank
3.4 Window ranking
ds_detail
SELECT * FROM DataLakeCatalog.your_name_database.sales_data

6.3 Adding Chart Components

Return to the canvas. In the persistent toolbar at the bottom of the canvas, click Chart and add the following four components in sequence. For each component, configure the dataset, dimensions, metrics, and title in the right panel.

Component 1: KPI Card (Total Revenue)

Chart Type: Metric Card.
Dataset: ds_region_summary.
Metric: total_revenue. For the calculation method, select Sum.
Display Name: Total Revenue. For the type in the style settings, select Custom - Currency.

Component 2: Regional Revenue Bar Chart

Chart Type: Bar Chart.
Dataset: ds_region_summary.
X-axis: region.
Y-axis: total_revenue. For the calculation method, select No Aggregation because the SQL query is already aggregated.
Title: Sales Revenue by Region.

Component 3: Daily Trend Line Chart

Chart Type: Line Chart.
Dataset: ds_daily_trend.
X-axis: date.
Y-axis: daily_revenue. You can also add daily_quantity as a secondary Y-axis.
Title: Daily Sales Trend.

Component 4: Product Ranking Table

Chart Type: Table.
Dataset: ds_product_rank.
Fields: region, product, product_revenue, revenue_rank.
Title: TOP Products by Region.

6.4 Adjusting the Layout

Move the pointer to the edge of a component to drag and resize it.
All dashboard changes are automatically saved as drafts, so you do not need to click Save manually.

6.5 Adding Filters (Enabling Region-Based Switching on the Dashboard)

1. In the toolbar below the canvas, click Page Filter.
2. Filter Field: Select ds_region_summary.region.
3. Filter: Select multiple values from the drop-down list.
4. Default Value: Select the regions to display. After saving, a Region selector appears at the top of the canvas.

Step 7: Publishing the Dashboard

7.1 Publishing the Dashboard

1. Click Publish in the upper-right corner of the dashboard edit mode.
2. In the publish dialog, you can select:
Share the publisher's data permissions.
Follow the viewer's own data permissions.
1. Click Publish. A toast message appears in the upper-right corner indicating success. You can click to switch to the Published state to preview the viewer perspective.

7.2 Copying the Share Link (Optional)

Click Share > Copy Link at the top of the published dashboard to share the link directly. Visitors who have logged in to the workspace and have the required permissions can view the published dashboard.

Verification Result

After completing all steps, you should confirm:
1. The SQL file quickstart_sales.sql is visible in SQL analysis, and at least one manual version has been saved.
2. The sample table DataLakeCatalog.<your_name>_database.sales_data contains 15 rows of data, and all four types of aggregate SQL can run successfully and produce results.
3. The visualizations have been saved with the SQL file: 3.2 Aggregation by Region → Bar Chart; 3.3 Daily Trend → Line Chart.
4. The dashboard Sales Performance Daily Report - <your_name> is visible in the dashboard list, and its status is Published.

Summary

In this tutorial, you have completed:
Create a database and sample tables in SQL analysis, and use five typical SQL statements to perform basic exploration, aggregation, trend analysis, window ranking, and parameterized reuse.
Use the chart panel to convert SQL results into bar charts and line charts with one click, and retain the configuration with the SQL file.
Consolidate multiple queries into datasets and chart components, and combine them into a complete sales daily report dashboard.
Configure filters to adapt a single dashboard to multiple regional perspectives.
Complete the publishing of the dashboard.
This workflow covers more than 80% of the high-frequency operations that data analysts perform daily in DataBuddy. You can continue to explore advanced capabilities such as building datasets directly from Catalog tables, metric models, and local files, as well as cross-page global filters.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック