matrixone-python-sdk 0.1.4__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,39 +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
- Get all secondary index table names for a given table in the current database (async version).
2559
+ Get all secondary index table names for a given table (async version).
2560
+
2561
+ This includes both regular secondary indexes (MULTIPLE type) and UNIQUE indexes.
2560
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
- # Get current database from connection params
2577
- database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
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
2578
2585
 
2579
- sql, params = build_get_index_tables_sql(table_name, database)
2586
+ sql, params = build_get_index_tables_sql(table_name, database_name)
2580
2587
  result = await self.execute(sql, params)
2581
2588
  return [row[0] for row in result.fetchall()]
2582
2589
 
2583
- 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]:
2584
2593
  """
2585
- Get the physical table name of a secondary index by its index name in the current database (async version).
2594
+ Get the physical table name of a secondary index by its index name (async version).
2586
2595
 
2587
2596
  Args:
2588
2597
  table_name: Name of the table
2589
2598
  index_name: Name of the secondary index
2599
+ database_name: Name of the database (optional). If None, uses the current database.
2590
2600
 
2591
2601
  Returns:
2592
2602
  Physical table name of the secondary index, or None if not found
@@ -2595,15 +2605,21 @@ class AsyncClient(BaseMatrixOneClient):
2595
2605
 
2596
2606
  >>> async with AsyncClient() as client:
2597
2607
  ... await client.connect(host='localhost', port=6001, user='root', password='111', database='test')
2608
+ ... # Use current database
2598
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
+ ... )
2599
2614
  ... print(index_table)
2600
2615
  """
2601
2616
  from .index_utils import build_get_index_table_by_name_sql
2602
2617
 
2603
- # Get current database from connection params
2604
- database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
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
2605
2621
 
2606
- sql, params = build_get_index_table_by_name_sql(table_name, index_name, database)
2622
+ sql, params = build_get_index_table_by_name_sql(table_name, index_name, database_name)
2607
2623
  result = await self.execute(sql, params)
2608
2624
  row = result.fetchone()
2609
2625
  return row[0] if row else None