-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vdk-oracle: escape special chars in column names
Why? Special characters in column names currently cause errors. They should be supported in case the plugin is used for tables with unorthodox column names What? Support special characters in oracle column names Refactor column caching logic Special chars are escaped as advised here https://docs.oracle.com/en/error-help/db/ora-00904/ How was this tested? Ran functional tests locally CI/CD What kind of change is this? Feature/non-breaking Signed-off-by: Dilyan Marinov <[email protected]> Export identifier normalization to separate function
- Loading branch information
Dilyan Marinov
committed
Jan 23, 2024
1 parent
9615fe8
commit ab3cd1c
Showing
10 changed files
with
307 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
4 changes: 4 additions & 0 deletions
4
.../tests/jobs/oracle-ingest-job-different-payloads-no-table-special-chars/00_drop_table.sql
This file contains 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,4 @@ | ||
begin | ||
execute immediate 'drop table test_table'; | ||
exception when others then if sqlcode <> -942 then raise; end if; | ||
end; |
58 changes: 58 additions & 0 deletions
58
...racle/tests/jobs/oracle-ingest-job-different-payloads-no-table-special-chars/10_ingest.py
This file contains 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,58 @@ | ||
# Copyright 2021-2024 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import datetime | ||
|
||
|
||
def run(job_input): | ||
payloads = [ | ||
{ | ||
"id": 0, | ||
}, | ||
{ | ||
"id": 1, | ||
"?str_data": "string", | ||
}, | ||
{ | ||
"id": 2, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
}, | ||
{ | ||
"id": 3, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
"%float_data": 1.2, | ||
}, | ||
{ | ||
"id": 4, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
"%float_data": 1.2, | ||
"^bool_data": True, | ||
}, | ||
{ | ||
"id": 5, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
"%float_data": 1.2, | ||
"^bool_data": True, | ||
"×tamp_data": datetime.datetime.utcfromtimestamp(1700554373), | ||
}, | ||
{ | ||
"id": 6, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
"%float_data": 1.2, | ||
}, | ||
{ | ||
"id": 7, | ||
"?str_data": "string", | ||
"@int_data": 12, | ||
"%float_data": 1.2, | ||
"^bool_data": True, | ||
}, | ||
] | ||
for payload in payloads: | ||
job_input.send_object_for_ingestion( | ||
payload=payload, destination_table="test_table" | ||
) |
4 changes: 4 additions & 0 deletions
4
...-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-no-table-special-chars/00_drop_table.sql
This file contains 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,4 @@ | ||
begin | ||
execute immediate 'drop table test_table'; | ||
exception when others then if sqlcode <> -942 then raise; end if; | ||
end; |
48 changes: 48 additions & 0 deletions
48
...s/vdk-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-no-table-special-chars/10_ingest.py
This file contains 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,48 @@ | ||
# Copyright 2021-2024 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import datetime | ||
from decimal import Decimal | ||
|
||
|
||
def run(job_input): | ||
col_names = [ | ||
"id", | ||
"@str_data", | ||
"%int_data", | ||
"*float*data*", | ||
"bool_data", | ||
"timestamp_data", | ||
"decimal_data", | ||
] | ||
row_data = [ | ||
[ | ||
0, | ||
"string", | ||
12, | ||
1.2, | ||
True, | ||
datetime.datetime.utcfromtimestamp(1700554373), | ||
Decimal(1.1), | ||
], | ||
[ | ||
1, | ||
"string", | ||
12, | ||
1.2, | ||
True, | ||
datetime.datetime.utcfromtimestamp(1700554373), | ||
Decimal(1.1), | ||
], | ||
[ | ||
2, | ||
"string", | ||
12, | ||
1.2, | ||
True, | ||
datetime.datetime.utcfromtimestamp(1700554373), | ||
Decimal(1.1), | ||
], | ||
] | ||
job_input.send_tabular_data_for_ingestion( | ||
rows=row_data, column_names=col_names, destination_table="test_table" | ||
) |
4 changes: 4 additions & 0 deletions
4
projects/vdk-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-special-chars/00_drop_table.sql
This file contains 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,4 @@ | ||
begin | ||
execute immediate 'drop table test_table'; | ||
exception when others then if sqlcode <> -942 then raise; end if; | ||
end; |
9 changes: 9 additions & 0 deletions
9
...cts/vdk-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-special-chars/10_create_table.sql
This file contains 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,9 @@ | ||
create table test_table ( | ||
id number, | ||
"@str_data" varchar2(255), | ||
"%int_data" number, | ||
"*float*data*" float, | ||
bool_data number(1), | ||
timestamp_data timestamp, | ||
decimal_data decimal(14,8), | ||
primary key(id)) |
20 changes: 20 additions & 0 deletions
20
projects/vdk-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-special-chars/20_ingest.py
This file contains 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,20 @@ | ||
# Copyright 2021-2024 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import datetime | ||
from decimal import Decimal | ||
|
||
|
||
def run(job_input): | ||
payload_with_types = { | ||
"id": 5, | ||
"@str_data": "string", | ||
"%int_data": 12, | ||
"*float*data*": 1.2, | ||
"bool_data": True, | ||
"timestamp_data": datetime.datetime.utcfromtimestamp(1700554373), | ||
"decimal_data": Decimal(0.1), | ||
} | ||
|
||
job_input.send_object_for_ingestion( | ||
payload=payload_with_types, destination_table="test_table" | ||
) |
2 changes: 2 additions & 0 deletions
2
projects/vdk-plugins/vdk-oracle/tests/jobs/oracle-ingest-job-special-chars/config.ini
This file contains 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,2 @@ | ||
[owner] | ||
team = test-team |
Oops, something went wrong.