matrixone-python-sdk 0.1.3__py3-none-any.whl → 0.1.4__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
@@ -2556,7 +2556,7 @@ class AsyncClient(BaseMatrixOneClient):
2556
2556
 
2557
2557
  async def get_secondary_index_tables(self, table_name: str) -> List[str]:
2558
2558
  """
2559
- Get all secondary index table names for a given table (async version).
2559
+ Get all secondary index table names for a given table in the current database (async version).
2560
2560
 
2561
2561
  Args:
2562
2562
  table_name: Name of the table to get secondary indexes for
@@ -2573,13 +2573,16 @@ class AsyncClient(BaseMatrixOneClient):
2573
2573
  """
2574
2574
  from .index_utils import build_get_index_tables_sql
2575
2575
 
2576
- sql, params = build_get_index_tables_sql(table_name)
2576
+ # Get current database from connection params
2577
+ database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2578
+
2579
+ sql, params = build_get_index_tables_sql(table_name, database)
2577
2580
  result = await self.execute(sql, params)
2578
2581
  return [row[0] for row in result.fetchall()]
2579
2582
 
2580
2583
  async def get_secondary_index_table_by_name(self, table_name: str, index_name: str) -> Optional[str]:
2581
2584
  """
2582
- Get the physical table name of a secondary index by its index name (async version).
2585
+ Get the physical table name of a secondary index by its index name in the current database (async version).
2583
2586
 
2584
2587
  Args:
2585
2588
  table_name: Name of the table
@@ -2597,7 +2600,10 @@ class AsyncClient(BaseMatrixOneClient):
2597
2600
  """
2598
2601
  from .index_utils import build_get_index_table_by_name_sql
2599
2602
 
2600
- sql, params = build_get_index_table_by_name_sql(table_name, index_name)
2603
+ # Get current database from connection params
2604
+ database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2605
+
2606
+ sql, params = build_get_index_table_by_name_sql(table_name, index_name, database)
2601
2607
  result = await self.execute(sql, params)
2602
2608
  row = result.fetchone()
2603
2609
  return row[0] if row else None
matrixone/client.py CHANGED
@@ -2615,7 +2615,7 @@ class Client(BaseMatrixOneClient):
2615
2615
 
2616
2616
  def get_secondary_index_tables(self, table_name: str) -> List[str]:
2617
2617
  """
2618
- Get all secondary index table names for a given table.
2618
+ Get all secondary index table names for a given table in the current database.
2619
2619
 
2620
2620
  Args:
2621
2621
  table_name: Name of the table to get secondary indexes for
@@ -2633,13 +2633,16 @@ class Client(BaseMatrixOneClient):
2633
2633
  """
2634
2634
  from .index_utils import build_get_index_tables_sql
2635
2635
 
2636
- sql, params = build_get_index_tables_sql(table_name)
2636
+ # Get current database from connection params
2637
+ database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2638
+
2639
+ sql, params = build_get_index_tables_sql(table_name, database)
2637
2640
  result = self.execute(sql, params)
2638
2641
  return [row[0] for row in result.fetchall()]
2639
2642
 
2640
2643
  def get_secondary_index_table_by_name(self, table_name: str, index_name: str) -> Optional[str]:
2641
2644
  """
2642
- Get the physical table name of a secondary index by its index name.
2645
+ Get the physical table name of a secondary index by its index name in the current database.
2643
2646
 
2644
2647
  Args:
2645
2648
  table_name: Name of the table
@@ -2658,7 +2661,10 @@ class Client(BaseMatrixOneClient):
2658
2661
  """
2659
2662
  from .index_utils import build_get_index_table_by_name_sql
2660
2663
 
2661
- sql, params = build_get_index_table_by_name_sql(table_name, index_name)
2664
+ # Get current database from connection params
2665
+ database = self._connection_params.get('database') if hasattr(self, '_connection_params') else None
2666
+
2667
+ sql, params = build_get_index_table_by_name_sql(table_name, index_name, database)
2662
2668
  result = self.execute(sql, params)
