-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-databricks-delta.sh
More file actions
executable file
·64 lines (54 loc) · 2.01 KB
/
Copy pathdeploy-databricks-delta.sh
File metadata and controls
executable file
·64 lines (54 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -euo pipefail
if [[ "$#" -ne 2 ]]; then
echo "usage: $0 <profile> <target>" >&2
exit 1
fi
profile="$1"
target="$2"
bundle_engine="${DATABRICKS_BUNDLE_ENGINE:-direct}"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
bundle_root="$repo_root/platform/databricks/delta"
read_env_file_value() {
local key="$1"
local env_file="$repo_root/.env"
if [[ ! -f "$env_file" ]]; then
return 1
fi
local line
line="$(grep -E "^${key}=" "$env_file" | tail -n 1 || true)"
if [[ -z "$line" ]]; then
return 1
fi
printf '%s' "${line#*=}"
}
deployment_url="${CONVEX_DEPLOYMENT_URL:-$(read_env_file_value CONVEX_DEPLOYMENT_URL || true)}"
if [[ -z "$deployment_url" ]]; then
echo "CONVEX_DEPLOYMENT_URL is required" >&2
exit 1
fi
source_id="${CONVEX_SOURCE_ID:-$deployment_url}"
table_name="${CONVEX_TABLE_NAME:-}"
secret_scope="${DATABRICKS_DELTA_SECRET_SCOPE:-convex-streaming-olap-export}"
secret_key="${DATABRICKS_DELTA_SECRET_KEY:-convex-deploy-key}"
catalog="${DATABRICKS_DELTA_CATALOG:-workspace}"
control_schema="${DATABRICKS_DELTA_CONTROL_SCHEMA:-convex_streaming_olap_export_control}"
bronze_schema="${DATABRICKS_DELTA_BRONZE_SCHEMA:-convex_streaming_olap_export_bronze}"
checkpoint_table="${DATABRICKS_DELTA_CHECKPOINT_TABLE:-connector_checkpoint}"
"$repo_root/scripts/ensure-databricks-delta-secret.sh" "$profile" "$secret_scope" "$secret_key"
bundle_args=(
--var "convex_deployment_url=$deployment_url"
--var "convex_deploy_key_secret_scope=$secret_scope"
--var "convex_deploy_key_secret_key=$secret_key"
--var "source_id=$source_id"
--var "table_name=$table_name"
--var "catalog=$catalog"
--var "control_schema=$control_schema"
--var "bronze_schema=$bronze_schema"
--var "checkpoint_table=$checkpoint_table"
)
(
cd "$bundle_root"
DATABRICKS_BUNDLE_ENGINE="$bundle_engine" databricks bundle validate -p "$profile" -t "$target" "${bundle_args[@]}"
DATABRICKS_BUNDLE_ENGINE="$bundle_engine" databricks bundle deploy -p "$profile" -t "$target" "${bundle_args[@]}"
)