Skip to content

Commit 6bde6c9

Browse files
authored
#58: Added UDF script creation examples to user guide (#66)
1 parent f114a54 commit 6bde6c9

File tree

3 files changed

+70
-7
lines changed

3 files changed

+70
-7
lines changed

doc/changes/changes_3.0.1.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@
44

55
## Documentation
66

7+
* #58: Added UDF script creation examples to user guide
78
* #64: Fixed typo in connection definition example in user guide
9+
10+
## Dependency Updates
11+
12+
* Updated `com.exasol:exasol-testcontainers:3.4.0` to `3.4.1`
13+
* Updated `mysql:mysql-connector-java:8.0.22` to `8.0.23`
14+
* Updated `org.mockito:mockito-junit-jupiter:3.7.0` to `3.7.7`
15+
* Updated `com.exasol:error-code-crawler-maven-plugin:0.1.0` to `0.1.1`
16+
* Updated `org.codehaus.mojo:versions-maven-plugin:2.7` to `2.8.1`
17+
* Updated `org.jacoco:jacoco-maven-plugin:0.8.5` to `0.8.6`

doc/user_guide/user_guide.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,59 @@ Add `returnsTable()` to the builder if you want the script to return a table.
200200
201201
See section ["Running Scripts"](#executing-scripts) for information about executing scripts.
202202
203+
### Creating UDF Scripts
204+
205+
User defined function (UDF) scripts allow you to run external applications that are implemented using high-level languages such as Java, Python or Lua.
206+
207+
To create an UDF script you need the following:
208+
209+
* UDF script name
210+
* Programming Language
211+
* Input type — SCALAR or SET
212+
* Columns emitted as return type
213+
* Optional bucket filesystem content
214+
215+
For example, the following code:
216+
217+
```java
218+
final UdfScript udfScript = schema.createUdfBuilder("UDF_SCRIPT")
219+
.language(UdfScript.Language.JAVA)
220+
.inputType(UdfScript.InputType.SCALAR)
221+
.emits(new Column("COLUMN_NAME", "VARCHAR(2000)"))
222+
.bucketFsContent("com.exasol.script.UdfScript", "/buckets/bfsdefault/artifacts/udfscript-1.0.0.jar")
223+
.build()
224+
```
225+
226+
It creates the following UDF script:
227+
228+
```sql
229+
CREATE JAVA SCALAR SCRIPT UDF_SCRIPT(...) EMITS ("COLUMN_NAME" VARCHAR(2000)) AS
230+
%scriptclass com.exasol.script.UdfScript;
231+
%jar /buckets/bfsdefault/artifacts/udfscript-1.0.0.jar;
232+
/
233+
```
234+
235+
Similarly, the following code snippet:
236+
237+
```java
238+
final UdfScript udfScript = schema.createUdfBuilder("UDF_SCRIPT")
239+
.language(UdfScript.Language.PYTHON)
240+
.inputType(UdfScript.InputType.SET)
241+
.parameter("INPUT", "VARCHAR(256)")
242+
.emits(new Column("COLUMN_ONE", "VARCHAR(256)"), new Column("COLUMN_TWO", "VARCHAR(256)"))
243+
.content("print('Hello, World!')")
244+
.build();
245+
```
246+
247+
It creates the following Python UDF script:
248+
249+
```sql
250+
CREATE PYTHON SET SCRIPT UDF_SCRIPT("INPUT" VARCHAR(256))
251+
EMITS ("COLUMN_ONE" VARCHAR(256), "COLUMN_TWO" VARCHAR(256)) AS
252+
print('Hello, World!')
253+
/
254+
```
255+
203256
### Creating Adapter Scripts
204257
205258
Adapter Scripts are what drive Virtual Schema adapters. They are scoped inside a schema.

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<dependency>
7676
<groupId>mysql</groupId>
7777
<artifactId>mysql-connector-java</artifactId>
78-
<version>8.0.22</version>
78+
<version>8.0.23</version>
7979
<scope>runtime</scope>
8080
</dependency>
8181
<dependency>
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>com.exasol</groupId>
9494
<artifactId>exasol-testcontainers</artifactId>
95-
<version>3.4.0</version>
95+
<version>3.4.1</version>
9696
<scope>test</scope>
9797
</dependency>
9898
<dependency>
@@ -140,7 +140,7 @@
140140
<dependency>
141141
<groupId>org.mockito</groupId>
142142
<artifactId>mockito-junit-jupiter</artifactId>
143-
<version>3.7.0</version>
143+
<version>3.7.7</version>
144144
<scope>test</scope>
145145
</dependency>
146146
<dependency>
@@ -170,7 +170,7 @@
170170
<plugin>
171171
<groupId>org.jacoco</groupId>
172172
<artifactId>jacoco-maven-plugin</artifactId>
173-
<version>0.8.5</version>
173+
<version>0.8.6</version>
174174
<executions>
175175
<execution>
176176
<id>prepare-agent</id>
@@ -312,7 +312,7 @@
312312
<plugin>
313313
<groupId>org.codehaus.mojo</groupId>
314314
<artifactId>versions-maven-plugin</artifactId>
315-
<version>2.7</version>
315+
<version>2.8.1</version>
316316
<executions>
317317
<execution>
318318
<phase>package</phase>
@@ -393,7 +393,7 @@
393393
<plugin>
394394
<groupId>com.exasol</groupId>
395395
<artifactId>error-code-crawler-maven-plugin</artifactId>
396-
<version>0.1.0</version>
396+
<version>0.1.1</version>
397397
<executions>
398398
<execution>
399399
<goals>
@@ -434,4 +434,4 @@
434434
</plugins>
435435
</pluginManagement>
436436
</build>
437-
</project>
437+
</project>

0 commit comments

Comments
 (0)