|
1 | | ---- |
2 | | -apiVersion: v1 |
3 | | -kind: ConfigMap |
4 | | -metadata: |
5 | | - name: simple-connect-app |
6 | | - labels: |
7 | | - stackable.tech/vendor: Stackable |
8 | | -data: |
9 | | - simple-connect-app.py: | |
10 | | - import sys |
11 | | - |
12 | | - from pyspark.sql import SparkSession |
13 | | - from pyspark.sql.types import * |
14 | | - |
15 | | - remote = sys.argv[1] |
16 | | - spark = (SparkSession.builder |
17 | | - .remote(remote) |
18 | | - .appName("simple-connect-app") |
19 | | - .getOrCreate()) |
20 | | - |
21 | | - schema = StructType([ |
22 | | - StructField("id", LongType(), True), |
23 | | - StructField("data", StringType(), True) |
24 | | - ]) |
25 | | - |
26 | | - |
27 | | - # create table |
28 | | - df = spark.createDataFrame([], schema) |
29 | | - df.writeTo("local.db.table").create() |
30 | | - |
31 | | - # append to table |
32 | | - data = [ |
33 | | - (1,"one"), |
34 | | - (2,"two"), |
35 | | - (3,"three"), |
36 | | - (4,"four") |
37 | | - ] |
38 | | - |
39 | | - df = spark.createDataFrame(data, schema) |
40 | | - df.writeTo("local.db.table").append() |
41 | | - |
42 | 1 | --- |
43 | 2 | apiVersion: batch/v1 |
44 | 3 | kind: Job |
|
51 | 10 | spec: |
52 | 11 | restartPolicy: OnFailure |
53 | 12 | activeDeadlineSeconds: 100 |
54 | | - volumes: |
55 | | - - name: script |
56 | | - configMap: |
57 | | - name: simple-connect-app |
58 | 13 | containers: |
59 | 14 | - name: simple-connect-app |
60 | 15 | {% if test_scenario['values']['spark-connect-client'].find(",") > 0 %} |
|
63 | 18 | image: oci.stackable.tech/sdp/spark-connect-client:{{ test_scenario['values']['spark-connect-client'] }}-stackable0.0.0-dev |
64 | 19 | {% endif %} |
65 | 20 | imagePullPolicy: IfNotPresent |
66 | | - # |
67 | | - # TODO: cannot use the PySpark job from the ConfigMap because it breaks |
68 | | - # with a "iceberg.SparkWrite$WriterFactory" ClassNotfoundException. |
69 | | - # Use the app bundled within spark-connect-client instead |
70 | | - # "/app/simple-connect-app.py", |
71 | | - # |
72 | 21 | command: |
73 | 22 | [ |
74 | 23 | "/usr/bin/python", |
|
82 | 31 | requests: |
83 | 32 | cpu: 200m |
84 | 33 | memory: 128Mi |
85 | | - volumeMounts: |
86 | | - - name: script |
87 | | - mountPath: /app |
0 commit comments