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

Specific integer types and limit-offset support #27

Merged
merged 14 commits into from
Feb 6, 2024

Conversation

LuckySting
Copy link
Contributor

Problem

Dialect don't support native usage of limit().offset() methods due to type collision: sqlalchemy by default provide all integer bound variables as Int64, when YQL requires UInt variable to be passed to LIMIT OFFSET.

In this PR

In this PR I add the optional type casting to the LIMIT OFFSET clause to allow native usage of SQLalchemy methods related to.

Bonus

Dialect was enriched with all integer YDB types.

@@ -87,15 +87,30 @@ def visit_FLOAT(self, type_: sa.FLOAT, **kw):
def visit_BOOLEAN(self, type_: sa.BOOLEAN, **kw):
Copy link
Member

Choose a reason for hiding this comment

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

I have a doubt about visit_uuid and implicit convert uuid to UTF8: YDB has own uuid type. Now it can't stored to a table, but it can be (and will sometime) in future. Then convert from uuid to UTF8 will see strange.

I suggest to not convert uuid to UTF-8 into SDK and suggest users to the conversion in customers code. It is simple as str(var)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed in offline: will solved in a separate PR

select._offset_clause, types.UInt64, skip_types=(types.UInt64, types.UInt32, types.UInt16, types.UInt8)
)
if select._limit_clause is None:
text += "\n LIMIT NULL"
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need explicit LIMIT NULL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed in offline: it is needed to use OFFSET without LIMIT

@rekby rekby merged commit db10250 into ydb-platform:main Feb 6, 2024
5 checks passed
@rekby rekby self-assigned this Feb 6, 2024
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.

2 participants