2663
2669
  row = result.fetchone()
2664
2670
  return row[0] if row else None
@@ -69,13 +69,13 @@ class ConnectionHook:
69
69
  event.listen(engine.sync_engine, "connect", self._on_connect_sync)
70
70
  event.listen(engine.sync_engine, "before_cursor_execute", self._on_before_cursor_execute)
71
71
  if hasattr(self._client_ref, 'logger'):
72
- self._client_ref.logger.info("Attached connection hook to async engine")
72
+ self._client_ref.logger.debug("Attached connection hook to async engine")
73
73
  else:
74
74
  # For sync engines, listen to both connect and before_cursor_execute events
75
75
  event.listen(engine, "connect", self._on_connect_sync)
76
76
  event.listen(engine, "before_cursor_execute", self._on_before_cursor_execute)
77
77
  if hasattr(self._client_ref, 'logger'):
78
- self._client_ref.logger.info("Attached connection hook to sync engine")
78
+ self._client_ref.logger.debug("Attached connection hook to sync engine")
79
79
 
80
80
  def _on_connect_sync(self, dbapi_connection, connection_record):
81
81
  """SQLAlchemy event handler for new connections (sync)"""
@@ -86,7 +86,7 @@ class ConnectionHook:
86
86
  try:
87
87
  # Log that the hook is being executed
88
88
  if hasattr(self._client_ref, 'logger'):
89
- self._client_ref.logger.info(f"Executing connection hook on new connection {conn_id}")
89
+ self._client_ref.logger.debug(f"Executing connection hook on new connection {conn_id}")
90
90
  # Pass the connection to avoid creating new connections
91
91
  self.execute_sync_with_connection(self._client_ref, dbapi_connection)
92
92
  self._executed_connections.add(conn_id)
@@ -104,7 +104,7 @@ class ConnectionHook:
104
104
  try:
105
105
  # Log that the hook is being executed
106
106
  if hasattr(self._client_ref, 'logger'):
107
- self._client_ref.logger.info(f"Executing connection hook on connection {conn_id}")
107
+ self._client_ref.logger.debug(f"Executing connection hook on connection {conn_id}")
108
108
  # Use the connection to avoid creating new connections
109
109
  self.execute_sync_with_connection(self._client_ref, conn.connection)
110
110
  self._executed_connections.add(conn_id)
@@ -212,7 +212,7 @@ class ConnectionHook:
212
212
  cursor = dbapi_connection.cursor()
213
213
  cursor.execute("SET experimental_ivf_index = 1")
214
214
  cursor.close()
215
- client.logger.info("✓ Enabled IVF vector operations")
215
+ client.logger.debug("✓ Enabled IVF vector operations")
216
216
  except Exception as e:
217
217
  client.logger.warning(f"Failed to enable IVF: {e}")
218
218
 
@@ -223,7 +223,7 @@ class ConnectionHook:
223
223
  cursor = dbapi_connection.cursor()
224
224
  cursor.execute("SET experimental_hnsw_index = 1")
225
225
  cursor.close()
226
- client.logger.info("✓ Enabled HNSW vector operations")
226
+ client.logger.debug("✓ Enabled HNSW vector operations")
227
227
  except Exception as e:
228
228
  client.logger.warning(f"Failed to enable HNSW: {e}")
229
229
 
@@ -234,7 +234,7 @@ class ConnectionHook:
234
234
  cursor = dbapi_connection.cursor()
235
235
  cursor.execute("SET experimental_fulltext_index = 1")
236
236
  cursor.close()
237
- client.logger.info("✓ Enabled fulltext search operations")
237
+ client.logger.debug("✓ Enabled fulltext search operations")
238
238
  except Exception as e:
239
239
  client.logger.warning(f"Failed to enable fulltext: {e}")
240
240
 
matrixone/index_utils.py CHANGED
@@ -19,43 +19,65 @@ Index utilities - Shared logic for secondary index operations
19
19
  from typing import List, Tuple
