-
Notifications
You must be signed in to change notification settings - Fork 2
/
combined_example.sh
executable file
·183 lines (140 loc) · 3.94 KB
/
combined_example.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
# Prerequisites:
# 1. Download Spark 3.4.1 (Scala 2.12) and install it in /opt/spark/spark-3.4.1 or some other directory
# 2. At repo_root/pramen, run
# sbt -DSPARK_VERSION="3.4.1" ++2.12.19 assembly
# 3. Run
# ./examples/combined_example.sh
cd $(dirname $(readlink -f $0))
export SCALA_VERSION="2.12"
export SPARK_VERSION="3.3.2"
export PRAMEN_VERSION="1.5.1-SNAPSHOT"
# SPECIFY SPARK LOCATION
export SPARK_HOME="/opt/spark/spark-3.3.2"
# SPECIFY PRAMEN JAR LOCATION
RUNNER_JAR="../runner/target/scala-${SCALA_VERSION}/pramen-runner_${SCALA_VERSION}_${SPARK_VERSION}-${PRAMEN_VERSION}.jar"
EXTRAS_JAR="../extras/target/scala-${SCALA_VERSION}/pramen-extras_${SCALA_VERSION}_${SPARK_VERSION}-${PRAMEN_VERSION}.jar"
RUNNER_ABSOLUTE_PATH_JAR=$(readlink -f ${RUNNER_JAR})
EXTRAS_ABSOLUTE_PATH_JAR=$(readlink -f ${EXTRAS_JAR})
DATE=`date +%Y_%m_%d-%H_%M_%S`
ME=`basename "$0" .sh`
USER=`whoami`
export PRAMEN_TEMP_DIR="/tmp/pramen_example_${USER}"
set -euxo pipefail
# Ensure the default JDK is 1.8
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
## GENERATE CONFIG
rm -rf "${PRAMEN_TEMP_DIR}"
mkdir -p "${PRAMEN_TEMP_DIR}" || true
cd "$PRAMEN_TEMP_DIR"
cat <<EOT > pramen_example.conf
pramen {
environment.name = "DEV"
pipeline.name = "EXAMPLE"
parallel.tasks = 1
bookkeeping.enabled = false
temporary.directory = ${PRAMEN_TEMP_DIR}
}
mail {
# CHANGE THIS TO YOUR SMTP SERVER IF YOU WANT TO RECEIVE EMAIL NOTIFICATIONS
smtp.host = "some.sftp.server.com"
smtp.port = "25"
smtp.auth = "false"
smtp.starttls.enable = "false"
smtp.EnableSSL.enable = "false"
debug = "false"
send.from = "Pramen <pramen.noreply@absa.africa>"
# THE COMMA SEPARATED LIST OF EMAIL ADDRESSES
#send.to = "address@example.com"
}
# This is to run properly in local mode
spark.conf.option {
spark.ui.enabled = "false"
spark.driver.bindAddress = "127.0.0.1"
spark.driver.host = "127.0.0.1"
spark.sql.session.timeZone = "Africa/Johannesburg"
spark.sql.shuffle.partitions = "1"
}
pramen.metastore {
tables = [
{
name = "example_table1"
format = "delta"
path = ${PRAMEN_TEMP_DIR}"/metastore/example_table1"
}
]
}
pramen.sources = [
{
name = "my_source"
factory.class = "za.co.absa.pramen.core.source.SparkSource"
format = "csv"
has.information.date.column = false
option {
header = true
delimiter = ","
}
}
]
pramen.sinks = [
{
name = "my_sink"
factory.class = "za.co.absa.pramen.core.sink.SparkSink"
format = "parquet"
mode = "overwrite"
number.of.partitions = 1
save.empty = true
partition.by = [ pramen_info_date ]
}
]
pramen.operations = [
{
name = "Ingestion"
type = "ingestion"
schedule.type = "daily"
source = "my_source"
tables = [
{
input.path = ${PRAMEN_TEMP_DIR}"/landing/example_table1"
output.metastore.table = "example_table1"
source.schema = "id int, name string"
transformations = [
{ col = "test_column", expr = "'test'" }
]
}
]
},
{
name = "Sink"
type = "sink"
sink = "my_sink"
#disabled = "true"
schedule.type = "daily"
tables = [
{
input.metastore.table = "example_table1"
output.path = ${PRAMEN_TEMP_DIR}"/sink/example_table1"
}
]
}
]
EOT
## GENERATE DATA
mkdir -p "${PRAMEN_TEMP_DIR}/landing/example_table1" || true
TEMP_CSV="$PRAMEN_TEMP_DIR/example.csv"
cat <<EOT > "$TEMP_CSV"
id,name
1,John
2,Mary
3,ABC
4,XYZ
EOT
cp "${TEMP_CSV}" "${PRAMEN_TEMP_DIR}/landing/example_table1/"
## RUN PRAMEN
$SPARK_HOME/bin/spark-submit \
--master local \
--conf spark.sql.extensions=io.delta.sql.DeltaSparkSessionExtension \
--conf spark.sql.catalog.spark_catalog=org.apache.spark.sql.delta.catalog.DeltaCatalog \
--jars $EXTRAS_ABSOLUTE_PATH_JAR \
--class za.co.absa.pramen.runner.PipelineRunner \
$RUNNER_ABSOLUTE_PATH_JAR --workflow pramen_example.conf --override-log-level INFO $@