From a1eb7d0f1e6c4777756ff11c4fdc6d7b10e19ab8 Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Mon, 24 Jun 2024 13:16:00 -0700 Subject: [PATCH 1/8] Configure Snowflake authentication in upload-and-deploy workflow --- .github/workflows/upload-and-deploy.yaml | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/.github/workflows/upload-and-deploy.yaml b/.github/workflows/upload-and-deploy.yaml index 8749870..e816245 100755 --- a/.github/workflows/upload-and-deploy.yaml +++ b/.github/workflows/upload-and-deploy.yaml @@ -26,6 +26,56 @@ jobs: - uses: actions/setup-python@v4 - uses: pre-commit/action@v3.0.0 + deploy-snowflake: + name: Deploy Snowflake resources + needs: pre-commit + runs-on: ubuntu-latest + env: + PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }} + steps: + - uses: actions/checkout@v3 + + - name: Configure Snowflake connection + run: | + # Create temporary files for config.toml and our private key + #mkdir ~/.snowflake + #config_file="~/.snowflake/config.toml" + config_file=$(mktemp) + private_key_file=$(mktemp) + + # Write to the private key file + echo "${{ secrets.SNOWFLAKE_PRIVATE_KEY }}" > $private_key_file + + # Write to config.toml file + echo 'default_connection_name = "recover"' >> $config_file + echo '[connections.recover]' >> $config_file + echo "account = \"${{ vars.SNOWFLAKE_ACCOUNT }}\"" >> $config_file + echo "user = \"${{ vars.SNOWFLAKE_USER }}\"" >> $config_file + echo "role = \"${{ vars.SNOWFLAKE_ROLE }}\"" >> $config_file + echo 'authenticator = "SNOWFLAKE_JWT"' >> $config_file + echo "private_key_path = \"$private_key_file\"" >> $config_file + + # check config file + cat $config_file + + # Write config.toml path to global environment + echo "SNOWFLAKE_CONFIG_PATH=$config_file" >> $GITHUB_ENV + + - name: check config + run: | + echo $SNOWFLAKE_CONFIG_PATH + cat $SNOWFLAKE_CONFIG_PATH + + - name: Install Snowflake CLI + uses: Snowflake-Labs/snowflake-cli-action@v1 + with: + default-config-file-path: ${{ env.SNOWFLAKE_CONFIG_PATH }} + + - name: test connection + run: | + snow --version + snow connection test + upload-files: name: Upload files to S3 bucket in development runs-on: ubuntu-latest From 8510876ed3a42508f79b5e34ac4bd8f8eeadf2f5 Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Wed, 26 Jun 2024 10:21:29 -0700 Subject: [PATCH 2/8] Add Snowflake table definition for enrolled_participants data type --- .../parquet/tables/enrolled_participants.sql | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql new file mode 100644 index 0000000..e4176bf --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql @@ -0,0 +1,91 @@ +create or alter TABLE enrolled_participants_empty ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "GlobalKey" VARCHAR(16777216), + "CustomFields_Treatments_id" VARCHAR(16777216), + "EmailAddress" VARCHAR(16777216), + "CustomFields_Symptoms_id" VARCHAR(16777216), + "name" VARCHAR(16777216), + "DateOfBirth" VARCHAR(16777216), + "EnrollmentDate" VARCHAR(16777216), + "color" VARCHAR(16777216), + "EventDates_AppDownloadDate" VARCHAR(16777216), + "severityTracking" VARCHAR(16777216), + "inactive" BOOLEAN, + "EventDates_DevicesConnectedDate" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "EventDates_EhrConnectedDate" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "EventDates_SymptomLogSetupDate" VARCHAR(16777216), + "EventDates_JoinNurtureCampaignStart" VARCHAR(16777216), + "EventDates_InfectionFirstReportedDate" VARCHAR(16777216), + "EventDates_JoinNurtureCampaign2Start" VARCHAR(16777216), + "EventDates_LastFitbitTrackerStepsDate" VARCHAR(16777216), + "EventDates_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), + "EventDates_EhrNurtureCampaignStart" VARCHAR(16777216), + "EventDates_ConnectFitbitNurtureStart" VARCHAR(16777216), + "EventDates_EhrCampaignStart" VARCHAR(16777216), + "EventDates_EhrNurtureCampaign2Start" VARCHAR(16777216), + "CustomFields_AppDownloadDate" VARCHAR(16777216), + "CustomFields_AppleHealthEnabled" VARCHAR(16777216), + "CustomFields_DateOfBirthVerified" VARCHAR(16777216), + "CustomFields_DevicesConnectedDate" VARCHAR(16777216), + "CustomFields_InfectionsReported" VARCHAR(16777216), + "CustomFields_ProjectCode" VARCHAR(16777216), + "CustomFields_Site" VARCHAR(16777216), + "CustomFields_EhrConnectedDate" VARCHAR(16777216), + "CustomFields_Reminder1Enabled" VARCHAR(16777216), + "CustomFields_Reminder2Enabled" VARCHAR(16777216), + "CustomFields_ReminderTime1" VARCHAR(16777216), + "CustomFields_ReminderTime2" VARCHAR(16777216), + "CustomFields_SymptomLogSetupDate" VARCHAR(16777216), + "CustomFields_Symptoms" NUMBER(38,0), + "CustomFields_Treatments" NUMBER(38,0), + "CustomFields_Under18" VARCHAR(16777216), + "CustomFields_HasOutstandingSurveys" VARCHAR(16777216), + "CustomFields_SelfEnrolled" VARCHAR(16777216), + "CustomFields_DeviceOrderDate" VARCHAR(16777216), + "CustomFields_DeviceOrderInfo" VARCHAR(16777216), + "CustomFields_DeviceOrderStatus" VARCHAR(16777216), + "CustomFields_AppleHealthRecordsEnabled" VARCHAR(16777216), + "CustomFields_DeviceOrderCompleteDate" VARCHAR(16777216), + "CustomFields_DeviceOrderConfirmationNumber" VARCHAR(16777216), + "CustomFields_HasSmartphone" VARCHAR(16777216), + "CustomFields_JoinNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_AppleHealthRecordsReceived" VARCHAR(16777216), + "CustomFields_EOPDate" VARCHAR(16777216), + "CustomFields_EOPReason" VARCHAR(16777216), + "CustomFields_EOPRemoveData" VARCHAR(16777216), + "CustomFields_GoogleFitEnabled" VARCHAR(16777216), + "CustomFields_InfectionFirstReportedDate" VARCHAR(16777216), + "CustomFields_JoinNurtureCampaign2Start" VARCHAR(16777216), + "CustomFields_AppDownloaded" VARCHAR(16777216), + "CustomFields_DeviceEligible" VARCHAR(16777216), + "CustomFields_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_DevicesConnected" VARCHAR(16777216), + "CustomFields_EhrConnected" VARCHAR(16777216), + "CustomFields_EhrNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_LastFitbitTrackerStepsDate" VARCHAR(16777216), + "CustomFields_ConnectFitbitNurtureStart" VARCHAR(16777216), + "CustomFields_ForceSendInvitation" VARCHAR(16777216), + "CustomFields_ForceSync" VARCHAR(16777216), + "CustomFields_JoinNurtureGroup" VARCHAR(16777216), + "CustomFields_EhrCampaignStart" VARCHAR(16777216), + "CustomFields_PendingUndersleepTrigger" VARCHAR(16777216), + "CustomFields_PendingWASOTrigger" VARCHAR(16777216), + "CustomFields_PendingOversleepTrigger" VARCHAR(16777216), + "CustomFields_EhrNurtureCampaign2Start" VARCHAR(16777216), + "UtcOffset" VARCHAR(16777216), + "TimeZone" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "MobilePhone" VARCHAR(16777216), + "UnsubscribedFromEmails" VARCHAR(16777216), + "UnsubscribedFromSMS" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "FirstName" VARCHAR(16777216), + "LastName" VARCHAR(16777216), + "Gender" VARCHAR(16777216), + "PostalCode" VARCHAR(16777216), + "MiddleName" VARCHAR(16777216), + "PreferredLanguage" VARCHAR(16777216) +); From ea9dd27564fc5043dbf2232fee906ac637198b83 Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Wed, 26 Jun 2024 13:44:34 -0700 Subject: [PATCH 3/8] Add SQL deployment scripts for Snowflake object hierarchy --- snowflake/objects/databases/deploy.sql | 17 +++ .../objects/databases/recover/deploy.sql | 12 ++ .../databases/recover/schemas/deploy.sql | 8 ++ .../recover/schemas/parquet/deploy.sql | 22 ++++ .../schemas/parquet/file_format/deploy.sql | 8 ++ .../parquet/file_format/parquet_format.sql | 7 ++ .../recover/schemas/parquet/stages/deploy.sql | 9 ++ .../schemas/parquet/stages/parquet_s3.sql | 6 + .../recover/schemas/parquet/tables/deploy.sql | 54 +++++++++ ...icipants_customfields_symptoms_parquet.sql | 11 ++ ...ipants_customfields_treatments_parquet.sql | 10 ++ ...s.sql => enrolledparticipants_parquet.sql} | 103 +++++++++--------- .../tables/fitbitactivitylogs_parquet.sql | 36 ++++++ .../tables/fitbitdailydata_parquet.sql | 62 +++++++++++ .../parquet/tables/fitbitdevices_parquet.sql | 9 ++ .../parquet/tables/fitbitecg_parquet.sql | 22 ++++ .../fitbitecg_waveformsamples_parquet.sql | 8 ++ .../tables/fitbitintradaycombined_parquet.sql | 20 ++++ .../fitbitrestingheartrates_parquet.sql | 8 ++ .../tables/fitbitsleeplogs_parquet.sql | 32 ++++++ ...itbitsleeplogs_sleeplogdetails_parquet.sql | 11 ++ .../tables/googlefitsamples_parquet.sql | 23 ++++ .../healthkitv2activitysummaries_parquet.sql | 16 +++ .../healthkitv2electrocardiogram_parquet.sql | 36 ++++++ ...v2electrocardiogram_subsamples_parquet.sql | 9 ++ .../tables/healthkitv2heartbeat_parquet.sql | 29 +++++ ...ealthkitv2heartbeat_subsamples_parquet.sql | 9 ++ .../tables/healthkitv2samples_parquet.sql | 56 ++++++++++ .../tables/healthkitv2statistics_parquet.sql | 13 +++ .../healthkitv2workouts_events_parquet.sql | 20 ++++ .../tables/healthkitv2workouts_parquet.sql | 77 +++++++++++++ .../parquet/tables/symptomlog_parquet.sql | 20 ++++ .../symptomlog_value_symptoms_parquet.sql | 8 ++ .../symptomlog_value_treatments_parquet.sql | 7 ++ 34 files changed, 747 insertions(+), 51 deletions(-) create mode 100644 snowflake/objects/databases/deploy.sql create mode 100644 snowflake/objects/databases/recover/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql rename snowflake/objects/databases/recover/schemas/parquet/tables/{enrolled_participants.sql => enrolledparticipants_parquet.sql} (96%) create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql create mode 100644 snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql diff --git a/snowflake/objects/databases/deploy.sql b/snowflake/objects/databases/deploy.sql new file mode 100644 index 0000000..9139561 --- /dev/null +++ b/snowflake/objects/databases/deploy.sql @@ -0,0 +1,17 @@ +/* + The current maximum allowed execution depth of EXECUTE IMMEDIATE FROM + statements is 5. Unfortunately, that makes a call stack which looks like: + + depth + 0 deploy.sql => + 1 databases/deploy.sql => + 2 databases/recover/deploy.sql => + 3 databases/recover/schemas/deploy.sql => + 4 databases/recover/schemas/parquet/deploy.sql => + 5 databases/recover/schemas/parquet/tables/deploy.sql => + 6 databases/recover/schemas/parquet/tables/enrolled_participants.sql + + not possible. To circumvent this issue, we omit the highest level of + abstraction (databases/deploy.sql) and instead EXECUTE IMMEDIATE FROM + database deployments individually in the primary deployment script (deploy.sql) +*/ diff --git a/snowflake/objects/databases/recover/deploy.sql b/snowflake/objects/databases/recover/deploy.sql new file mode 100644 index 0000000..f2a3ab1 --- /dev/null +++ b/snowflake/objects/databases/recover/deploy.sql @@ -0,0 +1,12 @@ +/* + Create a recover database (if it doesn't yet exist) for an environment and + deploy all child objects. +*/ +CREATE DATABASE IF NOT EXISTS recover_{{ environment }}; +USE DATABASE recover_{{ environment }}; + +EXECUTE IMMEDIATE + FROM './schemas/deploy.sql' + USING ( + git_branch => '{{ git_branch }}' + ); diff --git a/snowflake/objects/databases/recover/schemas/deploy.sql b/snowflake/objects/databases/recover/schemas/deploy.sql new file mode 100644 index 0000000..ff3a98e --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/deploy.sql @@ -0,0 +1,8 @@ +/* + Deploy schemas and their child objects. +*/ +EXECUTE IMMEDIATE + FROM './parquet/deploy.sql' + USING ( + git_branch => '{{ git_branch }}' + ); diff --git a/snowflake/objects/databases/recover/schemas/parquet/deploy.sql b/snowflake/objects/databases/recover/schemas/parquet/deploy.sql new file mode 100644 index 0000000..ae4f77a --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/deploy.sql @@ -0,0 +1,22 @@ +/* + Create a parquet schema (if it doesn't yet exist) and deploy all child objects. +*/ +CREATE SCHEMA IF NOT EXISTS parquet; +USE SCHEMA parquet; + +SET parquet_file_format_name = 'parquet_format'; +SET parquet_stage_name = 'parquet_s3'; + +EXECUTE IMMEDIATE + FROM './file_format/deploy.sql' + USING ( + parquet_file_format_name => $parquet_file_format_name + ); +EXECUTE IMMEDIATE + FROM './stages/deploy.sql' + USING ( + git_branch => '{{ git_branch }}', + parquet_stage_name => $parquet_stage_name + ); +EXECUTE IMMEDIATE + FROM './tables/deploy.sql'; diff --git a/snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql b/snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql new file mode 100644 index 0000000..9df36a2 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql @@ -0,0 +1,8 @@ +/* + Deploy all file formats +*/ +EXECUTE IMMEDIATE + FROM './parquet_format.sql' + USING ( + parquet_file_format_name => '{{ parquet_file_format_name }}' + ); diff --git a/snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql b/snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql new file mode 100644 index 0000000..e61f943 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql @@ -0,0 +1,7 @@ +/* + Create the Parquet file format +*/ +CREATE OR REPLACE FILE FORMAT {{ parquet_file_format_name }} + TYPE = PARQUET + COMPRESSION = AUTO + USE_VECTORIZED_SCANNER = TRUE; diff --git a/snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql b/snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql new file mode 100644 index 0000000..ad26780 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql @@ -0,0 +1,9 @@ +/* + Deploy all stages under the `parquet` schema. +*/ +EXECUTE IMMEDIATE + FROM './parquet_s3.sql' + USING ( + git_branch => '{{ git_branch }}', + parquet_stage_name => '{{ parquet_stage_name }}' + ); diff --git a/snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql b/snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql new file mode 100644 index 0000000..943ee5d --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql @@ -0,0 +1,6 @@ +/* + Create an external stage over the Parquet data in S3 +*/ +CREATE OR REPLACE STAGE {{ parquet_stage_name }} + URL = 's3://recover-processed-data/{{ git_branch }}/parquet/' + STORAGE_INTEGRATION = recover_prod_s3; diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql new file mode 100644 index 0000000..3bcd889 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql @@ -0,0 +1,54 @@ +/* + CREATE OR ALTER all tables +*/ + +EXECUTE IMMEDIATE + FROM './enrolledparticipants_customfields_symptoms_parquet.sql'; +EXECUTE IMMEDIATE + FROM './enrolledparticipants_customfields_treatments_parquet.sql'; +EXECUTE IMMEDIATE + FROM './enrolledparticipants_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitactivitylogs_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitdailydata_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitdevices_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitecg_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitecg_waveformsamples_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitintradaycombined_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitrestingheartrates_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitsleeplogs_parquet.sql'; +EXECUTE IMMEDIATE + FROM './fitbitsleeplogs_sleeplogdetails_parquet.sql'; +EXECUTE IMMEDIATE + FROM './googlefitsamples_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2activitysummaries_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2electrocardiogram_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2electrocardiogram_subsamples_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2heartbeat_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2heartbeat_subsamples_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2samples_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2statistics_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2workouts_events_parquet.sql'; +EXECUTE IMMEDIATE + FROM './healthkitv2workouts_parquet.sql'; +EXECUTE IMMEDIATE + FROM './symptomlog_parquet.sql'; +EXECUTE IMMEDIATE + FROM './symptomlog_value_symptoms_parquet.sql'; +EXECUTE IMMEDIATE + FROM './symptomlog_value_treatments_parquet.sql'; diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql new file mode 100644 index 0000000..066caed --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql @@ -0,0 +1,11 @@ +CREATE OR ALTER TABLE ENROLLEDPARTICIPANTS_CUSTOMFIELDS_SYMPTOMS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "CustomFields_Symptoms_id" VARCHAR(16777216), + "name" VARCHAR(16777216), + "color" VARCHAR(16777216), + "severityTracking" VARCHAR(16777216), + "inactive" BOOLEAN, + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql new file mode 100644 index 0000000..110e704 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql @@ -0,0 +1,10 @@ +CREATE OR ALTER TABLE ENROLLEDPARTICIPANTS_CUSTOMFIELDS_TREATMENTS ( + "id" NUMBER(38,0), + "CustomFields_Treatments_id" VARCHAR(16777216), + "name" VARCHAR(16777216), + "color" VARCHAR(16777216), + "index" NUMBER(38,0), + "inactive" BOOLEAN, + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_parquet.sql similarity index 96% rename from snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql rename to snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_parquet.sql index e4176bf..662134e 100644 --- a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolled_participants.sql +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_parquet.sql @@ -1,91 +1,92 @@ -create or alter TABLE enrolled_participants_empty ( +CREATE OR ALTER TABLE ENROLLEDPARTICIPANTS ( "id" NUMBER(38,0), - "index" NUMBER(38,0), - "GlobalKey" VARCHAR(16777216), "CustomFields_Treatments_id" VARCHAR(16777216), + "GlobalKey" VARCHAR(16777216), + "name" VARCHAR(16777216), "EmailAddress" VARCHAR(16777216), "CustomFields_Symptoms_id" VARCHAR(16777216), - "name" VARCHAR(16777216), + "FirstName" VARCHAR(16777216), + "color" VARCHAR(16777216), + "LastName" VARCHAR(16777216), + "index" NUMBER(38,0), "DateOfBirth" VARCHAR(16777216), + "inactive" BOOLEAN, + "severityTracking" VARCHAR(16777216), + "PostalCode" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), "EnrollmentDate" VARCHAR(16777216), - "color" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "EventDates_EhrNurtureCampaign2Start" VARCHAR(16777216), "EventDates_AppDownloadDate" VARCHAR(16777216), - "severityTracking" VARCHAR(16777216), - "inactive" BOOLEAN, + "EventDates_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), "EventDates_DevicesConnectedDate" VARCHAR(16777216), - "ParticipantIdentifier" VARCHAR(16777216), + "EventDates_ConnectFitbitNurtureStart" VARCHAR(16777216), "EventDates_EhrConnectedDate" VARCHAR(16777216), - "ParticipantID" VARCHAR(16777216), - "EventDates_SymptomLogSetupDate" VARCHAR(16777216), "EventDates_JoinNurtureCampaignStart" VARCHAR(16777216), + "EventDates_EhrNurtureCampaignStart" VARCHAR(16777216), + "EventDates_LastFitbitTrackerStepsDate" VARCHAR(16777216), + "EventDates_SymptomLogSetupDate" VARCHAR(16777216), "EventDates_InfectionFirstReportedDate" VARCHAR(16777216), "EventDates_JoinNurtureCampaign2Start" VARCHAR(16777216), - "EventDates_LastFitbitTrackerStepsDate" VARCHAR(16777216), - "EventDates_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), - "EventDates_EhrNurtureCampaignStart" VARCHAR(16777216), - "EventDates_ConnectFitbitNurtureStart" VARCHAR(16777216), "EventDates_EhrCampaignStart" VARCHAR(16777216), - "EventDates_EhrNurtureCampaign2Start" VARCHAR(16777216), "CustomFields_AppDownloadDate" VARCHAR(16777216), + "CustomFields_AppDownloaded" VARCHAR(16777216), "CustomFields_AppleHealthEnabled" VARCHAR(16777216), + "CustomFields_AppleHealthRecordsEnabled" VARCHAR(16777216), + "CustomFields_AppleHealthRecordsReceived" VARCHAR(16777216), + "CustomFields_ConnectFitbitNurtureStart" VARCHAR(16777216), "CustomFields_DateOfBirthVerified" VARCHAR(16777216), + "CustomFields_DeviceEligible" VARCHAR(16777216), + "CustomFields_DeviceOrderCompleteDate" VARCHAR(16777216), + "CustomFields_DeviceOrderConfirmationNumber" VARCHAR(16777216), + "CustomFields_DeviceOrderDate" VARCHAR(16777216), + "CustomFields_DeviceOrderInfo" VARCHAR(16777216), + "CustomFields_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_DeviceOrderStatus" VARCHAR(16777216), + "CustomFields_DevicesConnected" VARCHAR(16777216), "CustomFields_DevicesConnectedDate" VARCHAR(16777216), + "CustomFields_EhrConnected" VARCHAR(16777216), + "CustomFields_EhrConnectedDate" VARCHAR(16777216), + "CustomFields_EhrNurtureCampaign2Start" VARCHAR(16777216), + "CustomFields_EhrNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_HasOutstandingSurveys" VARCHAR(16777216), "CustomFields_InfectionsReported" VARCHAR(16777216), + "CustomFields_JoinNurtureCampaignStart" VARCHAR(16777216), + "CustomFields_LastFitbitTrackerStepsDate" VARCHAR(16777216), "CustomFields_ProjectCode" VARCHAR(16777216), "CustomFields_Site" VARCHAR(16777216), - "CustomFields_EhrConnectedDate" VARCHAR(16777216), + "CustomFields_GoogleFitEnabled" VARCHAR(16777216), + "CustomFields_PendingWASOTrigger" VARCHAR(16777216), "CustomFields_Reminder1Enabled" VARCHAR(16777216), "CustomFields_Reminder2Enabled" VARCHAR(16777216), "CustomFields_ReminderTime1" VARCHAR(16777216), "CustomFields_ReminderTime2" VARCHAR(16777216), + "CustomFields_SelfEnrolled" VARCHAR(16777216), "CustomFields_SymptomLogSetupDate" VARCHAR(16777216), "CustomFields_Symptoms" NUMBER(38,0), "CustomFields_Treatments" NUMBER(38,0), - "CustomFields_Under18" VARCHAR(16777216), - "CustomFields_HasOutstandingSurveys" VARCHAR(16777216), - "CustomFields_SelfEnrolled" VARCHAR(16777216), - "CustomFields_DeviceOrderDate" VARCHAR(16777216), - "CustomFields_DeviceOrderInfo" VARCHAR(16777216), - "CustomFields_DeviceOrderStatus" VARCHAR(16777216), - "CustomFields_AppleHealthRecordsEnabled" VARCHAR(16777216), - "CustomFields_DeviceOrderCompleteDate" VARCHAR(16777216), - "CustomFields_DeviceOrderConfirmationNumber" VARCHAR(16777216), - "CustomFields_HasSmartphone" VARCHAR(16777216), - "CustomFields_JoinNurtureCampaignStart" VARCHAR(16777216), - "CustomFields_AppleHealthRecordsReceived" VARCHAR(16777216), - "CustomFields_EOPDate" VARCHAR(16777216), - "CustomFields_EOPReason" VARCHAR(16777216), - "CustomFields_EOPRemoveData" VARCHAR(16777216), - "CustomFields_GoogleFitEnabled" VARCHAR(16777216), "CustomFields_InfectionFirstReportedDate" VARCHAR(16777216), + "CustomFields_JoinNurtureGroup" VARCHAR(16777216), "CustomFields_JoinNurtureCampaign2Start" VARCHAR(16777216), - "CustomFields_AppDownloaded" VARCHAR(16777216), - "CustomFields_DeviceEligible" VARCHAR(16777216), - "CustomFields_DeviceOrderNurtureCampaignStart" VARCHAR(16777216), - "CustomFields_DevicesConnected" VARCHAR(16777216), - "CustomFields_EhrConnected" VARCHAR(16777216), - "CustomFields_EhrNurtureCampaignStart" VARCHAR(16777216), - "CustomFields_LastFitbitTrackerStepsDate" VARCHAR(16777216), - "CustomFields_ConnectFitbitNurtureStart" VARCHAR(16777216), "CustomFields_ForceSendInvitation" VARCHAR(16777216), - "CustomFields_ForceSync" VARCHAR(16777216), - "CustomFields_JoinNurtureGroup" VARCHAR(16777216), - "CustomFields_EhrCampaignStart" VARCHAR(16777216), "CustomFields_PendingUndersleepTrigger" VARCHAR(16777216), - "CustomFields_PendingWASOTrigger" VARCHAR(16777216), + "CustomFields_EhrCampaignStart" VARCHAR(16777216), + "CustomFields_ForceSync" VARCHAR(16777216), "CustomFields_PendingOversleepTrigger" VARCHAR(16777216), - "CustomFields_EhrNurtureCampaign2Start" VARCHAR(16777216), + "CustomFields_EOPDate" VARCHAR(16777216), + "CustomFields_EOPReason" VARCHAR(16777216), + "CustomFields_EOPRemoveData" VARCHAR(16777216), + "CustomFields_PointsAndBadges" VARCHAR(16777216), + "CustomFields_Under18" VARCHAR(16777216), + "CustomFields_HasSmartphone" VARCHAR(16777216), "UtcOffset" VARCHAR(16777216), "TimeZone" VARCHAR(16777216), - "export_end_date" VARCHAR(16777216), + "PreferredLanguage" VARCHAR(16777216), "MobilePhone" VARCHAR(16777216), "UnsubscribedFromEmails" VARCHAR(16777216), "UnsubscribedFromSMS" VARCHAR(16777216), "InsertedDate" VARCHAR(16777216), - "FirstName" VARCHAR(16777216), - "LastName" VARCHAR(16777216), - "Gender" VARCHAR(16777216), - "PostalCode" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), "MiddleName" VARCHAR(16777216), - "PreferredLanguage" VARCHAR(16777216) + "Gender" VARCHAR(16777216) ); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql new file mode 100644 index 0000000..88aecad --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql @@ -0,0 +1,36 @@ +CREATE OR ALTER TABLE FITBITACTIVITYLOGS ( + "ParticipantIdentifier" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "EndDate" VARCHAR(16777216), + "ActiveDuration" VARCHAR(16777216), + "ActivityName" VARCHAR(16777216), + "ActivityTypeId" VARCHAR(16777216), + "AverageHeartRate" VARCHAR(16777216), + "Calories" VARCHAR(16777216), + "Duration" VARCHAR(16777216), + "LastModified" VARCHAR(16777216), + "LogType" VARCHAR(16777216), + "OriginalDuration" VARCHAR(16777216), + "OriginalStartTime" VARCHAR(16777216), + "Steps" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMax" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMin" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMinutes" VARCHAR(16777216), + "HeartRateZone_FatBurnMax" VARCHAR(16777216), + "HeartRateZone_FatBurnMin" VARCHAR(16777216), + "HeartRateZone_FatBurnMinutes" VARCHAR(16777216), + "HeartRateZone_CardioMax" VARCHAR(16777216), + "HeartRateZone_CardioMin" VARCHAR(16777216), + "HeartRateZone_CardioMinutes" VARCHAR(16777216), + "HeartRateZone_PeakMax" VARCHAR(16777216), + "HeartRateZone_PeakMin" VARCHAR(16777216), + "HeartRateZone_PeakMinutes" VARCHAR(16777216), + "SedentaryMinutes" VARCHAR(16777216), + "LightlyMinutes" VARCHAR(16777216), + "FairlyMinutes" VARCHAR(16777216), + "VeryMinutes" VARCHAR(16777216), + "LogId" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql new file mode 100644 index 0000000..65fb3ed --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql @@ -0,0 +1,62 @@ +CREATE OR ALTER TABLE FITBITDAILYDATA ( + "ParticipantIdentifier" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "ActivityCalories" VARCHAR(16777216), + "BodyBmi" VARCHAR(16777216), + "BodyFat" VARCHAR(16777216), + "BodyWeight" VARCHAR(16777216), + "CardioScore" VARCHAR(16777216), + "Calories" VARCHAR(16777216), + "CaloriesBMR" VARCHAR(16777216), + "Distance" VARCHAR(16777216), + "Elevation" VARCHAR(16777216), + "Floors" VARCHAR(16777216), + "FoodCaloriesIn" VARCHAR(16777216), + "HeartRateIntradayCount" VARCHAR(16777216), + "HeartRateIntradayMinuteCount" VARCHAR(16777216), + "HeartRateZone_OutOfRangeCaloriesOut" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMax" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMin" VARCHAR(16777216), + "HeartRateZone_OutOfRangeMinutes" VARCHAR(16777216), + "HeartRateZone_FatBurnCaloriesOut" VARCHAR(16777216), + "HeartRateZone_FatBurnMax" VARCHAR(16777216), + "HeartRateZone_FatBurnMin" VARCHAR(16777216), + "HeartRateZone_FatBurnMinutes" VARCHAR(16777216), + "HeartRateZone_CardioCaloriesOut" VARCHAR(16777216), + "HeartRateZone_CardioMax" VARCHAR(16777216), + "HeartRateZone_CardioMin" VARCHAR(16777216), + "HeartRateZone_CardioMinutes" VARCHAR(16777216), + "HeartRateZone_PeakCaloriesOut" VARCHAR(16777216), + "HeartRateZone_PeakMax" VARCHAR(16777216), + "HeartRateZone_PeakMin" VARCHAR(16777216), + "HeartRateZone_PeakMinutes" VARCHAR(16777216), + "MinutesFairlyActive" VARCHAR(16777216), + "MinutesLightlyActive" VARCHAR(16777216), + "MinutesSedentary" VARCHAR(16777216), + "MinutesVeryActive" VARCHAR(16777216), + "RestingHeartRate" VARCHAR(16777216), + "Steps" VARCHAR(16777216), + "Tracker_ActivityCalories" VARCHAR(16777216), + "Tracker_Calories" VARCHAR(16777216), + "Tracker_Distance" VARCHAR(16777216), + "Tracker_Elevation" VARCHAR(16777216), + "Tracker_Floors" VARCHAR(16777216), + "Tracker_MinutesFairlyActive" VARCHAR(16777216), + "Tracker_MinutesLightlyActive" VARCHAR(16777216), + "Tracker_MinutesSedentary" VARCHAR(16777216), + "Tracker_MinutesVeryActive" VARCHAR(16777216), + "Tracker_Steps" VARCHAR(16777216), + "Water" VARCHAR(16777216), + "ModifiedDate" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "BreathingRate" VARCHAR(16777216), + "Hrv_DailyRmssd" VARCHAR(16777216), + "Hrv_DeepRmssd" VARCHAR(16777216), + "SpO2_Avg" VARCHAR(16777216), + "SpO2_Max" VARCHAR(16777216), + "SpO2_Min" VARCHAR(16777216), + "TempSkin" VARCHAR(16777216), + "TempSkinLogType" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql new file mode 100644 index 0000000..80af166 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql @@ -0,0 +1,9 @@ +CREATE OR ALTER TABLE FITBITDEVICES ( + "ParticipantIdentifier" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "Device" VARCHAR(16777216), + "Battery" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql new file mode 100644 index 0000000..98c6403 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql @@ -0,0 +1,22 @@ +CREATE OR ALTER TABLE FITBITECG ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "WaveformSamples_val" NUMBER(38,0), + "ParticipantIdentifier" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "FitbitEcgKey" VARCHAR(16777216), + "StartTime" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "AverageHeartRate" NUMBER(38,0), + "ResultClassification" VARCHAR(16777216), + "WaveformSamples" NUMBER(38,0), + "SamplingFrequencyHz" FLOAT, + "ScalingFactor" FLOAT, + "NumberOfWaveformSamples" NUMBER(38,0), + "LeadNumber" NUMBER(38,0), + "FeatureVersion" VARCHAR(16777216), + "DeviceName" VARCHAR(16777216), + "FirmwareVersion" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql new file mode 100644 index 0000000..7063c59 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql @@ -0,0 +1,8 @@ +CREATE OR ALTER TABLE FITBITECG_WAVEFORMSAMPLES ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "WaveformSamples_val" NUMBER(38,0), + "ParticipantIdentifier" VARCHAR(16777216), + "FitbitEcgKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql new file mode 100644 index 0000000..a0ca540 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql @@ -0,0 +1,20 @@ +CREATE OR ALTER TABLE FITBITINTRADAYCOMBINED ( + "ParticipantID" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "DateTime" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "Level" VARCHAR(16777216), + "Mets" VARCHAR(16777216), + "Rmssd" VARCHAR(16777216), + "Coverage" VARCHAR(16777216), + "Hf" VARCHAR(16777216), + "Lf" VARCHAR(16777216), + "DeepSleepSummaryBreathRate" VARCHAR(16777216), + "RemSleepSummaryBreathRate" VARCHAR(16777216), + "FullSleepSummaryBreathRate" VARCHAR(16777216), + "LightSleepSummaryBreathRate" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql new file mode 100644 index 0000000..ca601db --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql @@ -0,0 +1,8 @@ +CREATE OR ALTER TABLE FITBITRESTINGHEARTRATES ( + "ParticipantIdentifier" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "RestingHeartRate" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql new file mode 100644 index 0000000..e61e086 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql @@ -0,0 +1,32 @@ +CREATE OR ALTER TABLE FITBITSLEEPLOGS ( + "id" NUMBER(38,0), + "ParticipantIdentifier" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "index" NUMBER(38,0), + "EndDate" VARCHAR(16777216), + "Duration" VARCHAR(16777216), + "Efficiency" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "InfoCode" VARCHAR(16777216), + "MinutesAfterWakeup" VARCHAR(16777216), + "MinutesAsleep" VARCHAR(16777216), + "MinutesAwake" VARCHAR(16777216), + "MinutesToFallAsleep" VARCHAR(16777216), + "TimeInBed" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "SleepLevelDeep" VARCHAR(16777216), + "SleepLevelLight" VARCHAR(16777216), + "SleepLevelRem" VARCHAR(16777216), + "SleepLevelWake" VARCHAR(16777216), + "SleepLogDetails" NUMBER(38,0), + "LogId" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "IsMainSleep" VARCHAR(16777216), + "LogType" VARCHAR(16777216), + "ModifiedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "SleepLevelAwake" VARCHAR(16777216), + "SleepLevelAsleep" VARCHAR(16777216), + "SleepLevelRestless" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql new file mode 100644 index 0000000..69fd77e --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql @@ -0,0 +1,11 @@ +CREATE OR ALTER TABLE FITBITSLEEPLOGS_SLEEPLOGDETAILS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Type" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "EndDate" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "LogId" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql new file mode 100644 index 0000000..8d4696b --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql @@ -0,0 +1,23 @@ +CREATE OR ALTER TABLE GOOGLEFITSAMPLES ( + "GoogleFitSampleKey" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "WindowStart" VARCHAR(16777216), + "WindowEnd" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "DataSourceAppPackageName" VARCHAR(16777216), + "DataSourceStreamIdentifier" VARCHAR(16777216), + "DataSourceStreamName" VARCHAR(16777216), + "OriginalDataSourceAppPackageName" VARCHAR(16777216), + "OriginalDataSourceStreamIdentifier" VARCHAR(16777216), + "OriginalDataSourceStreamName" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "OriginalDataSourceDeviceManufacturer" VARCHAR(16777216), + "OriginalDataSourceDeviceModel" VARCHAR(16777216), + "OriginalDataSourceDeviceType" VARCHAR(16777216), + "OriginalDataSourceDeviceUID" VARCHAR(16777216), + "Units" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql new file mode 100644 index 0000000..1e16cb3 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql @@ -0,0 +1,16 @@ +CREATE OR ALTER TABLE HEALTHKITV2ACTIVITYSUMMARIES ( + "HealthKitActivitySummaryKey" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "EndDate" VARCHAR(16777216), + "ActiveEnergyBurned" FLOAT, + "ActiveEnergyBurnedGoal" FLOAT, + "AppleExerciseTime" FLOAT, + "AppleExerciseTimeGoal" FLOAT, + "AppleStandHours" FLOAT, + "AppleStandHoursGoal" FLOAT, + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql new file mode 100644 index 0000000..427767e --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql @@ -0,0 +1,36 @@ +CREATE OR ALTER TABLE HEALTHKITV2ELECTROCARDIOGRAM ( + "HealthKitECGSampleKey" VARCHAR(16777216), + "id" NUMBER(38,0), + "Device_FDAIdentifier" VARCHAR(16777216), + "index" NUMBER(38,0), + "MicroVolts" FLOAT, + "Device_FirmwareVersion" VARCHAR(16777216), + "Device_HardwareVersion" VARCHAR(16777216), + "TimeSinceSampleStart" FLOAT, + "Device_LocalIdentifier" VARCHAR(16777216), + "Device_Manufacturer" VARCHAR(16777216), + "Device_Model" VARCHAR(16777216), + "Device_Name" VARCHAR(16777216), + "Device_SoftwareVersion" VARCHAR(16777216), + "SubSamples" NUMBER(38,0), + "Source_Name" VARCHAR(16777216), + "Source_Identifier" VARCHAR(16777216), + "Source_Version" VARCHAR(16777216), + "Source_OperatingSystemVersion" VARCHAR(16777216), + "Source_ProductType" VARCHAR(16777216), + "AverageHeartRate" NUMBER(38,0), + "NumberOfVoltageMeasurements" NUMBER(38,0), + "SamplingFrequency" NUMBER(38,0), + "Classification" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "SymptomStatus" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncVersion" VARCHAR(16777216), + "Metadata_HKMetadataKeyAppleECGAlgorithmVersion" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncIdentifier" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql new file mode 100644 index 0000000..a2226b2 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql @@ -0,0 +1,9 @@ +CREATE OR ALTER TABLE HEALTHKITV2ELECTROCARDIOGRAM_SUBSAMPLES ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "MicroVolts" FLOAT, + "TimeSinceSampleStart" FLOAT, + "ParticipantIdentifier" VARCHAR(16777216), + "HealthKitECGSampleKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql new file mode 100644 index 0000000..f45163c --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql @@ -0,0 +1,29 @@ +CREATE OR ALTER TABLE HEALTHKITV2HEARTBEAT ( + "id" NUMBER(38,0), + "HealthKitHeartbeatSampleKey" VARCHAR(16777216), + "Device_FDAIdentifier" VARCHAR(16777216), + "index" NUMBER(38,0), + "PrecededByGap" BOOLEAN, + "Device_FirmwareVersion" VARCHAR(16777216), + "TimeSinceSeriesStart" FLOAT, + "Device_HardwareVersion" VARCHAR(16777216), + "Device_LocalIdentifier" VARCHAR(16777216), + "Device_Manufacturer" VARCHAR(16777216), + "Device_Model" VARCHAR(16777216), + "Device_Name" VARCHAR(16777216), + "Device_SoftwareVersion" VARCHAR(16777216), + "SubSamples" NUMBER(38,0), + "Source_Name" VARCHAR(16777216), + "Source_Identifier" VARCHAR(16777216), + "Source_Version" VARCHAR(16777216), + "Source_OperatingSystemVersion" VARCHAR(16777216), + "Source_ProductType" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "Metadata_HKAlgorithmVersion" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql new file mode 100644 index 0000000..cd7d33c --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql @@ -0,0 +1,9 @@ +CREATE OR ALTER TABLE HEALTHKITV2HEARTBEAT_SUBSAMPLES ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "PrecededByGap" BOOLEAN, + "TimeSinceSeriesStart" FLOAT, + "ParticipantIdentifier" VARCHAR(16777216), + "HealthKitHeartbeatSampleKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql new file mode 100644 index 0000000..9da5721 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql @@ -0,0 +1,56 @@ +CREATE OR ALTER TABLE HEALTHKITV2SAMPLES ( + "ParticipantIdentifier" VARCHAR(16777216), + "HealthKitSampleKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "Units" VARCHAR(16777216), + "Source_Name" VARCHAR(16777216), + "Source_Identifier" VARCHAR(16777216), + "Source_Version" VARCHAR(16777216), + "Source_OperatingSystemVersion" VARCHAR(16777216), + "Source_ProductType" VARCHAR(16777216), + "Device_FDAIdentifier" VARCHAR(16777216), + "Device_FirmwareVersion" VARCHAR(16777216), + "Device_HardwareVersion" VARCHAR(16777216), + "Device_LocalIdentifier" VARCHAR(16777216), + "Device_Manufacturer" VARCHAR(16777216), + "Device_Model" VARCHAR(16777216), + "Device_Name" VARCHAR(16777216), + "Device_SoftwareVersion" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncVersion" VARCHAR(16777216), + "Metadata_HKTimeZone" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncIdentifier" VARCHAR(16777216), + "Metadata_HKMetadataKeyHeartRateMotionContext" VARCHAR(16777216), + "Metadata_HKExternalUUID" VARCHAR(16777216), + "metadata_withings_link" VARCHAR(16777216), + "metadata_health_mate_app_version" VARCHAR(16777216), + "metadata_withings_user_identifier" VARCHAR(16777216), + "Metadata_HKWasUserEntered" VARCHAR(16777216), + "metadata_sequence_no" VARCHAR(16777216), + "Metadata_Manufacturer" VARCHAR(16777216), + "Metadata_HKDateOfEarliestDataUsedForEstimate" VARCHAR(16777216), + "Metadata_HKMetadataKeyAppleDeviceCalibrated" VARCHAR(16777216), + "Metadata_sessionId" VARCHAR(16777216), + "Metadata_HKAlgorithmVersion" VARCHAR(16777216), + "Metadata_HKHeartRateSensorLocation" VARCHAR(16777216), + "Metadata_HKMetadataKeyDevicePlacementSide" VARCHAR(16777216), + "Metadata_HKMetadataKeyQuantityClampedToLowerBound" VARCHAR(16777216), + "Metadata_Status" VARCHAR(16777216), + "metadata_transmitter_time" VARCHAR(16777216), + "Metadata_HKDeviceName" VARCHAR(16777216), + "metadata_trend_arrow" VARCHAR(16777216), + "metadata_trend_rate" VARCHAR(16777216), + "Metadata_HKVO2MaxTestType" VARCHAR(16777216), + "Metadata_HKMetadataKeyHeartRateRecoveryActivityType" VARCHAR(16777216), + "Metadata_HKMetadataKeyUserMotionContext" VARCHAR(16777216), + "Metadata_HKMetadataKeyHeartRateRecoveryTestType" VARCHAR(16777216), + "Metadata_HKDeviceManufacturerName" VARCHAR(16777216), + "Metadata_HKSwimmingStrokeStyle" VARCHAR(16777216), + "Metadata_timeEstimate" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql new file mode 100644 index 0000000..a784774 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql @@ -0,0 +1,13 @@ +CREATE OR ALTER TABLE HEALTHKITV2STATISTICS ( + "HealthKitStatisticKey" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "Value" VARCHAR(16777216), + "Units" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "Type" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql new file mode 100644 index 0000000..d8d85d1 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql @@ -0,0 +1,20 @@ +CREATE OR ALTER TABLE HEALTHKITV2WORKOUTS_EVENTS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Events_ParticipantID" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "EndDate" VARCHAR(16777216), + "Metadata_TachyMonEvent_alertLevelAndDirection" VARCHAR(16777216), + "Metadata_TachyMonEvent_eventAvgHR" VARCHAR(16777216), + "Metadata_TachyMonEvent_maxHR" VARCHAR(16777216), + "Metadata_TachyMonEvent_alertLevel1" VARCHAR(16777216), + "Metadata_TachyMonEvent_alertLevel2" VARCHAR(16777216), + "Metadata_TachyMonEvent_minHR" VARCHAR(16777216), + "Metadata_TachyMonEvent_startAvgHR" VARCHAR(16777216), + "Metadata_HKSWOLFScore" VARCHAR(16777216), + "Metadata_HKSwimmingStrokeStyle" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "HealthKitWorkoutKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql new file mode 100644 index 0000000..8b23c6b --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql @@ -0,0 +1,77 @@ +CREATE OR ALTER TABLE HEALTHKITV2WORKOUTS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Events_ParticipantID" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "StartDate" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "Summary_ActivityType" VARCHAR(16777216), + "EndDate" VARCHAR(16777216), + "Summary_Duration" FLOAT, + "Metadata_TachyMonEvent_alertLevelAndDirection" VARCHAR(16777216), + "Summary_TotalEnergyBurned" FLOAT, + "Metadata_TachyMonEvent_eventAvgHR" VARCHAR(16777216), + "Summary_TotalDistance" FLOAT, + "Metadata_TachyMonEvent_maxHR" VARCHAR(16777216), + "Metadata_TachyMonEvent_alertLevel1" VARCHAR(16777216), + "Summary_TotalSwimmingStrokeCount" FLOAT, + "Metadata_TachyMonEvent_alertLevel2" VARCHAR(16777216), + "Source_Name" VARCHAR(16777216), + "Metadata_TachyMonEvent_minHR" VARCHAR(16777216), + "Source_Identifier" VARCHAR(16777216), + "Source_Version" VARCHAR(16777216), + "Metadata_TachyMonEvent_startAvgHR" VARCHAR(16777216), + "Metadata_HKSWOLFScore" VARCHAR(16777216), + "Source_OperatingSystemVersion" VARCHAR(16777216), + "Metadata_HKSwimmingStrokeStyle" VARCHAR(16777216), + "Source_ProductType" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncVersion" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "Metadata_HKExternalUUID" VARCHAR(16777216), + "HealthKitWorkoutKey" VARCHAR(16777216), + "ParticipantID" VARCHAR(16777216), + "Metadata_HKMetadataKeySyncIdentifier" VARCHAR(16777216), + "Metadata_HKIndoorWorkout" VARCHAR(16777216), + "Metadata_HKWorkoutBrandName" VARCHAR(16777216), + "Metadata_HKTimeZone" VARCHAR(16777216), + "Metadata_HKGroupFitness" VARCHAR(16777216), + "Metadata_HKCoachedWorkout" VARCHAR(16777216), + "metadata_whoop_strain" VARCHAR(16777216), + "Metadata_HKMetadataKeyAppleFitnessPlusSession" VARCHAR(16777216), + "Metadata_Coach" VARCHAR(16777216), + "metadata_splat_points" VARCHAR(16777216), + "Metadata_WorkoutUUID" VARCHAR(16777216), + "Metadata_Class" VARCHAR(16777216), + "metadata_device_id" VARCHAR(16777216), + "Metadata_HKWasUserEntered" VARCHAR(16777216), + "Metadata_HKSwimmingLocationType" VARCHAR(16777216), + "metadata_total_workout_time" VARCHAR(16777216), + "metadata_record_break_s_" VARCHAR(16777216), + "metadata_total_weight_lifted" VARCHAR(16777216), + "metadata_wasted_time" VARCHAR(16777216), + "metadata_total_rest_time" VARCHAR(16777216), + "metadata_total_exercises_completed" VARCHAR(16777216), + "Metadata_HKDeviceName" VARCHAR(16777216), + "Metadata_ExerciseIdentifier" VARCHAR(16777216), + "Metadata_Title" VARCHAR(16777216), + "Metadata_activityType" VARCHAR(16777216), + "Metadata_SWMetadataKeyCustomWorkoutTitle" VARCHAR(16777216), + "Metadata_SWMetadataKeyUniqueID" VARCHAR(16777216), + "Metadata_SWMetadataKeyYYYYMMDD" VARCHAR(16777216), + "Metadata_SWMetadataKeySetsCompleted" VARCHAR(16777216), + "Metadata_SWMetadataKeyCustomWorkoutID" VARCHAR(16777216), + "Metadata_SWMetadataKeyDifficultyLevel" VARCHAR(16777216), + "metadata_average_speed" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216), + "Events" NUMBER(38,0), + "Device_FDAIdentifier" VARCHAR(16777216), + "Device_FirmwareVersion" VARCHAR(16777216), + "Device_HardwareVersion" VARCHAR(16777216), + "Device_LocalIdentifier" VARCHAR(16777216), + "Device_Manufacturer" VARCHAR(16777216), + "Device_Model" VARCHAR(16777216), + "Device_Name" VARCHAR(16777216), + "Device_SoftwareVersion" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql new file mode 100644 index 0000000..f062f45 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql @@ -0,0 +1,20 @@ +CREATE OR ALTER TABLE SYMPTOMLOG ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Value_symptoms_id" VARCHAR(16777216), + "Value_treatments_id" VARCHAR(16777216), + "Type" VARCHAR(16777216), + "Date" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "severity" NUMBER(38,0), + "DataPointKey" VARCHAR(16777216), + "Value_symptoms" NUMBER(38,0), + "Value_treatments" NUMBER(38,0), + "Value_notes" VARCHAR(16777216), + "Value_overallFeeling" NUMBER(38,0), + "Value_icon" VARCHAR(16777216), + "Properties" VARCHAR(16777216), + "InsertedDate" VARCHAR(16777216), + "export_start_date" VARCHAR(16777216), + "export_end_date" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql new file mode 100644 index 0000000..70603c0 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql @@ -0,0 +1,8 @@ +CREATE OR ALTER TABLE SYMPTOMLOG_VALUE_SYMPTOMS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Value_symptoms_id" VARCHAR(16777216), + "severity" NUMBER(38,0), + "ParticipantIdentifier" VARCHAR(16777216), + "DataPointKey" VARCHAR(16777216) +); diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql new file mode 100644 index 0000000..29821d7 --- /dev/null +++ b/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql @@ -0,0 +1,7 @@ +CREATE OR ALTER TABLE SYMPTOMLOG_VALUE_TREATMENTS ( + "id" NUMBER(38,0), + "index" NUMBER(38,0), + "Value_treatments_id" VARCHAR(16777216), + "ParticipantIdentifier" VARCHAR(16777216), + "DataPointKey" VARCHAR(16777216) +); From 57ae25d2679aa33a090b8632f38afbed13d2942d Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Tue, 2 Jul 2024 15:33:21 -0700 Subject: [PATCH 4/8] Deploy Snowflake objects in upload-and-deploy workflow --- .github/workflows/upload-and-deploy.yaml | 15 +++-- snowflake/objects/deploy.sql | 77 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 snowflake/objects/deploy.sql diff --git a/.github/workflows/upload-and-deploy.yaml b/.github/workflows/upload-and-deploy.yaml index e816245..eae16a5 100755 --- a/.github/workflows/upload-and-deploy.yaml +++ b/.github/workflows/upload-and-deploy.yaml @@ -55,15 +55,12 @@ jobs: echo 'authenticator = "SNOWFLAKE_JWT"' >> $config_file echo "private_key_path = \"$private_key_file\"" >> $config_file - # check config file - cat $config_file - # Write config.toml path to global environment echo "SNOWFLAKE_CONFIG_PATH=$config_file" >> $GITHUB_ENV - - name: check config + - name: Configuration file information run: | - echo $SNOWFLAKE_CONFIG_PATH + echo "Snowflake configuration is located at $SNOWFLAKE_CONFIG_PATH" cat $SNOWFLAKE_CONFIG_PATH - name: Install Snowflake CLI @@ -71,11 +68,17 @@ jobs: with: default-config-file-path: ${{ env.SNOWFLAKE_CONFIG_PATH }} - - name: test connection + - name: Test Snowflake connection run: | snow --version snow connection test + - name: Deploy Snowflake objects + run: | + snow sql \ + -D "environment=$(git rev-parse --abbrev-ref HEAD)" \ + -f snowflake/objects/deploy.sql + upload-files: name: Upload files to S3 bucket in development runs-on: ubuntu-latest diff --git a/snowflake/objects/deploy.sql b/snowflake/objects/deploy.sql new file mode 100644 index 0000000..cbcafd6 --- /dev/null +++ b/snowflake/objects/deploy.sql @@ -0,0 +1,77 @@ +/* + This is the primary deployment script for RECOVER Snowflake objects. + + Deployments are made to a specific environment. An environment is analogous + to a database. Account-level objects are not covered by this script. We assume + that the following objects have already been created at the account level: + + - ROLE `RECOVER_DATA_ENGINEER` + * A ROLE with the appropriate privelages to create and deploy + objects in a database. + - WAREHOUSE `RECOVER_XSMALL` + - API INTEGRATION `RECOVER_GIT` + * An API INTEGRATION with an API_ALLOWED_PREFIXES value + containing 'https://github.com/Sage-Bionetworks/' and + API_PROVIDER = GIT_HTTPS_API. + - STORAGE INTEGRATION `RECOVER_PROD_S3` + * An S3 storage integration which allows access to the + S3 buckets in the RECOVER production account. + + Additionally, we assume that the following databases have already been created + when deploying to the "staging" or "main" environment, respectively: + + - DATABASE `RECOVER_STAGING` + - DATABASE `RECOVER_MAIN` + + To deploy to an environment identified by your current git branch, + we can invoke this file with the Snowflake CLI like so: + + `snow sql -D "environment=$(git rev-parse --abbrev-ref HEAD)" -f {this file}` +*/ + +/* + Configure the runner +*/ +USE ROLE RECOVER_DATA_ENGINEER; +USE WAREHOUSE RECOVER_XSMALL; + +/* + Configure and bootstrap the database if this is a dev environment. + + Since we typically want to use the branch name as the environment identifier, + but only A-Za-z0-9 and _ and $ characters are allowed in Snowflake identifier + names and we have the convention of naming the branch after its associated + Jira ticket (e.g., etl-123), we substitute a likely hyphen in the `environment` + variable passed at runtime. +*/ +SET safe_environment_identifier = (SELECT REPLACE('&{ environment }', '-', '_')); +SET database_identifier = CONCAT('recover_', $safe_environment_identifier); + +EXECUTE IMMEDIATE +$$ +BEGIN + IF ('&{ environment }' != 'main' AND '&{ environment }' != 'staging') THEN + -- This is a dev environment. Deploy from scratch. + CREATE OR REPLACE DATABASE IDENTIFIER($database_identifier); + END IF; +END; +$$; +USE DATABASE IDENTIFIER($database_identifier); + +/* + Create an external stage over the RECOVER Git repository so that we can + use EXECUTE IMMEDIATE FROM statements. +*/ +CREATE GIT REPOSITORY IF NOT EXISTS recover_git_repository + ORIGIN = 'https://github.com/Sage-Bionetworks/recover.git' + API_INTEGRATION = RECOVER_GIT; + +/* + Deploy our database and all its child objects. +*/ +EXECUTE IMMEDIATE + FROM @recover_git_repository/branches/&{ environment }/snowflake/objects/databases/recover/deploy.sql + USING ( + environment => $safe_environment_identifier, + git_branch => '&{ environment }' + ); From de701d9b9c61569c4e3f6903add8a6e2e5feac96 Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Wed, 3 Jul 2024 08:06:14 -0700 Subject: [PATCH 5/8] Add README to `snowflake` directory --- snowflake/README.md | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 snowflake/README.md diff --git a/snowflake/README.md b/snowflake/README.md new file mode 100644 index 0000000..3a6a9bf --- /dev/null +++ b/snowflake/README.md @@ -0,0 +1,50 @@ +# Snowflake + +We use Snowflake to interact with RECOVER data. Snowflake is a [DBMS](https://en.wikipedia.org/wiki/Database) with managed infrastructure that enables us to work with the data in a way that's easier and faster compared to AWS Glue. For general information about Snowflake, see Snowflake's [Key Concepts and Architecture](https://docs.snowflake.com/en/user-guide/intro-key-concepts). + +## Deployment +We deploy Snowflake objects as part of our CI/CD process. When a commit is pushed to a branch, all objects under the `objects` folder are deployed automatically to a database prefixed with the branch name, e.g., `RECOVER_MY_BRANCH_NAME`. Deployment happens within its own isolated environment, ensuring that deployments do not interfere with each other and maintain their own independent configurations and resources. An environment is analogous to a database. That said, account-level objects are reeused by each deployment. For more information, see [our deployment entrypoint](objects/deploy.sql). + +### Deployment logic and object definitions +Deployment logic and object [DDL](https://en.wikipedia.org/wiki/Data_definition_language) is organized as a hierarchy: +``` +snowflake/objects +└── database + └── recover + └── schema + └── parquet + ├── file_format + ├── stage + └── table +``` + +Every level in this hierarchy has a `deploy.sql` which will deploy all child objects with respect to the current directory. +``` +snowflake/objects +├── database +│   ├── deploy.sql +│   └── recover +│   ├── deploy.sql +│   └── schema +│   ├── deploy.sql +│   └── parquet +│   ├── deploy.sql +│   ├── file_format +│   │   ├── deploy.sql +│   │   └── parquet_format.sql +│   ├── stage +│   │   ├── deploy.sql +│   │   └── parquet_s3.sql +│   └── table +│   ├── deploy.sql +│   ├── enrolledparticipants_customfields_symptoms_parquet.sql +│   ├── enrolledparticipants_customfields_treatments_parquet.sql +│   ├── enrolledparticipants_parquet.sql +│   ├── fitbitactivitylogs_parquet.sql +│   ├── fitbitdailydata_parquet.sql +│   ├── ... +└── deploy.sql +``` +For example, the file located at `snowflake/objects/database/recover/deploy.sql` will deploy all objects under the `RECOVER` database, and `snowflake/objects/database/recover/schema/parquet/deploy.sql` will deploy the file formats, stages, and tables under the `PARQUET` schema. + +The child objects, that is, the schemas, file formats, stages, tables – anything that is not a database – are defined in such a way as to be agnostic to their parent context. For example, `snowflake/objects/database/recover/schema/parquet/deploy.sql` will deploy the `PARQUET` schema and all its child objects to whichever database your Snowflake user assumes. There is nothing in the SQL which restricts the `PARQUET` schema to be created within the `RECOVER` database. Likewise, the tables in `snowflake/objects/database/recover/schema/parquet/table/` can be deployed to any schema, although their DDL is specific to the columns in our Parquet datasets. From 029a674295045c1a96d234928a6522ac725095cc Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Wed, 3 Jul 2024 08:10:26 -0700 Subject: [PATCH 6/8] Rename `snowflake/objects/` folders to singular --- snowflake/objects/{databases => database}/deploy.sql | 0 snowflake/objects/{databases => database}/recover/deploy.sql | 2 +- .../recover/schemas => database/recover/schema}/deploy.sql | 0 .../schemas => database/recover/schema}/parquet/deploy.sql | 4 ++-- .../recover/schema}/parquet/file_format/deploy.sql | 0 .../recover/schema}/parquet/file_format/parquet_format.sql | 0 .../recover/schema/parquet/stage}/deploy.sql | 0 .../recover/schema/parquet/stage}/parquet_s3.sql | 0 .../recover/schema/parquet/table}/deploy.sql | 0 .../enrolledparticipants_customfields_symptoms_parquet.sql | 0 .../enrolledparticipants_customfields_treatments_parquet.sql | 0 .../schema/parquet/table}/enrolledparticipants_parquet.sql | 0 .../schema/parquet/table}/fitbitactivitylogs_parquet.sql | 0 .../recover/schema/parquet/table}/fitbitdailydata_parquet.sql | 0 .../recover/schema/parquet/table}/fitbitdevices_parquet.sql | 0 .../recover/schema/parquet/table}/fitbitecg_parquet.sql | 0 .../parquet/table}/fitbitecg_waveformsamples_parquet.sql | 0 .../schema/parquet/table}/fitbitintradaycombined_parquet.sql | 0 .../schema/parquet/table}/fitbitrestingheartrates_parquet.sql | 0 .../recover/schema/parquet/table}/fitbitsleeplogs_parquet.sql | 0 .../table}/fitbitsleeplogs_sleeplogdetails_parquet.sql | 0 .../schema/parquet/table}/googlefitsamples_parquet.sql | 0 .../parquet/table}/healthkitv2activitysummaries_parquet.sql | 0 .../parquet/table}/healthkitv2electrocardiogram_parquet.sql | 0 .../healthkitv2electrocardiogram_subsamples_parquet.sql | 0 .../schema/parquet/table}/healthkitv2heartbeat_parquet.sql | 0 .../table}/healthkitv2heartbeat_subsamples_parquet.sql | 0 .../schema/parquet/table}/healthkitv2samples_parquet.sql | 0 .../schema/parquet/table}/healthkitv2statistics_parquet.sql | 0 .../parquet/table}/healthkitv2workouts_events_parquet.sql | 0 .../schema/parquet/table}/healthkitv2workouts_parquet.sql | 0 .../recover/schema/parquet/table}/symptomlog_parquet.sql | 0 .../parquet/table}/symptomlog_value_symptoms_parquet.sql | 0 .../parquet/table}/symptomlog_value_treatments_parquet.sql | 0 snowflake/objects/deploy.sql | 2 +- 35 files changed, 4 insertions(+), 4 deletions(-) rename snowflake/objects/{databases => database}/deploy.sql (100%) rename snowflake/objects/{databases => database}/recover/deploy.sql (89%) rename snowflake/objects/{databases/recover/schemas => database/recover/schema}/deploy.sql (100%) rename snowflake/objects/{databases/recover/schemas => database/recover/schema}/parquet/deploy.sql (89%) rename snowflake/objects/{databases/recover/schemas => database/recover/schema}/parquet/file_format/deploy.sql (100%) rename snowflake/objects/{databases/recover/schemas => database/recover/schema}/parquet/file_format/parquet_format.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/stages => database/recover/schema/parquet/stage}/deploy.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/stages => database/recover/schema/parquet/stage}/parquet_s3.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/deploy.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/enrolledparticipants_customfields_symptoms_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/enrolledparticipants_customfields_treatments_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/enrolledparticipants_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitactivitylogs_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitdailydata_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitdevices_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitecg_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitecg_waveformsamples_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitintradaycombined_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitrestingheartrates_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitsleeplogs_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/fitbitsleeplogs_sleeplogdetails_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/googlefitsamples_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2activitysummaries_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2electrocardiogram_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2electrocardiogram_subsamples_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2heartbeat_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2heartbeat_subsamples_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2samples_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2statistics_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2workouts_events_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/healthkitv2workouts_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/symptomlog_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/symptomlog_value_symptoms_parquet.sql (100%) rename snowflake/objects/{databases/recover/schemas/parquet/tables => database/recover/schema/parquet/table}/symptomlog_value_treatments_parquet.sql (100%) diff --git a/snowflake/objects/databases/deploy.sql b/snowflake/objects/database/deploy.sql similarity index 100% rename from snowflake/objects/databases/deploy.sql rename to snowflake/objects/database/deploy.sql diff --git a/snowflake/objects/databases/recover/deploy.sql b/snowflake/objects/database/recover/deploy.sql similarity index 89% rename from snowflake/objects/databases/recover/deploy.sql rename to snowflake/objects/database/recover/deploy.sql index f2a3ab1..320ac7d 100644 --- a/snowflake/objects/databases/recover/deploy.sql +++ b/snowflake/objects/database/recover/deploy.sql @@ -6,7 +6,7 @@ CREATE DATABASE IF NOT EXISTS recover_{{ environment }}; USE DATABASE recover_{{ environment }}; EXECUTE IMMEDIATE - FROM './schemas/deploy.sql' + FROM './schema/deploy.sql' USING ( git_branch => '{{ git_branch }}' ); diff --git a/snowflake/objects/databases/recover/schemas/deploy.sql b/snowflake/objects/database/recover/schema/deploy.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/deploy.sql rename to snowflake/objects/database/recover/schema/deploy.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/deploy.sql b/snowflake/objects/database/recover/schema/parquet/deploy.sql similarity index 89% rename from snowflake/objects/databases/recover/schemas/parquet/deploy.sql rename to snowflake/objects/database/recover/schema/parquet/deploy.sql index ae4f77a..0cac759 100644 --- a/snowflake/objects/databases/recover/schemas/parquet/deploy.sql +++ b/snowflake/objects/database/recover/schema/parquet/deploy.sql @@ -13,10 +13,10 @@ EXECUTE IMMEDIATE parquet_file_format_name => $parquet_file_format_name ); EXECUTE IMMEDIATE - FROM './stages/deploy.sql' + FROM './stage/deploy.sql' USING ( git_branch => '{{ git_branch }}', parquet_stage_name => $parquet_stage_name ); EXECUTE IMMEDIATE - FROM './tables/deploy.sql'; + FROM './table/deploy.sql'; diff --git a/snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql b/snowflake/objects/database/recover/schema/parquet/file_format/deploy.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/file_format/deploy.sql rename to snowflake/objects/database/recover/schema/parquet/file_format/deploy.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql b/snowflake/objects/database/recover/schema/parquet/file_format/parquet_format.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/file_format/parquet_format.sql rename to snowflake/objects/database/recover/schema/parquet/file_format/parquet_format.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql b/snowflake/objects/database/recover/schema/parquet/stage/deploy.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/stages/deploy.sql rename to snowflake/objects/database/recover/schema/parquet/stage/deploy.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql b/snowflake/objects/database/recover/schema/parquet/stage/parquet_s3.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/stages/parquet_s3.sql rename to snowflake/objects/database/recover/schema/parquet/stage/parquet_s3.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql b/snowflake/objects/database/recover/schema/parquet/table/deploy.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/deploy.sql rename to snowflake/objects/database/recover/schema/parquet/table/deploy.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_customfields_symptoms_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_symptoms_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_customfields_symptoms_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_customfields_treatments_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_customfields_treatments_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_customfields_treatments_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/enrolledparticipants_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/enrolledparticipants_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitactivitylogs_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitactivitylogs_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitactivitylogs_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitdailydata_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdailydata_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitdailydata_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitdevices_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitdevices_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitdevices_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitecg_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitecg_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitecg_waveformsamples_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitecg_waveformsamples_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitecg_waveformsamples_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitintradaycombined_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitintradaycombined_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitintradaycombined_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitrestingheartrates_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitrestingheartrates_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitrestingheartrates_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitsleeplogs_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitsleeplogs_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/fitbitsleeplogs_sleeplogdetails_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/fitbitsleeplogs_sleeplogdetails_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/fitbitsleeplogs_sleeplogdetails_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/googlefitsamples_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/googlefitsamples_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/googlefitsamples_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2activitysummaries_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2activitysummaries_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2activitysummaries_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2electrocardiogram_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2electrocardiogram_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2electrocardiogram_subsamples_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2electrocardiogram_subsamples_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2electrocardiogram_subsamples_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2heartbeat_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2heartbeat_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2heartbeat_subsamples_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2heartbeat_subsamples_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2heartbeat_subsamples_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2samples_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2samples_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2samples_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2statistics_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2statistics_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2statistics_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2workouts_events_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_events_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2workouts_events_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/healthkitv2workouts_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/healthkitv2workouts_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/healthkitv2workouts_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/symptomlog_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/symptomlog_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/symptomlog_value_symptoms_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_symptoms_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/symptomlog_value_symptoms_parquet.sql diff --git a/snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql b/snowflake/objects/database/recover/schema/parquet/table/symptomlog_value_treatments_parquet.sql similarity index 100% rename from snowflake/objects/databases/recover/schemas/parquet/tables/symptomlog_value_treatments_parquet.sql rename to snowflake/objects/database/recover/schema/parquet/table/symptomlog_value_treatments_parquet.sql diff --git a/snowflake/objects/deploy.sql b/snowflake/objects/deploy.sql index cbcafd6..be247b0 100644 --- a/snowflake/objects/deploy.sql +++ b/snowflake/objects/deploy.sql @@ -70,7 +70,7 @@ CREATE GIT REPOSITORY IF NOT EXISTS recover_git_repository Deploy our database and all its child objects. */ EXECUTE IMMEDIATE - FROM @recover_git_repository/branches/&{ environment }/snowflake/objects/databases/recover/deploy.sql + FROM @recover_git_repository/branches/&{ environment }/snowflake/objects/database/recover/deploy.sql USING ( environment => $safe_environment_identifier, git_branch => '&{ environment }' From b2c57e446696f099c42e17781b65001c4fb540ee Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Wed, 3 Jul 2024 09:26:55 -0700 Subject: [PATCH 7/8] CREATE OR REPLACE git repository to ensure it is always up-to-date --- snowflake/objects/deploy.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snowflake/objects/deploy.sql b/snowflake/objects/deploy.sql index be247b0..7226535 100644 --- a/snowflake/objects/deploy.sql +++ b/snowflake/objects/deploy.sql @@ -62,7 +62,7 @@ USE DATABASE IDENTIFIER($database_identifier); Create an external stage over the RECOVER Git repository so that we can use EXECUTE IMMEDIATE FROM statements. */ -CREATE GIT REPOSITORY IF NOT EXISTS recover_git_repository +CREATE OR REPLACE GIT REPOSITORY recover_git_repository ORIGIN = 'https://github.com/Sage-Bionetworks/recover.git' API_INTEGRATION = RECOVER_GIT; From 559ac2dc41f1ade36f802e37be27e9b55916f03c Mon Sep 17 00:00:00 2001 From: Phil Snyder Date: Fri, 12 Jul 2024 15:31:13 -0700 Subject: [PATCH 8/8] qualify snowflake deployment for staging/main --- .../upload-and-deploy-to-prod-main.yaml | 50 +++++++++++++++++++ .github/workflows/upload-and-deploy.yaml | 9 +--- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/upload-and-deploy-to-prod-main.yaml b/.github/workflows/upload-and-deploy-to-prod-main.yaml index 10cc6d2..5f89978 100644 --- a/.github/workflows/upload-and-deploy-to-prod-main.yaml +++ b/.github/workflows/upload-and-deploy-to-prod-main.yaml @@ -88,6 +88,56 @@ jobs: Payload: '{"RequestType": "Create"}' LogType: Tail + deploy-snowflake-main: + name: Deploy Snowflake resources + needs: sceptre-deploy-main + runs-on: ubuntu-latest + env: + PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }} + steps: + - uses: actions/checkout@v3 + + - name: Configure Snowflake connection + run: | + # Create temporary files for config.toml and our private key + config_file=$(mktemp) + private_key_file=$(mktemp) + + # Write to the private key file + echo "${{ secrets.SNOWFLAKE_PRIVATE_KEY }}" > $private_key_file + + # Write to config.toml file + echo 'default_connection_name = "recover"' >> $config_file + echo '[connections.recover]' >> $config_file + echo "account = \"${{ vars.SNOWFLAKE_ACCOUNT }}\"" >> $config_file + echo "user = \"${{ vars.SNOWFLAKE_USER }}\"" >> $config_file + echo "role = \"${{ vars.SNOWFLAKE_ROLE }}\"" >> $config_file + echo 'authenticator = "SNOWFLAKE_JWT"' >> $config_file + echo "private_key_path = \"$private_key_file\"" >> $config_file + + # Write config.toml path to global environment + echo "SNOWFLAKE_CONFIG_PATH=$config_file" >> $GITHUB_ENV + + - name: Configuration file information + run: | + echo "Snowflake configuration is located at $SNOWFLAKE_CONFIG_PATH" + cat $SNOWFLAKE_CONFIG_PATH + + - name: Install Snowflake CLI + uses: Snowflake-Labs/snowflake-cli-action@v1 + with: + default-config-file-path: ${{ env.SNOWFLAKE_CONFIG_PATH }} + + - name: Test Snowflake connection + run: | + snow --version + snow connection test + + - name: Deploy Snowflake objects + run: | + snow sql \ + -D "environment=main" \ + -f snowflake/objects/deploy.sql sts-access-test: name: Runs STS access tests on prod synapse folders diff --git a/.github/workflows/upload-and-deploy.yaml b/.github/workflows/upload-and-deploy.yaml index eae16a5..9501ac8 100755 --- a/.github/workflows/upload-and-deploy.yaml +++ b/.github/workflows/upload-and-deploy.yaml @@ -32,14 +32,13 @@ jobs: runs-on: ubuntu-latest env: PRIVATE_KEY_PASSPHRASE: ${{ secrets.SNOWFLAKE_PRIVATE_KEY_PASSPHRASE }} + SNOWFLAKE_ENVIRONMENT: ${{ github.ref_name == 'main' && 'staging' || github.ref_name }} steps: - uses: actions/checkout@v3 - name: Configure Snowflake connection run: | # Create temporary files for config.toml and our private key - #mkdir ~/.snowflake - #config_file="~/.snowflake/config.toml" config_file=$(mktemp) private_key_file=$(mktemp) @@ -76,7 +75,7 @@ jobs: - name: Deploy Snowflake objects run: | snow sql \ - -D "environment=$(git rev-parse --abbrev-ref HEAD)" \ + -D "environment=$SNOWFLAKE_ENVIRONMENT" \ -f snowflake/objects/deploy.sql upload-files: @@ -153,7 +152,6 @@ jobs: --test-sts-permission read_write -v - pytest-docker: name: Build and push testing docker images to the pytest ECR repository. needs: pre-commit @@ -209,7 +207,6 @@ jobs: ecr-username: ${{ steps.login-ecr.outputs[steps.ecr.outputs.username-key] }} ecr-password: ${{ steps.login-ecr.outputs[steps.ecr.outputs.password-key] }} - glue-unit-tests: name: Run Pytest unit tests for AWS glue needs: pytest-docker @@ -260,7 +257,6 @@ jobs: su - glue_user --command "cd $GITHUB_WORKSPACE && python3 -m pytest tests/test_json_to_parquet.py --namespace $NAMESPACE -v" - sceptre-deploy-develop: name: Deploys branch using sceptre runs-on: ubuntu-latest @@ -344,7 +340,6 @@ jobs: --bucket $DEV_INTERMEDIATE_BUCKET --bucket_prefix "${{ env.NAMESPACE }}/json/" - integration-test-develop: name: Triggers ETL workflow with S3 test files runs-on: ubuntu-latest