Skip to content

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.

def visit_FLOAT(self, type_: sa.FLOAT, **kw):
return "FLOAT"

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
@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