Skip to content

Oracle support#2349

Merged
paulteehan merged 52 commits into
v4from
obsl-591-core-add-oracledb-support2
Aug 6, 2025
Merged

Oracle support#2349
paulteehan merged 52 commits into
v4from
obsl-591-core-add-oracledb-support2

Conversation

@paulteehan

@paulteehan paulteehan commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

Oracle implementation in soda-core. Tests passing locally, I think CI may not be configured yet. Ready for review.

Still pending:

  • Update soda-library to match connection YAML
  • Add support and test in soda-extensions

@paulteehan paulteehan changed the title Initial oracle support Oracle support Jul 25, 2025
@paulteehan paulteehan mentioned this pull request Jul 25, 2025
@paulteehan
paulteehan requested a review from mivds July 28, 2025 16:41
@paulteehan paulteehan assigned Niels-b and unassigned Niels-b Jul 28, 2025
@paulteehan
paulteehan requested a review from Niels-b July 28, 2025 16:42
@paulteehan
paulteehan marked this pull request as ready for review August 4, 2025 10:10

@mivds mivds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! Noticed a few odd quirks though; I left a few questions/suggestions

Comment on lines +67 to +72
id
for id in [ # prefixes can be None if information schema is top-level, e.g. Oracle
*prefixes,
self.sql_dialect.schema_information_schema(),
]
if id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, wondering if we can't resolve this by passing prefixes=[] to MetadataColumnsQuery.__init__? Then we use the already available interface instead of adding hidden logic here

Comment thread soda-core/src/soda_core/common/statements/metadata_tables_query.py Outdated
self.sql_dialect.column_table_name(),
col
for col in [
self.sql_dialect.column_table_catalog(), # this could be None for some data sources e.g. Oracle

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an option to have this function return "NULL", i.e. SELECT NULL, schema_name, table_name FROM ...? That way we don't need to add conditionals here or in the result processing.

Comment thread soda-core/src/soda_core/common/data_source_connection.py Outdated
Comment on lines +8 to 9
# Attention, if dt does not have timezone info, Python will assume dt is in the local system timezone (e.g. UTC+1)
return dt.astimezone(timezone.utc).isoformat(timespec="seconds")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find with that comment. Out of scope for this PR, but I suspect this may not be the behavior we want.

Probably want to do something like this instead:

if dt.tzinfo is None:
  dt = dt.replace(tzinfo=timezone.utc)
return dt.isoformat(timespec="seconds")

That would interpret the timestamp as UTC if no timezone is provided (which is more reproducible than using the local timezone). Then formats to string including timezone, which may be UTC or a previously set timezone

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very big fan of this! Ran into issues with the "auto-conversion" that happens here.
With all the timezone stuff we're doing for this PR and for Oracle, I think we can definitely change it (if it doesn't break other things!!)

Comment thread soda-core/src/soda_core/common/sql_ast.py Outdated
Comment thread soda-core/src/soda_core/common/sql_dialect.py Outdated
Comment on lines +626 to +627
def sql_expr_timestamp_with_tz_literal(self, datetime_in_iso8601: str) -> str:
return self.sql_expr_timestamp_literal(datetime_in_iso8601)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure what the best approach is here. I fear this function as-is will be hard to use because you will always need to be aware of whether the datetime you have contains a timezone or not, and call the appropriate function. We could have a single function that detects if timezone is present and then acts accordingly. On the other hand that may lead to bugs because it works differently than expected.

I guess let's keep it as you've implemented it for now. We'll find out later on if there are places where we don't know which function to call.

Comment thread soda-tests/src/helpers/data_source_test_helper.py
Comment thread soda-tests/tests/features/test_schema_check.py Outdated
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2025

Copy link
Copy Markdown

@paulteehan
paulteehan merged commit cc98fa2 into v4 Aug 6, 2025
19 of 21 checks passed
@paulteehan
paulteehan deleted the obsl-591-core-add-oracledb-support2 branch August 6, 2025 18:13
nielsn pushed a commit that referenced this pull request Aug 8, 2025
* Initial oracle support

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* Added create_table to sql_ast

* Added insert into statements to sql_ast

* Added newlines to new statements so it's more readable

* Updated some sql ast stuff based on needs from soda-extensions

* Added drop table to the AST

* Add support for Oracle

* Code style updates

* Add support for Oracle

* Add support for Oracle

* Allow insert into using select statements

* Allow insert into using select statements

* Additional fixes to support Oracle

* Additional fixes to support Oracle

* Revert accidental changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix test

* fix package version

* Fix date formatting in sqlserver

* Fix date formatting in sqlserver

* Parse other type of connect string

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove oracle

* Clarify prefix joining

* Clarify prefix joining

* Refactor metadata queries

* Fix review comments

* Add comment

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add timestamp and timestamp_tz insert tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Test timestamp insert

* Extend test

* cleanup

* Fix failing tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niels Bylois <niels.bylois@soda.io>
nielsn added a commit that referenced this pull request Aug 8, 2025
* Cleanning up the DWH tables to add the failed scan rows table

* Sql dialect extensions for diagnostic warehouse

* Added sql dialect max length

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* - Align naming for `STAR` alias
- Remove `IN` for `STAR` because confusing
- Some TODO's for typing

* Align semicolon treatment in  `create_schema_if_not_exists_sql` with rest of codebase

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Oracle support, AST enhancements, timezone tests (#2349)

* Initial oracle support

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixes to and extensions to support OracleDB

* Added create_table to sql_ast

* Added insert into statements to sql_ast

* Added newlines to new statements so it's more readable

* Updated some sql ast stuff based on needs from soda-extensions

* Added drop table to the AST

* Add support for Oracle

* Code style updates

* Add support for Oracle

* Add support for Oracle

* Allow insert into using select statements

* Allow insert into using select statements

* Additional fixes to support Oracle

* Additional fixes to support Oracle

* Revert accidental changes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix test

* fix package version

* Fix date formatting in sqlserver

* Fix date formatting in sqlserver

* Parse other type of connect string

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove oracle

* Clarify prefix joining

* Clarify prefix joining

* Refactor metadata queries

* Fix review comments

* Add comment

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add timestamp and timestamp_tz insert tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Test timestamp insert

* Extend test

* cleanup

* Fix failing tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niels Bylois <niels.bylois@soda.io>

* Add new plugin stubs for request proposals (#2361)

* Add new plugin stubs for request proposals

* Add create schema support for DuckDB

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niels Nuyttens <niels@soda.io>
Co-authored-by: paulteehan <45394252+paulteehan@users.noreply.github.com>
Co-authored-by: Niels Bylois <niels.bylois@soda.io>
Co-authored-by: Lauren De bruyn <lauren@soda.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants