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

Add table settings support #22

Merged
merged 7 commits into from
Jan 11, 2024
Merged

Conversation

ilchuk96
Copy link
Contributor

No description provided.

Copy link
Contributor

@LuckySting LuckySting left a comment

Choose a reason for hiding this comment

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

Almost done 🦕

@@ -343,7 +343,35 @@ def get_bind_types(


class YqlDDLCompiler(DDLCompiler):
pass
def post_create_table(self, table):
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick (blocking): Could you provide a typehint here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

pass
def post_create_table(self, table):
ydb_opts = table.dialect_options["ydb"]
with_content = []
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick (non-blocking) Usually in the compilers such variables are named "_clause". Up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed

@@ -343,7 +343,35 @@ def get_bind_types(


class YqlDDLCompiler(DDLCompiler):
pass
def post_create_table(self, table):
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (blocking) There are another table settings, for example, TTL, which may be rendered in the WITH clause. I suggest to move this code to the def render_table_partitioning_settings(self, table) -> List[str] and add call of the method to the post_create_table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Ivan Ilchuk added 2 commits December 20, 2023 17:25
@LuckySting
Copy link
Contributor

Looks good for me, let's remove "WIP" prefix

@ilchuk96 ilchuk96 changed the title WIP: add table settings support add table settings support Dec 21, 2023
@ilchuk96 ilchuk96 changed the title add table settings support Add table settings support Dec 21, 2023
)
table.create(connection)

session: ydb.Session = connection.connection.driver_connection.pool.acquire()
Copy link
Contributor

@LuckySting LuckySting Jan 8, 2024

Choose a reason for hiding this comment

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

nitpick: We have to return this session to the pool at the end, but it's not crucial in tests I think

Copy link
Member

Choose a reason for hiding this comment

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

It can be problem in tests too - pool has limited sessions (default 100), if the limit will be reached - code can't get new session.

It is not big problem in one place, but it will be problem in loops or if many tests will not return the session.
especially if reuse connection (and session pool) between tests.

It is better to fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added calling of delete() method for session

Copy link
Member

@rekby rekby left a comment

Choose a reason for hiding this comment

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

Hello @ilchuk96

Thanks for the work!

Can you fix the session leak?

And what about use protobuf constants instead of hardcoded calues (1,2) in tests?

)
table.create(connection)

session: ydb.Session = connection.connection.driver_connection.pool.acquire()
Copy link
Member

Choose a reason for hiding this comment

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

It can be problem in tests too - pool has limited sessions (default 100), if the limit will be reached - code can't get new session.

It is not big problem in one place, but it will be problem in loops or if many tests will not return the session.
especially if reuse connection (and session pool) between tests.

It is better to fix it

@pytest.mark.parametrize(
"auto_partitioning_by_size,res",
[
(None, 1),
Copy link
Member

Choose a reason for hiding this comment

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

Here and below:
What about import protobuf to tests and re-use constants from protobuf?

https://github.com/ydb-platform/ydb-api-protos/blob/42d87a682c672b758a6456a240eaa3e80db0a80a/protos/ydb_common.proto#L13-L13

instead of hard-code int values?
import protobuf is bad for public interface, but so-ok for tests and better (by my opinion) then hard-codede values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did I add it correctly?

from ydb._grpc.v4.protos import ydb_common_pb2
<...>
ydb_common_pb2.FeatureFlag.Status.ENABLED

Copy link
Member

@rekby rekby left a comment

Choose a reason for hiding this comment

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

Thanks for the work

@rekby rekby merged commit a3144d1 into ydb-platform:main Jan 11, 2024
5 checks passed
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