Skip to content

Commit cc0e8d7

Browse files
committed
Initial commit
0 parents  commit cc0e8d7

File tree

4 files changed

+133
-0
lines changed

4 files changed

+133
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update Azure Synapse Serverless SQL Pool
2+
3+
# Sample of how to deploy to an Azure Synapse Serverless SQL Pool using GitHub Actions
4+
# You can use a self-hosted runner installed locally for this to work
5+
# You can also use a GitHub-hosted runner
6+
7+
# For this pipeline you also need to setup the below encrypted secrets (https://bit.ly/3nd0Jj8)
8+
# sqlinstance - Your Serverless SQL Pool endpoint
9+
#(the one that ends with -ondemand)
10+
# database - The database in the SQL Pool you want the update deployed to
11+
# Note it has to exist BEFORE this the scripts are run
12+
# UserName - User name to connect to the Serverless SQL Pool endpoint
13+
# try and keep this secret
14+
# Pw - Password of above user, definitely keep this one secret
15+
16+
#Sets the trigger to update when update is pushed to main branch
17+
on:
18+
push:
19+
branches:
20+
- main
21+
22+
jobs:
23+
24+
# Job to install the scripts
25+
ServerlessPool1:
26+
# Easier to use Github-hosted runner if updating in GitHub
27+
runs-on: windows-latest
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
# Note that I am using latest version of action
33+
- uses: actions/checkout@v2.4.0
34+
35+
# install dbops PowerShell module
36+
- name: Install dbops module
37+
run: 'Install-Module -Name dbops -Force -PassThru'
38+
39+
# Run migration-based scripts
40+
- name: Run migration-based scripts
41+
run: |
42+
$SecurePw=ConvertTo-SecureString ${{ secrets.Pw }} –asplaintext –force
43+
Install-DBOScript -ScriptPath scripts -sqlinstance ${{ secrets.sqlinstance }} -Database ${{ secrets.database }} -UserName ${{ secrets.UserName }} -Password $SecurePw -SchemaVersionTable $null

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Azure Synapse Serverless SQL Pool Database Project using GitHub Actions
2+
3+
Example of a Migration-Based deployment that deploys to an Azure Synapse serverless SQL Pool using GitHub Actions.
4+
5+
It uses a yaml pipeline, which is in the '/.github/workflows' folder.
6+
7+
In order to use it in GitHub Actions you can either import or fork this repository into another GitHub repository.
8+
9+
Afterwards, you can select the yaml file in the GitHub repository and tailor the pipeline to suit your needs. Or, you can clone your repository locally and change the pure yaml file there.
10+
11+
Please note that the databases have to exist in the serverless SQL Pools for this to work. In addition, you might want to create a file in Azure Data Lake storage that contains the heading used for the SchemaVersions table (https://dbup.readthedocs.io/en/latest/more-info/journaling/). From there, you can try using it as the SchemaVersions table in the code.
12+
13+
This repository is provided "as is" based on the MIT license (https://opensource.org/licenses/MIT). Basically, I am not responsible for your use of it.

scripts/Script0001 - Create table.sql

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
IF NOT EXISTS (SELECT * FROM sys.external_file_formats WHERE name = 'SynapseParquetFormat')
2+
CREATE EXTERNAL FILE FORMAT [SynapseParquetFormat]
3+
WITH ( FORMAT_TYPE = PARQUET)
4+
GO
5+
6+
IF NOT EXISTS (SELECT * FROM sys.external_data_sources WHERE name = 'nyctlc_azureopendatastorage_blob_core_windows_net')
7+
CREATE EXTERNAL DATA SOURCE [nyctlc_azureopendatastorage_blob_core_windows_net]
8+
WITH (
9+
LOCATION = 'https://azureopendatastorage.blob.core.windows.net/nyctlc',
10+
)
11+
Go
12+
13+
IF NOT EXISTS (SELECT * FROM sys.external_tables WHERE name = 'nyc_tlc_yellow_trip_ext')
14+
CREATE EXTERNAL TABLE nyc_tlc_yellow_trip_ext (
15+
[vendorID] varchar(8000),
16+
[tpepPickupDateTime] datetime2(7),
17+
[tpepDropoffDateTime] datetime2(7),
18+
[passengerCount] int,
19+
[tripDistance] float,
20+
[puLocationId] varchar(8000),
21+
[doLocationId] varchar(8000),
22+
[startLon] float,
23+
[startLat] float,
24+
[endLon] float,
25+
[endLat] float,
26+
[rateCodeId] int,
27+
[storeAndFwdFlag] varchar(8000),
28+
[paymentType] varchar(8000),
29+
[fareAmount] float,
30+
[extra] float,
31+
[mtaTax] float,
32+
[improvementSurcharge] varchar(8000),
33+
[tipAmount] float,
34+
[tollsAmount] float,
35+
[totalAmount] float
36+
)
37+
WITH (
38+
LOCATION = 'yellow/puYear=2014/puMonth=3/*.parquet',
39+
-- LOCATION = 'yellow/puYear=*/puMonth=*/*.parquet'
40+
DATA_SOURCE = [nyctlc_azureopendatastorage_blob_core_windows_net],
41+
FILE_FORMAT = [SynapseParquetFormat]
42+
)
43+
GO

scripts/Script0002 - Alter table.sql

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
IF EXISTS (SELECT * FROM sys.external_tables WHERE name = 'nyc_tlc_yellow_trip_ext')
2+
DROP EXTERNAL TABLE nyc_tlc_yellow_trip_ext
3+
GO
4+
5+
CREATE EXTERNAL TABLE nyc_tlc_yellow_trip_ext (
6+
[vendorID] varchar(8000),
7+
[tpepPickupDateTime] datetime2(7),
8+
[tpepDropoffDateTime] datetime2(7),
9+
[passengerCount] int,
10+
[tripDistance] float,
11+
[puLocationId] varchar(8000),
12+
[doLocationId] varchar(8000),
13+
[startLon] float,
14+
[startLat] float,
15+
[endLon] float,
16+
[endLat] float,
17+
[rateCodeId] int,
18+
[storeAndFwdFlag] varchar(8000),
19+
[paymentType] varchar(8000),
20+
[fareAmount] float,
21+
[extra] float,
22+
[mtaTax] float,
23+
[improvementSurcharge] varchar(8000),
24+
[tipAmount] float,
25+
[tollsAmount] float,
26+
[totalAmount] float
27+
)
28+
WITH (
29+
LOCATION = 'yellow/puYear=2014/puMonth=3/*.parquet',
30+
-- LOCATION = 'yellow/puYear=*/puMonth=*/*.parquet'
31+
DATA_SOURCE = [nyctlc_azureopendatastorage_blob_core_windows_net],
32+
FILE_FORMAT = [SynapseParquetFormat]
33+
)
34+
GO

0 commit comments

Comments
 (0)