20
20
 
21
21
 
22
- def build_get_index_tables_sql(table_name: str) -> Tuple[str, Tuple]:
22
+ def build_get_index_tables_sql(table_name: str, database: str = None) -> Tuple[str, Tuple]:
23
23
  """
24
24
  Build SQL to get all secondary index table names for a given table.
25
25
 
26
26
  Args:
27
27
  table_name: Name of the table
28
+ database: Name of the database (optional, but recommended to avoid cross-database conflicts)
28
29
 
29
30
  Returns:
30
31
  Tuple of (sql, params)
31
32
  """
32
- sql = """
33
- SELECT DISTINCT index_table_name
34
- FROM mo_catalog.mo_indexes
35
- JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
36
- WHERE relname = ? AND type = 'MULTIPLE'
37
- """
38
- return sql, (table_name,)
39
-
40
-
41
- def build_get_index_table_by_name_sql(table_name: str, index_name: str) -> Tuple[str, Tuple]:
33
+ if database:
34
+ sql = """
35
+ SELECT DISTINCT index_table_name
36
+ FROM mo_catalog.mo_indexes
37
+ JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
38
+ WHERE relname = ? AND reldatabase = ? AND type = 'MULTIPLE'
39
+ """
40
+ return sql, (table_name, database)
41
+ else:
42
+ # Fallback to old behavior if database is not provided
43
+ sql = """
44
+ SELECT DISTINCT index_table_name
45
+ FROM mo_catalog.mo_indexes
46
+ JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
47
+ WHERE relname = ? AND type = 'MULTIPLE'
48
+ """
49
+ return sql, (table_name,)
50
+
51
+
52
+ def build_get_index_table_by_name_sql(table_name: str, index_name: str, database: str = None) -> Tuple[str, Tuple]:
42
53
  """
43
54
  Build SQL to get the physical table name of a secondary index by its index name.
44
55
 
45
56
  Args:
46
57
  table_name: Name of the table
47
58
  index_name: Name of the secondary index
59
+ database: Name of the database (optional, but recommended to avoid cross-database conflicts)
48
60
 
49
61
  Returns:
50
62
  Tuple of (sql, params)
51
63
  """
52
- sql = """
53
- SELECT DISTINCT index_table_name
54
- FROM mo_catalog.mo_indexes
55
- JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
56
- WHERE relname = ? AND name = ?
57
- """
58
- return sql, (table_name, index_name)
64
+ if database:
65
+ sql = """
66
+ SELECT DISTINCT index_table_name
67
+ FROM mo_catalog.mo_indexes
68
+ JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
69
+ WHERE relname = ? AND name = ? AND reldatabase = ?
70
+ """
71
+ return sql, (table_name, index_name, database)
72
+ else:
73
+ # Fallback to old behavior if database is not provided
74
+ sql = """
75
+ SELECT DISTINCT index_table_name
76
+ FROM mo_catalog.mo_indexes
77
+ JOIN mo_catalog.mo_tables ON mo_indexes.table_id = mo_tables.rel_id
78
+ WHERE relname = ? AND name = ?
79
+ """
80
+ return sql, (table_name, index_name)
59
81
 
60
82
 
61
83
  def build_verify_counts_sql(table_name: str, index_tables: List[str]) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrixone-python-sdk
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: A comprehensive Python SDK for MatrixOne database operations with vector search, fulltext search, and advanced features
5
5
  Home-page: https://github.com/matrixorigin/matrixone
6
6
  Author: MatrixOne Team
@@ -1,15 +1,15 @@
1
1
  matrixone/__init__.py,sha256=7bePzwzerZTiZIlbUT9zI_u4fp49DvQNcIqyiIvEVVs,3966
2
2
  matrixone/account.py,sha256=0r9xLNTiUfXa3xWZQUhEJ_uUcNp_gja-YulOR5iYDU4,24712
