-
Notifications
You must be signed in to change notification settings - Fork 78
Improve oracle support in reconcile #2081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+427
−45
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b1ac4eb
fix oracle jdbc url
m-abulazm 95e4fdc
add oracle and snowflake jars to local spark setup
m-abulazm c4a2ea1
add base for read schema integration specs
m-abulazm b5f8100
use localhost for `test_oracle_read_schema_happy`
m-abulazm 6e3ddb7
fix schema compare for oracle and snowflake
m-abulazm 2c2295d
add oracle recon test
m-abulazm 73f0230
fix oracle transformations and hashing
m-abulazm fc43b96
improve recon logging
m-abulazm ab07c04
improve oracle integration test
m-abulazm 6f937a6
fmt
m-abulazm fa6f93b
fix outdated specs
m-abulazm bfffbfc
add error handling in setup oracle spark infra
m-abulazm e88fa50
use correct oracle jdbc driver class instead of deprecated one
m-abulazm 2222c96
fix outdated spec
m-abulazm 5aba442
add reading secrets from env getter for iontegration specs
m-abulazm fa23add
Merge branch 'main' into fix/recon/oracle
m-abulazm e1b5a83
Merge branch 'main' into fix/recon/oracle
m-abulazm 47ca8e8
use `row` reconcile to catch hashing inconsistencies
m-abulazm d8266bd
add setup oracle script
m-abulazm fa8a022
productionize oracle setup
m-abulazm 4f1dec0
Merge branch 'main' into fix/recon/oracle
m-abulazm 7edda10
add test to improve coverage
m-abulazm 1dd8fa4
remove value error check as type checker solves it
m-abulazm 243de22
one more coverage trick
m-abulazm 493f9ec
fmt
m-abulazm 12ea4ad
fix oracle url bug
m-abulazm 0b09ea1
Merge branch 'main' into fix/recon/oracle
m-abulazm eaa68ad
Merge branch 'main' into fix/recon/oracle
m-abulazm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| #!/usr/bin/env bash | ||
| set -Eeuo pipefail | ||
|
|
||
| # Config | ||
| ORACLE_CONTAINER="${ORACLE_CONTAINER:-oracle-free}" | ||
| ORACLE_IMAGE="${ORACLE_IMAGE:-container-registry.oracle.com/database/free:latest-lite}" | ||
| ORACLE_PORT="${ORACLE_PORT:-1521}" | ||
| ORACLE_PWD="${ORACLE_PWD:?export ORACLE_PWD for SYS}" | ||
| ORACLE_SID="${ORACLE_SID:-FREEPDB1}" | ||
|
|
||
| # Dependencies | ||
| command -v docker >/dev/null || { echo "Docker not installed" >&2; exit 2; } | ||
|
|
||
| # Image present? | ||
| docker image inspect "${ORACLE_IMAGE}" >/dev/null 2>&1 || docker pull "${ORACLE_IMAGE}" | ||
|
|
||
| # Start container if needed | ||
| if docker ps --format '{{.Names}}' | grep -qx "${ORACLE_CONTAINER}"; then | ||
| : | ||
| elif docker ps -a --format '{{.Names}}' | grep -qx "${ORACLE_CONTAINER}"; then | ||
| docker start "${ORACLE_CONTAINER}" >/dev/null | ||
| else | ||
| docker run --name "${ORACLE_CONTAINER}" \ | ||
| -p "${ORACLE_PORT}:1521" \ | ||
| -e ORACLE_PWD="${ORACLE_PWD}" \ | ||
| -d "${ORACLE_IMAGE}" >/dev/null | ||
| echo "Starting Oracle container..." | ||
| fi | ||
|
|
||
| echo "Waiting up to 5 minutes for Oracle to be healthy..." | ||
| MAX_WAIT=300; WAIT_INTERVAL=5; waited=0 | ||
| while :; do | ||
| state="$(docker inspect -f '{{.State.Health.Status}}' "${ORACLE_CONTAINER}" 2>/dev/null || true)" | ||
| echo "health=${state:-unknown} waited=${waited}s" | ||
| [[ "$state" == "healthy" ]] && break | ||
| (( waited >= MAX_WAIT )) && { echo "ERROR: Oracle not healthy in 300s" >&2; exit 1; } | ||
| sleep "$WAIT_INTERVAL"; waited=$((waited + WAIT_INTERVAL)) | ||
| done | ||
| echo "Oracle is fully started." | ||
|
|
||
| # SQL bootstrap as SYSDBA, target SYSTEM schema | ||
| docker exec -i "${ORACLE_CONTAINER}" bash -lc \ | ||
| "sqlplus -L -s 'sys/${ORACLE_PWD}@localhost:${ORACLE_PORT}/${ORACLE_SID} as sysdba'" <<'SQL' | ||
| WHENEVER SQLERROR EXIT SQL.SQLCODE | ||
| SET ECHO ON FEEDBACK ON PAGESIZE 200 LINESIZE 32767 SERVEROUTPUT ON | ||
|
|
||
| -- reconcile queries executes DBMS_CRYPTO | ||
| GRANT EXECUTE ON DBMS_CRYPTO TO SYSTEM; | ||
|
|
||
| -- work in SYSTEM, not SYS | ||
| ALTER SESSION SET CURRENT_SCHEMA=SYSTEM; | ||
|
|
||
| -- create table if not exists (guard ORA-00955) | ||
| BEGIN | ||
| EXECUTE IMMEDIATE q'[ | ||
| CREATE TABLE SOURCE_TABLE ( | ||
| ID NUMBER(15,0), | ||
| DESCR CHAR(30 CHAR), | ||
| YEAR NUMBER(4,0), | ||
| DATEE DATE, | ||
| CONSTRAINT PK_SOURCE_TABLE PRIMARY KEY (ID) | ||
| ) | ||
| ]'; | ||
| EXCEPTION | ||
| WHEN OTHERS THEN | ||
| IF SQLCODE != -955 THEN RAISE; END IF; | ||
| END; | ||
| / | ||
|
|
||
| -- truncate if exists | ||
| DECLARE n INTEGER; | ||
| BEGIN | ||
| SELECT COUNT(*) INTO n FROM USER_TABLES WHERE TABLE_NAME='SOURCE_TABLE'; | ||
| IF n=1 THEN EXECUTE IMMEDIATE 'TRUNCATE TABLE SOURCE_TABLE'; END IF; | ||
| END; | ||
| / | ||
|
|
||
| -- idempotent load | ||
| MERGE INTO SOURCE_TABLE t | ||
| USING ( | ||
| SELECT 1001 ID, 'Cycle 1' DESCR, 2025 YEAR, DATE '2025-01-01' DATEE FROM DUAL UNION ALL | ||
| SELECT 1002, 'Cycle 2', 2025, DATE '2025-02-01' FROM DUAL UNION ALL | ||
| SELECT 1003, 'Cycle 3', 2025, DATE '2025-03-01' FROM DUAL UNION ALL | ||
| SELECT 1004, 'Cycle 4', 2025, DATE '2025-04-15' FROM DUAL UNION ALL | ||
| SELECT 1005, 'Cycle 5', 2025, DATE '2025-05-01' FROM DUAL | ||
| ) s | ||
| ON (t.ID = s.ID) | ||
| WHEN MATCHED THEN UPDATE SET t.DESCR = RPAD(s.DESCR,30), t.YEAR = s.YEAR, t.DATEE = s.DATEE | ||
| WHEN NOT MATCHED THEN INSERT (ID, DESCR, YEAR, DATEE) | ||
| VALUES (s.ID, RPAD(s.DESCR,30), s.YEAR, s.DATEE); | ||
|
|
||
| COMMIT; | ||
| SQL | ||
|
|
||
| echo "Oracle DDL/DML completed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.