Compare commits
1 Commits
main
...
db-push-sc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f664314b29 |
@ -11,4 +11,5 @@ COPY . .
|
||||
RUN ls ./
|
||||
|
||||
# Set CMD to execute the symbolic link, making it look like block.py is the entry
|
||||
CMD ["python", "/app/block_wrapper.py"]
|
||||
CMD ["python", "/app/block_wrapper.py"]
|
||||
|
||||
|
||||
22
README.md
22
README.md
@ -1 +1,21 @@
|
||||
**Hello world!!!**
|
||||
# Block for inserting/upserting scores into the scores table
|
||||
|
||||
This block is responsible for inserting or updating score records in the `scores` table using the same database configuration as `db_push_v1`.
|
||||
|
||||
## Table DDL
|
||||
|
||||
The following DDL illustrates the `scores` table structure (Postgres style, conceptually compatible with DuckDB for tests):
|
||||
|
||||
```sql
|
||||
-- creating scores table
|
||||
CREATE TABLE IF NOT EXISTS scores (
|
||||
application_key TEXT PRIMARY KEY,
|
||||
application_timestamp TIMESTAMP NOT NULL,
|
||||
hd_score_m1 DOUBLE PRECISION NULL,
|
||||
hd_score_m2 DOUBLE PRECISION NULL,
|
||||
hd_score_iso_m2 DOUBLE PRECISION NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_scores_application_key ON scores(application_key);
|
||||
CREATE INDEX IF NOT EXISTS idx_scores_application_timestamp ON scores(application_timestamp);
|
||||
```
|
||||
|
||||
18
config.json
18
config.json
@ -1,6 +1,14 @@
|
||||
[
|
||||
{
|
||||
"namespace": "",
|
||||
"connectionId": ""
|
||||
}
|
||||
]
|
||||
{
|
||||
"namespace": "staging",
|
||||
"connectionId": "56be80f8-7139-466f-b883-e4a695812d52"
|
||||
},
|
||||
{
|
||||
"namespace": "production",
|
||||
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
|
||||
},
|
||||
{
|
||||
"namespace": "production-beta",
|
||||
"connectionId": "cf2344a8-28d3-4b38-9456-ba9e5c347bf5"
|
||||
}
|
||||
]
|
||||
22
main.sql
22
main.sql
@ -1 +1,21 @@
|
||||
Select * from dummy_table limit 10;
|
||||
INSERT INTO public.scores (
|
||||
application_key,
|
||||
application_timestamp,
|
||||
hd_score_m1,
|
||||
hd_score_m2,
|
||||
hd_score_iso_m2
|
||||
)
|
||||
VALUES (
|
||||
$application_key,
|
||||
$application_timestamp,
|
||||
$hd_score_m1,
|
||||
$hd_score_m2,
|
||||
$hd_score_iso_m2
|
||||
)
|
||||
ON CONFLICT (application_key)
|
||||
DO UPDATE
|
||||
SET application_timestamp = EXCLUDED.application_timestamp,
|
||||
hd_score_m1 = EXCLUDED.hd_score_m1,
|
||||
hd_score_m2 = EXCLUDED.hd_score_m2,
|
||||
hd_score_iso_m2 = EXCLUDED.hd_score_iso_m2;
|
||||
|
||||
|
||||
@ -1 +1,27 @@
|
||||
{}
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"application_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"application_timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"hd_score_m1": {
|
||||
"type": ["number", "null"]
|
||||
},
|
||||
"hd_score_m2": {
|
||||
"type": ["number", "null"]
|
||||
},
|
||||
"hd_score_iso_m2": {
|
||||
"type": ["number", "null"]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"application_key",
|
||||
"application_timestamp"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -1 +1,20 @@
|
||||
{}
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"result": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"error": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user