3
- matrixone/async_client.py,sha256=KKvWIzcV2PtwaFT31jgawRLt1CJhI_rePQdAs8xLzEc,155275
3
+ matrixone/async_client.py,sha256=yluma410CLUy3FhxMxeOm-5uhRwhD-ONzMIJd-dEuvg,155669
4
4
  matrixone/async_metadata_manager.py,sha256=W3TJBCy56diDPBzimpBImFrmf9DBc7iiS5CdBHLAh_Q,10232
5
5
  matrixone/async_orm.py,sha256=O4Rf85MnZg0_fuLvbHGfOPrHI2OLznYwLk9eam5J5ik,4864
6
6
  matrixone/async_vector_index_manager.py,sha256=fVnS00zgbUXw4YmZR-wRCzm541n30TLlmXXmXV34ELU,23134
7
7
  matrixone/base_client.py,sha256=PUhq0c7Si9OIk83B4ZZ73ozwaHDRZ1zi0Q94YixseqY,6952
8
- matrixone/client.py,sha256=bxdKUVTzo18yMDFmgcUdSIfoKozC-pfUOlKuWCwwGwI,187341
8
+ matrixone/client.py,sha256=NONid82vkq2GYWVfJqjHgFjeTBkXauEEvcoYtSoeuYs,187735
9
9
  matrixone/config.py,sha256=jrm1rLBhLWrX3dVdPx67sFaZ_9M8Vj4hImVrAmFaYbw,13917
10
- matrixone/connection_hooks.py,sha256=FrCGWipg5KUrdBt-cJMORaOUfoIqgSZNZCtDnn9la50,13531
10
+ matrixone/connection_hooks.py,sha256=5o7heheRQ8pLguoUQxEoo023519rT2-OhloPW-vORpE,13538
11
11
  matrixone/exceptions.py,sha256=VsGgESLl4vm5-9QbigyE5RTwFujyoYXhQuGhGKoujFw,1667
12
- matrixone/index_utils.py,sha256=ND_Md-mj1Yh8Qq4RGW5tYxwqkgwItkWzWDLL_SQ9AMI,3759
12
+ matrixone/index_utils.py,sha256=ofEm0PHKE4VIGuq4ymeJPtA5NvV1afwZfHPLN2bd6Dw,4862
13
13
  matrixone/logger.py,sha256=aZmetje_AqtyxFxsqZvp-3R68n8I_ldplRGfV2MHg48,26105
14
14
  matrixone/metadata.py,sha256=Yf0eJywe3BUqg6aEywSWh9neRcVsrgf6g-uaZFvqLOA,31707
15
15
  matrixone/moctl.py,sha256=b_qQPSK52JiyyUH4PYzAuhJPk8dAD6LRfT_sFGsf23o,6704
@@ -31,7 +31,7 @@ matrixone/sqlalchemy_ext/ivf_config.py,sha256=-esAijWMfyF1GUJivpZh-F4lvyKRmY8LYI
31
31
  matrixone/sqlalchemy_ext/table_builder.py,sha256=JVritBPnCXZt0eJUivDrmGdlpaYO-uL7i2n24HiarEE,12870
32
32
  matrixone/sqlalchemy_ext/vector_index.py,sha256=dasW3kT4f69io9y6DLQMarvf1FTbzh0UN-HALs0kBVs,55907
33
33
  matrixone/sqlalchemy_ext/vector_type.py,sha256=HaOJ9dRdW_yrecD9qGUucW9bMfM3zCxbDC-0Ca32Kmk,30669
34
- matrixone_python_sdk-0.1.3.dist-info/licenses/LICENSE,sha256=-PpUMwDyMyFlH9H7cnzkTh0Uo42tRvz43k7hnxe7G_I,11252
34
+ matrixone_python_sdk-0.1.4.dist-info/licenses/LICENSE,sha256=-PpUMwDyMyFlH9H7cnzkTh0Uo42tRvz43k7hnxe7G_I,11252
35
35
  tests/__init__.py,sha256=odB22tIaJIHSwRhumhDlQYD6Fug_C0opWa07dSKkeQs,694
