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

getting index type #352

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Bobako
Copy link

@Bobako Bobako commented Sep 15, 2023

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Метод session.describe_table возвращает в том числе объекты, описывающие индексы таблицы - TableIndex. Этот объект не содержит информации о типе индекса (синхронный или асинхронный), хотя эта информация есть в protobuf сообщении, на основе которого формируется объект.

Issue Number: #351

What is the new behavior?

TableIndex содержать поле type - enum, описывающий тип индекса.

@@ -301,6 +302,12 @@ def to_pb(self):
return self._pb


@enum.unique
class IndexType(enum.IntEnum):
SYNCHRONOUS = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use enum.auto() here

@@ -1337,6 +1344,10 @@ def async_bulk_upsert(self, table_path, rows, column_types, settings=None):
def _make_index_description(index):
result = TableIndex(index.name).with_index_columns(*tuple(col for col in index.index_columns))
result.status = IndexStatus(index.status)
if index.HasField("global_async_index"):
result.type = IndexType(IndexType.ASYNCHRONOUS)
Copy link
Contributor

Choose a reason for hiding this comment

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

no needs to IndexType(IndexType.ASYNCHRONOUS). IndexType.ASYNCHRONOUS/IndexType.SYNCHRONOUS close enough.

@@ -286,6 +286,7 @@ def __init__(self, name):
self.index_columns = []
# output only.
self.status = None
self.type = None
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this field also should be in the constructor

@Valeria1235
Copy link
Contributor

Привет! Спасибо за патч. Можешь, пожалуйста, ещё тестом это покрыть?)

@LuckySting
Copy link
Contributor

LuckySting commented Apr 4, 2024

@Valeria1235, Hi! I tried to use the same approach, but I get nither global_async_index nor global_index from the describe_table, it seems like the server doesn't set this "oneof" field at all. Could you check it, please

@Valeria1235
Copy link
Contributor

@Valeria1235, Hi! I tried to use the same approach, but I get nither global_async_index nor global_index from the describe_table, it seems like the server doesn't set this "oneof" field at all. Could you check it, please

Hi! I was just only reviewed this patch and as you can see there are no one tests cases. So perhaps it's no longer working or relevant.

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