Skip to content
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

refactor(oracle): port to sqlglot #8020

Merged
merged 68 commits into from Jan 22, 2024

Conversation

gforsyth
Copy link
Member

No description provided.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

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

Generally speaking looks great 👌🏻

Just a few questions.

I will look into the impala/druid failures since they seem to be consistent (but are passing on upstream/the-epic-split)

ibis/backends/tests/test_client.py Show resolved Hide resolved
ibis/backends/tests/test_string.py Outdated Show resolved Hide resolved
ibis/backends/oracle/__init__.py Show resolved Hide resolved
if isinstance(node, sg.exp.Table):
return sg.table(node.name, quoted=True)
elif isinstance(node, sg.exp.Column):
return sg.column(col=node.name, quoted=True)
Copy link
Member

Choose a reason for hiding this comment

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

Oooh, I hadn't really thought about this but I suspect we should probably apply this transform in general to backends whose quoted value is True.

Copy link
Member

Choose a reason for hiding this comment

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

Anyway, follow-up fodder.

# artificially locked tables
cursor.close()
raise
df = OraclePandasData.convert_table(df, schema)
Copy link
Member

Choose a reason for hiding this comment

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

We have this method in many of the backends. Nothing to do here except note for a follow up to perhaps generalize a bit.

ibis/backends/oracle/compiler.py Outdated Show resolved Hide resolved
ibis/backends/oracle/compiler.py Outdated Show resolved Hide resolved
Comment on lines +43 to +51
def _datatype_sql(self: Oracle.Generator, expression: sge.DataType) -> str:
# Use this to handle correctly formatting timestamp precision
# e.g. TIMESTAMP (scale) WITH TIME ZONE vs. TIMESTAMP WITH TIME ZONE(scale)
if expression.is_type("timestamptz"):
for exp in expression.expressions:
if isinstance(exp, sge.DataTypeParam):
return f"TIMESTAMP ({self.sql(exp, 'this')}) WITH TIME ZONE"
return "TIMESTAMP WITH TIME ZONE"
return self.datatype_sql(expression)
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if there's a better way to do this, but the regular mapping in Oracle.Generator.TYPE_MAPPING didn't expose the scale parameter

Copy link
Member

Choose a reason for hiding this comment

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

At some point we should upstream the bug report to sqlglot

Copy link
Member Author

Choose a reason for hiding this comment

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

@gforsyth
Copy link
Member Author

Ok, I have this down to 3 failing tests locally. I've been staring at it for long enough that I'm not going to get anywhere else today. I'll pick it back up on Monday.

@gforsyth gforsyth marked this pull request as ready for review January 19, 2024 20:32
@cpcloud cpcloud added tes-required-for-release Things that must be addressed before *release* of `main` after merging in `the-epic-split` tes-required-for-merge Issues that must addressed before merging the-epic-split branch into main refactor Issues or PRs related to refactoring the codebase labels Jan 22, 2024
In ibis/backends/tests/error.py we define the fallback exception types
as `None` if they cannot be imported (because the parent package isn't
installed).

This can lead to passing a tuple of possible exceptions that looks like

```
raises=(ImpalaHiveServer2Error, None, OracleDatabaseError)
```

If this gets passed without filteing, then you can end up with a gnarly
internal pytest error.

To avoid this, we filter out any `None` we find in `raises` while
handling the custom pytest markers.
@gforsyth gforsyth merged commit 278c173 into ibis-project:the-epic-split Jan 22, 2024
49 checks passed
@gforsyth gforsyth deleted the oracle-sqlglot branch January 22, 2024 20:39
@cpcloud
Copy link
Member

cpcloud commented Jan 22, 2024

NICE

kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 1, 2024
kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 1, 2024
kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 1, 2024
kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 2, 2024
kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 2, 2024
kszucs pushed a commit to kszucs/ibis that referenced this pull request Feb 2, 2024
cpcloud pushed a commit to cpcloud/ibis that referenced this pull request Feb 4, 2024
cpcloud pushed a commit to cpcloud/ibis that referenced this pull request Feb 5, 2024
kszucs pushed a commit that referenced this pull request Feb 5, 2024
kszucs pushed a commit that referenced this pull request Feb 6, 2024
kszucs pushed a commit that referenced this pull request Feb 6, 2024
cpcloud pushed a commit to cpcloud/ibis that referenced this pull request Feb 12, 2024
cpcloud pushed a commit that referenced this pull request Feb 12, 2024
cpcloud pushed a commit to cpcloud/ibis that referenced this pull request Feb 12, 2024
cpcloud pushed a commit that referenced this pull request Feb 12, 2024
kszucs pushed a commit that referenced this pull request Feb 12, 2024
ncclementi pushed a commit to ncclementi/ibis that referenced this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oracle The Oracle backend refactor Issues or PRs related to refactoring the codebase tes-required-for-merge Issues that must addressed before merging the-epic-split branch into main tes-required-for-release Things that must be addressed before *release* of `main` after merging in `the-epic-split`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants