|
| 1 | +source: '{my_source}' |
| 2 | +target: '{my_target}' |
| 3 | + |
| 4 | +defaults: |
| 5 | + mode: full-refresh |
| 6 | + |
| 7 | +hooks: |
| 8 | + start: |
| 9 | + - type: query |
| 10 | + connection: '{source.name}' |
| 11 | + query: | |
| 12 | + BEGIN |
| 13 | + EXECUTE IMMEDIATE 'DROP TABLE {env.schema}.CUSTOMERS_NOSCHEMA PURGE'; |
| 14 | + EXCEPTION |
| 15 | + WHEN OTHERS THEN |
| 16 | + IF SQLCODE != -942 THEN |
| 17 | + RAISE; |
| 18 | + END IF; |
| 19 | + END; |
| 20 | +
|
| 21 | + - type: query |
| 22 | + connection: '{source.name}' |
| 23 | + query: | |
| 24 | + CREATE TABLE {env.schema}.CUSTOMERS_NOSCHEMA ( |
| 25 | + id NUMBER, |
| 26 | + name VARCHAR2(50) |
| 27 | + ) |
| 28 | +
|
| 29 | + - type: query |
| 30 | + connection: '{source.name}' |
| 31 | + query: | |
| 32 | + INSERT INTO {env.schema}.CUSTOMERS_NOSCHEMA (id, name) VALUES (1, 'Alice'); |
| 33 | + INSERT INTO {env.schema}.CUSTOMERS_NOSCHEMA (id, name) VALUES (2, 'Bob'); |
| 34 | + INSERT INTO {env.schema}.CUSTOMERS_NOSCHEMA (id, name) VALUES (3, 'Carol'); |
| 35 | +
|
| 36 | + - type: query |
| 37 | + connection: '{target.name}' |
| 38 | + query: drop table if exists public.customers_noschema |
| 39 | + |
| 40 | + end: |
| 41 | + - type: query |
| 42 | + connection: '{target.name}' |
| 43 | + query: select * from public.customers_noschema order by id |
| 44 | + into: result |
| 45 | + |
| 46 | + - type: log |
| 47 | + message: | |
| 48 | + store.result => { pretty_table(store.result) } |
| 49 | +
|
| 50 | + # ensure all rows replicated with the bare (no-schema) stream name |
| 51 | + - type: check |
| 52 | + check: length(store.result) == 3 |
| 53 | + |
| 54 | + - type: check |
| 55 | + check: store.result[0].name == "Alice" |
| 56 | + |
| 57 | + - type: check |
| 58 | + check: store.result[2].name == "Carol" |
| 59 | + |
| 60 | + - type: query |
| 61 | + connection: '{source.name}' |
| 62 | + query: | |
| 63 | + BEGIN |
| 64 | + EXECUTE IMMEDIATE 'DROP TABLE {env.schema}.CUSTOMERS_NOSCHEMA PURGE'; |
| 65 | + EXCEPTION |
| 66 | + WHEN OTHERS THEN |
| 67 | + IF SQLCODE != -942 THEN |
| 68 | + RAISE; |
| 69 | + END IF; |
| 70 | + END; |
| 71 | +
|
| 72 | + - type: query |
| 73 | + connection: '{target.name}' |
| 74 | + query: drop table if exists public.customers_noschema |
| 75 | + |
| 76 | +# bare table name (no schema qualifier) — exercises the schema-injection path. |
| 77 | +# Sling must inject & case-normalize the connection's default schema so Oracle's |
| 78 | +# owner-qualified metadata lookup resolves the columns. |
| 79 | +# https://github.com/slingdata-io/sling-cli/issues/749 |
| 80 | +streams: |
| 81 | + CUSTOMERS_NOSCHEMA: |
| 82 | + object: public.customers_noschema |
| 83 | + |
| 84 | +env: |
| 85 | + schema: ${SCHEMA} |
| 86 | + my_source: ${SOURCE} |
| 87 | + my_target: ${TARGET} |
0 commit comments