36
36
  tests/offline/__init__.py,sha256=M13mz7gtVDS0_dJUW1EFyyiAGhEj282k3ia7eWA3dPs,703
37
37
  tests/offline/conftest.py,sha256=Mz_NT6GBOxqSZsSCR2SXe1pkSpLGKT2-ssWNHhh9xOg,2494
@@ -39,7 +39,7 @@ tests/offline/test_account.py,sha256=uCHKPOBGiJrpEwXdyF2CoNoS5yqxuyKJgLTPMvKZQbk
39
39
  tests/offline/test_async_client_query_comprehensive.py,sha256=HmLg8iYlD6l5K4lJN5VSXhJDtKGg17vym-9KaX6WDzY,45416
40
40
  tests/offline/test_basic.py,sha256=pVyPnidD5jIoC8_40U1iXND29399G-0O5e4itm-2uhc,1710
41
41
  tests/offline/test_case_sensitivity.py,sha256=aYlhA5F8RSlSy6wl3HWIrPylE3Z3eAUf4RWQohwD0eA,8715
42
- tests/offline/test_connection_hooks_offline.py,sha256=pMbkjiEdn5ShljuX8QZRVnsMQLbJxI43tfb0saohBRw,11678
42
+ tests/offline/test_connection_hooks_offline.py,sha256=mqnummeGGEvqeevG2R7-0VexnBquo4CJyTtmLhMa7Ps,11686
43
43
  tests/offline/test_dialect_schema_handling.py,sha256=WK22Cu3cI1uZ2RtmXmkwnWrYXrwMdcXkhqHTwp0Bqqo,24380
44
44
  tests/offline/test_explain_methods.py,sha256=QGSwqGGulZ-8e0pnshQ9A0JwC-CQZ6GcE7mkp_LIYIw,12683
45
45
  tests/offline/test_filter_logical_in.py,sha256=Qb-bJiy5lhQaVlTeVNVZ75v6Xyx4Qd2IS_faaxC4VUg,8967
@@ -118,8 +118,8 @@ tests/online/test_transaction_query_methods.py,sha256=VaPvHOYskwJVyM7lvVvBJ6Hqhd
118
118
  tests/online/test_unified_filter_online.py,sha256=86JwEKUaBLNuLGJlR4E0zjzdWL5xVFyYLvyxbzkdEVI,21214
119
119
  tests/online/test_vector_comprehensive.py,sha256=vmnwwVXLA7lUI_zSK3fJcf1HKx2AvrVDcUT0_d-gQwg,26980
120
120
  tests/online/test_version_management.py,sha256=BU8Vc1fDKNCwhRliZi6XmEnd0HYdHuki9Xxi09vnriA,11416
121
- matrixone_python_sdk-0.1.3.dist-info/METADATA,sha256=lNJxaTy1NjfSwoOdr8YOVZ-E9ISSjL2U-t9ZDtZsMnI,20815
122
- matrixone_python_sdk-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
- matrixone_python_sdk-0.1.3.dist-info/entry_points.txt,sha256=4wUGPC_7_f5ZDR33JRo1LZmmTuyfkYAv41_5H5Qy-Ik,138
124
- matrixone_python_sdk-0.1.3.dist-info/top_level.txt,sha256=LQZabpBx_dtQk8JbKeH3MbjmC8HYDLE8UQeEf6NfQJA,16
125
- matrixone_python_sdk-0.1.3.dist-info/RECORD,,
121
+ matrixone_python_sdk-0.1.4.dist-info/METADATA,sha256=EOKIuyVQVsFc316C84HjVLJYxD-7fMtq7a307ypoJ54,20815
122
+ matrixone_python_sdk-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
+ matrixone_python_sdk-0.1.4.dist-info/entry_points.txt,sha256=4wUGPC_7_f5ZDR33JRo1LZmmTuyfkYAv41_5H5Qy-Ik,138
124
+ matrixone_python_sdk-0.1.4.dist-info/top_level.txt,sha256=LQZabpBx_dtQk8JbKeH3MbjmC8HYDLE8UQeEf6NfQJA,16
125
+ matrixone_python_sdk-0.1.4.dist-info/RECORD,,
@@ -106,7 +106,7 @@ class TestConnectionHook:
106
106
  # Verify that cursor.execute was called with the correct SQL
