Skip to content

Commit 0b98e04

Browse files
authored
Merge 2def653 into d3517ab
2 parents d3517ab + 2def653 commit 0b98e04

3 files changed

Lines changed: 281 additions & 0 deletions

File tree

  • 0_Azure/2_AzureAnalytics/1_SynapseAnalytics/demos/2_synapse_views_dynamically_remove_space
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Serverless SQL Pool: Dynamically Remove Space
2+
3+
Costa Rica
4+
5+
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com)
6+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
7+
[brown9804](https://github.com/brown9804)
8+
9+
Last updated: 2025-01-24
10+
11+
----------
12+
13+
## Wiki
14+
15+
<details>
16+
<summary><b>List of References </b> (Click to expand)</summary>
17+
18+
19+
</details>
20+
21+
## Content
22+
23+
<details>
24+
<summary><b>Table of Content </b> (Click to expand)</summary>
25+
26+
27+
</details>
28+
29+
30+
<div align="center">
31+
<h3 style="color: #4CAF50;">Total Visitors</h3>
32+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
33+
</div>
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Dedicated SQL Pool: Store Procedure Dynamically Remove Space
2+
3+
Costa Rica
4+
5+
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com)
6+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
7+
[brown9804](https://github.com/brown9804)
8+
9+
Last updated: 2025-01-24
10+
11+
----------
12+
13+
## Wiki
14+
15+
<details>
16+
<summary><b>List of References </b> (Click to expand)</summary>
17+
18+
19+
</details>
20+
21+
## Content
22+
23+
<details>
24+
<summary><b>Table of Content </b> (Click to expand)</summary>
25+
26+
27+
</details>
28+
29+
## Demo
30+
31+
### Set Up a Dedicated SQL Pool
32+
33+
1. **Sign in to the Azure Portal**: Go to the Azure Portal and sign in with your Azure account.
34+
2. **Navigate to Your Synapse Workspace**: In the Azure Portal, search for your Synapse workspace or create a new one if you don't have one.
35+
36+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/92a5e451-1868-47e2-b32b-858591c306ee" />
37+
38+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/51e3b091-855d-4481-89e0-623705e3cf2a" />
39+
40+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/7d03bfa8-e1e3-4706-970f-a89c7b8cd904" />
41+
42+
### Create a Dedicated SQL Pool
43+
44+
1. **Launch Synapse Studio**: From the Synapse workspace overview, click on the `Open Synapse Studio` button.
45+
46+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/302b1fd8-49a6-427e-93dc-8e952f1667e6" />
47+
48+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/a368036b-c859-47fc-a1c5-d045b6910790" />
49+
50+
2. **Create a Dedicated SQL Pool**:
51+
- In Synapse Studio, go to the `Manage` hub by clicking on the `Manage` icon in the left navigation pane.
52+
- Under `Analytics pools`, select `SQL pools` and click on the `+ New` button.
53+
54+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/6d96ac07-57f1-4efd-917b-200a43091311" />
55+
56+
- Enter the following details:
57+
- **SQL pool name**: Enter a name for your SQL pool (e.g., `SQLPOOL1`).
58+
- **Performance level**: Choose a performance level (e.g., `DW1000c`).
59+
- Click `Review + create` and then `Create` to provision the dedicated SQL pool.
60+
61+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/89ca427b-20f1-4df5-ae20-847b76cdd9a7" />
62+
63+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/b8b2c94b-76e6-4ced-8812-c386c6a55f32" />
64+
65+
### Create Tables with Spaces in Names and Columns
66+
67+
1. **Open the SQL Script Editor**:
68+
- In Synapse Studio, go to the `Develop hub` by clicking on the `Develop` icon in the left navigation pane.
69+
- Click on `+ New SQL script` to open the SQL script editor.
70+
71+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/3382ea4a-06eb-4e32-93d9-569cef7fc2f5" />
72+
73+
2. **Create Sample Tables**: Use the following script to create tables with spaces in their names and columns. Click [here to see the .sql file]().
74+
75+
```sql
76+
-- Create sample tables with spaces in names
77+
CREATE TABLE [Employee Records] (
78+
[Employee ID] INT,
79+
[Employee Name] NVARCHAR(255),
80+
[Employee Address] NVARCHAR(255)
81+
);
82+
83+
CREATE TABLE [Sales Data] (
84+
[Sale ID] INT,
85+
[Sale Date] DATE,
86+
[Employee ID] INT,
87+
[Sale Amount] DECIMAL(10, 2)
88+
);
89+
90+
CREATE TABLE [Inventory Details] (
91+
[Item ID] INT,
92+
[Item Name] NVARCHAR(255),
93+
[Item Category] NVARCHAR(255),
94+
[Item Price] DECIMAL(10, 2)
95+
);
96+
97+
-- Insert sample data into the tables
98+
INSERT INTO [Employee Records] ([Employee ID], [Employee Name], [Employee Address])
99+
VALUES (1, 'Alice Johnson', '789 Pine St');
100+
101+
INSERT INTO [Employee Records] ([Employee ID], [Employee Name], [Employee Address])
102+
VALUES (2, 'Bob Brown', '101 Maple St');
103+
104+
INSERT INTO [Sales Data] ([Sale ID], [Sale Date], [Employee ID], [Sale Amount])
105+
VALUES (1, '2023-02-01', 1, 200.00);
106+
107+
INSERT INTO [Sales Data] ([Sale ID], [Sale Date], [Employee ID], [Sale Amount])
108+
VALUES (2, '2023-02-02', 2, 250.00);
109+
110+
INSERT INTO [Inventory Details] ([Item ID], [Item Name], [Item Category], [Item Price])
111+
VALUES (1, 'Gadget', 'Electronics', 49.99);
112+
113+
INSERT INTO [Inventory Details] ([Item ID], [Item Name], [Item Category], [Item Price])
114+
VALUES (2, 'Tool', 'Hardware', 29.99);
115+
```
116+
117+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/6f8a154d-2fcb-4aa5-bc9f-27f6b8334017" />
118+
119+
3. **Run the Script**: Execute the script in the SQL script editor to create the tables and insert sample data.
120+
121+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/1d02fd74-7246-4aa6-8247-b98619d70c47" />
122+
123+
> [!NOTE]
124+
> Once you refresh, the tables will be visible:
125+
126+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/3e6fc8a1-ad34-4a0b-8940-ae27b303190d">
127+
128+
### Create Views with Modified Tables/Column Names
129+
130+
1. **Create a Stored Procedure to Remove Spaces from Column Names**: Use the following script to create a stored procedure that removes spaces from column names and creates views. Click [here to see the .sql file]().
131+
132+
```sql
133+
134+
```
135+
136+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/13b3b5f2-3142-448f-b03a-3eeae00a1509" />
137+
138+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/575905c1-bcf7-4800-981b-6ff4ab2b3302" />
139+
140+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/a7244b21-c787-4f64-8689-fe66670aa86a" />
141+
142+
2. **Execute the Stored Procedure**: Click on `Run`, to create the stored procedure.
143+
144+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/17be4e92-9816-43ff-9cc3-23d9737a9056" />
145+
146+
| Before | After |
147+
| --- | --- |
148+
| <img width="550" alt="image" src="https://github.com/user-attachments/assets/d081329c-b5f6-452f-826b-50a2dd614a1c" /> | <img width="550" alt="image" src="https://github.com/user-attachments/assets/588aa482-ac5c-4013-b926-e01db58d1733" /> |
149+
150+
3. Run the stored procedure to create views with modified column names.
151+
152+
```sql
153+
EXEC RemoveSpacesFromColumnNames
154+
```
155+
156+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/015b9c07-10f6-4895-bdba-4945e3277923" />
157+
158+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/1ccf430e-1dff-4968-980c-a4f3913a8369" />
159+
160+
> [!NOTE]
161+
> Once you refresh, the views will be visible:
162+
163+
| Before | After |
164+
| --- | --- |
165+
<img width="360" alt="image" src="https://github.com/user-attachments/assets/b0de5118-bf67-4f75-9dd7-2ae5ba33cb28" />
166+
167+
168+
169+
170+
171+
172+
<div align="center">
173+
<h3 style="color: #4CAF50;">Total Visitors</h3>
174+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
175+
</div>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Azure Synapse: Dynamically Remove Space - Overview
2+
3+
Costa Rica
4+
5+
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com)
6+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
7+
[brown9804](https://github.com/brown9804)
8+
9+
Last updated: 2025-01-24
10+
11+
----------
12+
13+
> [!NOTE]
14+
> Both the `table name and column name fields will be reviewed`. We'll remove any blank spaces to create the view.
15+
16+
## Wiki
17+
18+
<details>
19+
<summary><b>List of References </b> (Click to expand)</summary>
20+
21+
- [What is Azure Synapse Analytics?](https://learn.microsoft.com/en-us/azure/synapse-analytics/overview-what-is)
22+
- [What is dedicated SQL pool (formerly SQL DW) in Azure Synapse Analytics?](https://learn.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-overview-what-is)
23+
- [Serverless SQL pool in Azure Synapse Analytics](https://learn.microsoft.com/en-us/azure/synapse-analytics/sql/on-demand-workspace-overview)
24+
- [Create and use views using serverless SQL pool in Azure Synapse Analytics](https://learn.microsoft.com/en-us/azure/synapse-analytics/sql/create-use-views)
25+
26+
</details>
27+
28+
## Content
29+
30+
<details>
31+
<summary><b>Table of Content </b> (Click to expand)</summary>
32+
33+
- [Wiki](#wiki)
34+
- [Content](#content)
35+
- [Overview](#overview)
36+
- [SQL Pools](#sql-pools)
37+
- [Synapse Views](#synapse-views)
38+
- [How to Dynamically Remove Space in field name](#how-to-dynamically-remove-space-in-field-name)
39+
40+
</details>
41+
42+
## Overview
43+
44+
> `Azure Synapse Analytics` is an integrated analytics service that accelerates time to insight across data warehouses and big data systems.
45+
> It combines the `best of SQL technologies used in enterprise data warehousing`, Spark technologies for big data, and data integration
46+
> capabilities to provide a unified experience for data professionals
47+
48+
<img width="550" alt="image" src="https://github.com/user-attachments/assets/9a753e36-e229-4da7-8a87-a5c21ddd70f9"> <br/>
49+
From [Microsoft Official Documentation](https://learn.microsoft.com/en-us/azure/synapse-analytics/overview-what-is)
50+
51+
### SQL Pools
52+
53+
SQL pools in Azure Synapse Analytics come in two main types:
54+
55+
| Type | Description | Characteristics |
56+
| --- | --- | --- |
57+
| Serverless SQL Pool (built in) | This is a built-in, on-demand query service in Azure Synapse Analytics. You don't need to provision or manage any infrastructure. You simply run your queries, and you're billed based on the amount of data processed. It's great for ad-hoc querying and exploring data in your data lake without worrying about the underlying infrastructure. | - A query service over data in your data lake. <br/> - No infrastructure setup or clusters to maintain. <br/> - Pay-per-use model, charging only for the data processed by queries. <br/> - Suitable for ad-hoc querying and data exploration. |
58+
| Dedicated SQL Pool (formerly SQL DW) | This requires you to provision and manage a set of resources (Data Warehousing Units or DWUs). You have control over the performance and scale of your data warehouse, but it also means you need to manage the infrastructure. It's ideal for large-scale, high-performance analytics and data warehousing. | - A collection of analytic resources provisioned when using Synapse SQL. <br/> - Uses Data Warehousing Units (DWU) to determine size and performance. <br/> - Ideal for large-scale data warehousing and high-performance analytics. |
59+
60+
### Synapse Views
61+
62+
> **Synapse views** are `virtual tables created by querying data from one or more tables in Azure Synapse Analytics.
63+
> They don't store data themselves but provide a way to simplify complex queries and reuse them`. Views can be created over both dedicated and serverless SQL pools.
64+
65+
## How to Dynamically Remove Space in field name
66+
67+
- For an overview of Serverless SQL Pool (built-in), please read this overview.
68+
- For information on Dedicated SQL Pool (formerly SQL DW), click here.
69+
70+
<div align="center">
71+
<h3 style="color: #4CAF50;">Total Visitors</h3>
72+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
73+
</div>

0 commit comments

Comments
 (0)