Skip to content

Commit 7dd6749

Browse files
author
Olha Virolainen
authored
add new select action (#76)
* add new select action * deprecate old select action
1 parent 136d067 commit 7dd6749

File tree

9 files changed

+495
-79
lines changed

9 files changed

+495
-79
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
## 2.5.0 (October 1, 2021)
2+
3+
* Add New Select action
4+
* Deprecate old Select action
5+
16
## 2.4.5 (September 1, 2021)
7+
28
Open only one connection pool per one execution and reuse it
39

410
## 2.4.4 (August 12, 2021)
11+
512
* Remove dependencyCheckAnalyze task
613

714
## 2.4.3 (February 12, 2021)

README.md

Lines changed: 56 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,56 @@
1+
[![CircleCI](https://circleci.com/gh/elasticio/jdbc-component.svg?style=svg)](https://circleci.com/gh/elasticio/jdbc-component)
12
# JDBC-component
2-
3-
## Description
3+
## Table of Contents
4+
5+
* [General information](#general-information)
6+
* [Description](#description)
7+
* [Completeness Matrix](#completeness-matrix)
8+
* [Credentials](#credentials)
9+
* [Triggers](#triggers)
10+
* [Select trigger](#select-trigger)
11+
* [Get Rows Polling trigger](#get-rows-polling-trigger)
12+
* [Actions](#actions)
13+
* [Execute custom query](#execute-custom-query)
14+
* [Select action](#select-action)
15+
* [Lookup Row By Primary Key](#lookup-row-by-primary-key)
16+
* [Insert action](#insert-action)
17+
* [Delete Row By Primary Key](#delete-row-by-primary-key)
18+
* [Execute stored procedure](#execute-stored-procedure)
19+
* [Upsert Row By Primary Key)](#upsert-row-by-primary-key)
20+
* [Known Limitations](#known-limitations)
21+
22+
Execute stored procedure
23+
24+
## General information
25+
### Description
426
This is an open source component for working with object-relational database management systems on [elastic.io platform](http://www.elastic.io "elastic.io platform").
527

628
### Completeness Matrix
729
![JDBC Component Completeness Matrix](https://user-images.githubusercontent.com/22715422/67289390-38dad900-f4e7-11e9-9a45-1c7775c9c7d5.png)
830

931
[JDBC Component Completeness Matrix](https://docs.google.com/spreadsheets/d/1sZr9ydJbMK8v-TguctmFDiqgjRKcrpbdj4CeFuZEkQU/edit?usp=sharing)
1032

11-
### Purpose
12-
With this component you will have following triggers:
13-
14-
``SELECT`` - this trigger will execute an [SQL](https://en.wikipedia.org/wiki/SQL "SQL") query that returns multiple results, it has limitations on the query and suited only for SELECT type of queries. The trigger will remember last execution timestamp and let you build queries on it.
15-
16-
``GET ROWS POLLING`` - this trigger will execute select query from specified table with simple criteria of selected datetime or timestamp table. The trigger will remember last execution timestamp and let you build queries on it.
17-
18-
Following actions are inside:
19-
20-
``SELECT`` - this action will execute an [SQL](https://en.wikipedia.org/wiki/SQL "SQL") query that returns multiple results, it has limitations on the query and suited only for SELECT type of queries.
21-
22-
``LOOKUP BY PRIMARY KEY`` - this action will execute select query from specified table, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"). The action returns only one result (a primary key is unique).
23-
24-
``UPSERT BY PRIMARY KEY`` - this action will execute select command from specified table, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"), and execute insert command by PRIMARY KEY with specified field, if result does not found, else - action will execute update command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
25-
26-
``DELETE BY PRIMARY KEY`` - this action will execute delete query from specified table, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"). The action returns an integer value that indicates the number of rows affected, the returned value can be 0 or 1 (a primary key is unique).
27-
28-
``INSERT`` - this action will execute insert query into the specified table. The action returns boolean value is execution insert successful or not.
29-
30-
### How works
31-
32-
### Requirements
33-
Before you can deploy any code into elastic.io **you must be a registered elastic.io platform user**. Please see our home page at [http://www.elastic.io](http://www.elastic.io) to learn how.
34-
35-
#### Environment variables
36-
For integration-testing is needed to specify following environment variables:
37-
1. Connection to MSSQL:
38-
- ``CONN_USER_MSSQL`` - user login
39-
- ``CONN_PASSWORD_MSSQL`` - user password
40-
- ``CONN_DBNAME_MSSQL`` - DataBase name
41-
- ``CONN_HOST_MSSQL`` - DataBase host
42-
- ``CONN_PORT_MSSQL`` - DataBase port
43-
2. Connection to MySQL:
44-
- ``CONN_USER_MYSQL`` - user login
45-
- ``CONN_PASSWORD_MYSQL`` - user password
46-
- ``CONN_DBNAME_MYSQL`` - DataBase name
47-
- ``CONN_HOST_MYSQL`` - DataBase host
48-
- ``CONN_PORT_MYSQL`` - DataBase port
49-
3. Connection to Oracle:
50-
- ``CONN_USER_ORACLE`` - user login
51-
- ``CONN_PASSWORD_ORACLE`` - user password
52-
- ``CONN_DBNAME_ORACLE`` - DataBase name
53-
- ``CONN_HOST_ORACLE`` - DataBase host
54-
- ``CONN_PORT_ORACLE`` - DataBase port
55-
4. Connection to PostgreSQL:
56-
- ``CONN_USER_POSTGRESQL`` - user login
57-
- ``CONN_PASSWORD_POSTGRESQL`` - user password
58-
- ``CONN_DBNAME_POSTGRESQL`` - DataBase name
59-
- ``CONN_HOST_POSTGRESQL`` - DataBase host
60-
- ``CONN_PORT_POSTGRESQL`` - DataBase port
61-
#### Others
6233
## Credentials
6334
You need to use following properties to configure credentials:
6435

65-
### DB Engine
66-
Choose one of existing database types:
36+
```DB Engine``` - Choose one of existing database types:
6737
![image](https://user-images.githubusercontent.com/40201204/43577772-6f85bdea-9655-11e8-96e1-368493a36c9d.png)
6838

69-
### Connection URI
70-
Provide hostname of the server, e.g. ``acme.com``
71-
### Connection port
72-
Optional field. Provide port of the server instance, as by default:
39+
```Connection URI``` - Provide hostname of the server, e.g. ``acme.com``
40+
41+
```Connection port``` - Optional field. Provide port of the server instance, as by default:
7342
- ``3306`` - MySQL
7443
- ``5432`` - PostgreSQL
7544
- ``1521`` - Oracle
7645
- ``1433`` - MSSQL
77-
### Database Name
78-
Provide name of database at the instance that you want to interact with.
79-
### User
80-
Provide a username that has permissions to interact with the Database.
81-
### Password
82-
Provide a password of the user that has permissions to interact with the Database.
83-
### Configuration properties
84-
Optional field. Provide a configuration properties for connections to the Database, e.g. ``useUnicode=true&serverTimezone=UTC``
46+
47+
```Database Name``` - Provide name of database at the instance that you want to interact with.
48+
49+
```User``` - Provide a username that has permissions to interact with the Database.
50+
51+
```Password``` - Provide a password of the user that has permissions to interact with the Database.
52+
53+
```Configuration properties``` - Optional field. Provide a configuration properties for connections to the Database, e.g. ``useUnicode=true&serverTimezone=UTC``
8554

8655
**Limitation:** `Configuration properties` value may not be checked during Credentials Verifacation, so in case of using this field make sure that it contains correct input.
8756

@@ -100,6 +69,7 @@ The format of ``Start Polling From (optional)`` field should be like ``yyyy-mm-d
10069
- ``mi`` - minute
10170
- ``ss`` - second
10271
- ``sss`` - millisecond (optional)
72+
-
10373
### Get Rows Polling trigger
10474
This trigger can polling data from provided table. As WHERE clause you can use column, which has datatype like DATE or TIMESTAMP.
10575
![image](https://user-images.githubusercontent.com/40201204/43591332-c99f6b3e-967b-11e8-8a77-bf8386e83d51.png)
@@ -137,7 +107,7 @@ Optional field, indicates the beginning time to start polling from (defaults to
137107
This action exists in JDBC component only for backward compatibility. New [**Select trigger**](#select-trigger) is recommended to use.
138108

139109
## Actions
140-
### Execute custom query action
110+
### Execute custom query
141111
Action to execute custom SQL query from provided request string.
142112

143113
**Note:** SQL request will be executed according to chosen database JDBC specification.
@@ -168,7 +138,8 @@ UPDATE stars SET radius = 5 WHERE id = 2;
168138
```
169139

170140
### Select action
171-
![image](https://user-images.githubusercontent.com/40201204/43592439-39ec5738-967e-11e8-8632-3655b08982d3.png)
141+
![image](https://user-images.githubusercontent.com/16806832/134408205-04b84670-c976-41e7-b805-faabff4ae1e5.png)
142+
172143
The action will execute an [SQL](https://en.wikipedia.org/wiki/SQL "SQL") query that can return multiple results, it has limitations on the query and suited only for SELECT type of queries.
173144
In SQL query you can use clause variables with specific data types.
174145
Internally we use prepared statements, so all incoming data is
@@ -201,9 +172,14 @@ Following types are supported:
201172
* ``float``
202173
* ``date``
203174

204-
![image](https://user-images.githubusercontent.com/40201204/43644974-332f2aa4-9739-11e8-8483-f7395e5d195d.png)
175+
![image](https://user-images.githubusercontent.com/16806832/134408591-b9faa51c-3b35-4cf2-992d-51dcd07c5cb5.png)
205176

206-
Checkbox ``Don't throw Error on an Empty Result`` allows to emit an empty response, otherwise you will get an error on empty response.
177+
Dropdown **Emit Behaviour** contains following possible options:
178+
* Fetch all - a single message with an array `results` containing all the objects (rows) will be emitted
179+
* Emit Individually - multiple messages (one message per one row) will be emitted
180+
* Expect Single - a single message with one result row will be emitted. If more than one row is returned the error will be thrown. A boolean input "Allow Zero Results" (defaults to `false`) appears at input metadata. If `false` - error will be thrown, else - the empty object will be emitted.
181+
182+
![image](https://user-images.githubusercontent.com/16806832/134408977-d4692d3f-e9fb-48be-9104-c4cb121accaa.png)
207183

208184
#### Input fields description
209185
Component supports dynamic incoming metadata - as soon as your query is in place it will be parsed and incoming metadata will be generated accordingly.
@@ -241,7 +217,7 @@ As output metadata, you will get execution insert result like:
241217
}
242218
```
243219

244-
### Delete Row By Primary Key action
220+
### Delete Row By Primary Key
245221
![image](https://user-images.githubusercontent.com/40201204/43592505-5b6bbfe8-967e-11e8-845e-2ce8ac707357.png)
246222
The action will execute delete query from a ``Table`` dropdown field, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"). The action returns count of affected rows.
247223
Checkbox ``Don't throw Error on an Empty Result`` allows to emit an empty response, otherwise you will get an error on empty response.
@@ -290,7 +266,7 @@ Component generates next metadata:
290266

291267
![image](https://user-images.githubusercontent.com/22715422/62056735-edd26200-b226-11e9-871e-0efc305d70b2.png)
292268

293-
### Upsert Row By Primary Key action
269+
### Upsert Row By Primary Key
294270
The action will execute ``SELECT`` command from a ``Tables`` dropdown field, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY"), and execute ``INSERT`` command by PRIMARY KEY with specified field, if result does not found, else - action will execute ``UPDATE`` command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
295271
1. Find and select jdbc-component in the component repository
296272
![image](https://user-images.githubusercontent.com/16806832/44981615-c70a9d80-af7b-11e8-8055-3b553abe8212.png)
@@ -328,11 +304,15 @@ As an input metadata you will get all fields of selected table. [PRIMARY KEY](ht
328304
![image](https://user-images.githubusercontent.com/16806832/44397461-1a76f780-a549-11e8-8247-9a6f9aa3f3b4.png)
329305

330306

331-
### Create or update record action (Deprecated)
307+
### Create or update record (Deprecated)
332308
This action exists in JDBC component only for backward compatibility.
333-
Please use [**Upsert row by primary key**](#upsert-row-by-primary-key-action) instead.
309+
Please use [**Upsert row by primary key**](#upsert-row-by-primary-key) instead.
310+
311+
### Select (Deprecated)
312+
This action exists in JDBC component only for backward compatibility.
313+
Please use [**Select action**](#select-action) instead.
334314

335-
## Current limitations
315+
## Known limitations
336316
1. Only tables with one [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key "PRIMARY KEY") is supported. You will see the message ``Table has not Primary Key. Should be one Primary Key
337317
``, if the selected table doesn't have a primary key. Also, you will see the message ``Composite Primary Key is not supported
338318
``, if the selected table has composite primary key.

component.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "Database",
33
"description": "Database JDBC connector",
4-
"version": "2.4.5",
4+
"version": "2.5.0",
55
"buildType": "docker",
66
"credentials": {
77
"verifier": "io.elastic.jdbc.JdbcCredentialsVerifier",
@@ -271,6 +271,7 @@
271271
"dynamicMetadata": "io.elastic.jdbc.providers.PrimaryColumnNamesProvider"
272272
},
273273
"selectAction": {
274+
"deprecated": true,
274275
"main": "io.elastic.jdbc.actions.SelectAction",
275276
"title": "Select",
276277
"description": "Executes a SELECT statement that fetches potentially multiple rows from the database",
@@ -289,6 +290,32 @@
289290
},
290291
"dynamicMetadata": "io.elastic.jdbc.providers.QueryColumnNamesProvider"
291292
},
293+
"newSelectAction": {
294+
"main": "io.elastic.jdbc.actions.NewSelectAction",
295+
"title": "Select Query",
296+
"description": "Executes a SELECT statement that fetches potentially multiple rows from the database",
297+
"fields": {
298+
"sqlQuery": {
299+
"viewClass": "TextAreaView",
300+
"label": "SQL Query",
301+
"required": true,
302+
"placeholder": "SELECT * FROM films WHERE watched = @watched:boolean AND created = @created:date",
303+
"note": "You can use parameters of message body as <i>@value:type</i>"
304+
},
305+
"emitBehaviour": {
306+
"label": "Emit Behaviour",
307+
"viewClass": "SelectView",
308+
"required": false,
309+
"prompt": "Default Emit Individually",
310+
"model": {
311+
"fetchAll": "Fetch All",
312+
"emitIndividually": "Emit Individually",
313+
"expectSingle": "Expect Single"
314+
}
315+
}
316+
},
317+
"dynamicMetadata": "io.elastic.jdbc.providers.QueryColumnNamesAndAllowsZeroResultsProvider"
318+
},
292319
"createOrUpdateRecord": {
293320
"main": "io.elastic.jdbc.actions.CreateOrUpdateRecord",
294321
"title": "Create or update record",
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Mon Sep 20 22:42:00 EEST 2021
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 commit comments

Comments
 (0)