107
107
  self.mock_cursor.execute.assert_called_with("SET experimental_ivf_index = 1")
108
108
  self.mock_cursor.close.assert_called_once()
109
- self.mock_client.logger.info.assert_called_with("✓ Enabled IVF vector operations")
109
+ self.mock_client.logger.debug.assert_called_with("✓ Enabled IVF vector operations")
110
110
 
111
111
  def test_execute_sync_with_hnsw_action(self):
112
112
  """Test synchronous execution with HNSW action"""
@@ -117,7 +117,7 @@ class TestConnectionHook:
117
117
  # Verify that cursor.execute was called with the correct SQL
118
118
  self.mock_cursor.execute.assert_called_with("SET experimental_hnsw_index = 1")
119
119
  self.mock_cursor.close.assert_called_once()
120
- self.mock_client.logger.info.assert_called_with("✓ Enabled HNSW vector operations")
120
+ self.mock_client.logger.debug.assert_called_with("✓ Enabled HNSW vector operations")
121
121
 
122
122
  def test_execute_sync_with_fulltext_action(self):
123
123
  """Test synchronous execution with fulltext action"""
@@ -128,7 +128,7 @@ class TestConnectionHook:
128
128
  # Verify that cursor.execute was called with the correct SQL
129
129
  self.mock_cursor.execute.assert_called_with("SET experimental_fulltext_index = 1")
130
130
  self.mock_cursor.close.assert_called_once()
131
- self.mock_client.logger.info.assert_called_with("✓ Enabled fulltext search operations")
131
+ self.mock_client.logger.debug.assert_called_with("✓ Enabled fulltext search operations")
132
132
 
133
133
  def test_execute_sync_with_vector_action(self):
134
134
  """Test synchronous execution with vector action (enables both IVF and HNSW)"""
@@ -140,8 +140,8 @@ class TestConnectionHook:
140
140
  expected_calls = [call("SET experimental_ivf_index = 1"), call("SET experimental_hnsw_index = 1")]
141
141
  self.mock_cursor.execute.assert_has_calls(expected_calls, any_order=True)
142
142
  self.mock_cursor.close.assert_called()
143
- self.mock_client.logger.info.assert_any_call("✓ Enabled IVF vector operations")
144
- self.mock_client.logger.info.assert_any_call("✓ Enabled HNSW vector operations")
143
+ self.mock_client.logger.debug.assert_any_call("✓ Enabled IVF vector operations")
144
+ self.mock_client.logger.debug.assert_any_call("✓ Enabled HNSW vector operations")
145
145
 
146
146
  def test_execute_sync_with_all_action(self):
147
147
  """Test synchronous execution with all action"""
@@ -157,9 +157,9 @@ class TestConnectionHook:
157
157
  ]
158
158
  self.mock_cursor.execute.assert_has_calls(expected_calls, any_order=True)
159
159
  self.mock_cursor.close.assert_called()
160
- self.mock_client.logger.info.assert_any_call("✓ Enabled IVF vector operations")
161
- self.mock_client.logger.info.assert_any_call("✓ Enabled HNSW vector operations")
162
- self.mock_client.logger.info.assert_any_call("✓ Enabled fulltext search operations")
160
+ self.mock_client.logger.debug.assert_any_call("✓ Enabled IVF vector operations")
161
+ self.mock_client.logger.debug.assert_any_call("✓ Enabled HNSW vector operations")
162
+ self.mock_client.logger.debug.assert_any_call("✓ Enabled fulltext search operations")
163
163
 
164
164
  def test_execute_sync_with_custom_hook(self):
165
165
  """Test synchronous execution with custom hook"""