matrixone-python-sdk 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
matrixone/async_client.py CHANGED
@@ -2554,36 +2554,49 @@ class AsyncClient(BaseMatrixOneClient):
2554
2554
  except Exception as e:
2555
2555
  raise QueryError(f"Failed to get git version: {e}")
2556
2556
 
2557
- async def get_secondary_index_tables(self, table_name: str) -> List[str]:
2557
+ async def get_secondary_index_tables(self, table_name: str, database_name: str = None) -> List[str]:
2558
2558
  """
2559
2559
  Get all secondary index table names for a given table (async version).
2560
2560
 
2561
+ This includes both regular secondary indexes (MULTIPLE type) and UNIQUE indexes.
2562
+
2561
2563
  Args:
2562
2564
  table_name: Name of the table to get secondary indexes for
2565
+ database_name: Name of the database (optional). If None, uses the current database.
2563
2566
 
2564
2567
  Returns:
2565
- List of secondary index table names
2568
+ List of secondary index table names (includes both __mo_index_secondary_... and __mo_index_unique_... tables)
2566
2569
 
2567
2570
  Examples::
2568
2571
 
2569
2572
  >>> async with AsyncClient() as client:
2570
2573
  ... await client.connect(host='localhost', port=6001, user='root', password='111', database='test')
2574
+ ... # Use current database
2571
2575
  ... index_tables = await client.get_secondary_index_tables('cms_all_content_chunk_info')
2576
+ ... # Or specify database explicitly
2577
+ ... index_tables = await client.get_secondary_index_tables('cms_all_content_chunk_info', 'test')
2572
2578
  ... print(index_tables)
2573
2579
  """
2574
2580
  from .index_utils import build_get_index_tables_sql
2575
2581
 
2576
- sql, params = build_get_index_tables_sql(table_name)
2582
+ # Use provided database_name or get current database from connection params
2583
+ if database_name is None:
2584
+ database_name = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2585
+
2586
+ sql, params = build_get_index_tables_sql(table_name, database_name)
2577
2587
  result = await self.execute(sql, params)
2578
2588
  return [row[0] for row in result.fetchall()]
2579
2589
 
2580
- async def get_secondary_index_table_by_name(self, table_name: str, index_name: str) -> Optional[str]:
2590
+ async def get_secondary_index_table_by_name(
2591
+ self, table_name: str, index_name: str, database_name: str = None
2592
+ ) -> Optional[str]:
2581
2593
  """
2582
2594
  Get the physical table name of a secondary index by its index name (async version).
2583
2595
 
2584
2596
  Args:
2585
2597
  table_name: Name of the table
2586
2598
  index_name: Name of the secondary index
2599
+ database_name: Name of the database (optional). If None, uses the current database.
2587
2600
 
2588
2601
  Returns:
2589
2602
  Physical table name of the secondary index, or None if not found
@@ -2592,12 +2605,21 @@ class AsyncClient(BaseMatrixOneClient):
2592
2605
 
2593
2606
  >>> async with AsyncClient() as client:
2594
2607
  ... await client.connect(host='localhost', port=6001, user='root', password='111', database='test')
2608
+ ... # Use current database
2595
2609
  ... index_table = await client.get_secondary_index_table_by_name('cms_all_content_chunk_info', 'cms_id')
2610
+ ... # Or specify database explicitly
2611
+ ... index_table = await client.get_secondary_index_table_by_name(
2612
+ ... 'cms_all_content_chunk_info', 'cms_id', 'test'
2613
+ ... )
2596
2614
  ... print(index_table)
2597
2615
  """
2598
2616
  from .index_utils import build_get_index_table_by_name_sql
2599
2617
 
2600
- sql, params = build_get_index_table_by_name_sql(table_name, index_name)
2618
+ # Use provided database_name or get current database from connection params
2619
+ if database_name is None:
2620
+ database_name = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2621
+
2622
+ sql, params = build_get_index_table_by_name_sql(table_name, index_name, database_name)
2601
2623
  result = await self.execute(sql, params)
2602
2624
  row = result.fetchone()
2603
2625
  return row[0] if row else None