vastdb 2.0.3__py3-none-any.whl → 2.0.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.
vastdb/_adbc.py CHANGED
@@ -17,6 +17,7 @@ log = logging.getLogger(__name__)
17
17
 
18
18
 
19
19
  TXID_OVERRIDE_PROPERTY: str = "vast.db.external_txid"
20
+ END_USER_PROPERTY: str = "vast.db.end_user"
20
21
  VAST_DIST_ALIAS = "vast_pysdk_vector_dist"
21
22
  DEFAULT_ADBC_DRIVER_CACHE_DIR: str = "~/.vast/adbc_drivers_cache"
22
23
  DEFAULT_ADBC_DRIVER_CACHE_BY_URL_DIR: str = f"{DEFAULT_ADBC_DRIVER_CACHE_DIR}/by_url"
@@ -83,9 +84,18 @@ class AdbcDriver:
83
84
 
84
85
 
85
86
  def _get_adbc_connection(
86
- adbc_driver_path: str, endpoint: str, access_key: str, secret_key: str, txid: int
87
+ adbc_driver_path: str,
88
+ endpoint: str,
89
+ access_key: str,
90
+ secret_key: str,
91
+ txid: int,
92
+ end_user: Optional[str],
87
93
  ) -> Connection:
88
94
  """Get an adbc connection in transaction."""
95
+ conn_kwargs = {TXID_OVERRIDE_PROPERTY: str(txid)}
96
+ if end_user is not None:
97
+ conn_kwargs[END_USER_PROPERTY] = end_user
98
+
89
99
  return connect(
90
100
  driver=adbc_driver_path,
91
101
  db_kwargs={
@@ -93,7 +103,7 @@ def _get_adbc_connection(
93
103
  "vast.db.access_key": access_key,
94
104
  "vast.db.secret_key": secret_key,
95
105
  },
96
- conn_kwargs={TXID_OVERRIDE_PROPERTY: str(txid)},
106
+ conn_kwargs=conn_kwargs,
97
107
  )
98
108
 
99
109
 
@@ -157,9 +167,10 @@ class AdbcConnection:
157
167
  access_key: str,
158
168
  secret_key: str,
159
169
  txid: int,
170
+ end_user: Optional[str] = None,
160
171
  ):
161
172
  self._adbc_conn = _get_adbc_connection(
162
- adbc_driver.local_path, endpoint, access_key, secret_key, txid
173
+ adbc_driver.local_path, endpoint, access_key, secret_key, txid, end_user
163
174
  )
164
175
 
165
176
  self._cursor = self._adbc_conn.cursor()
vastdb/_internal.py CHANGED
@@ -1117,7 +1117,7 @@ class VastdbApi:
1117
1117
  if not bucket.startswith(bucket_name):
1118
1118
  raise ValueError(f'bucket: {bucket} did not start from {bucket_name}')
1119
1119
  schemas_length = lists.SchemasLength()
1120
- count = int(res_headers['tabular-list-count']) if 'tabular-list-count' in res_headers else schemas_length
1120
+ count = int(res_headers['tabular-list-count']) if count_only else schemas_length
1121
1121
  for i in range(schemas_length):
1122
1122
  schema_obj = lists.Schemas(i)
1123
1123
  name = schema_obj.Name().decode()
@@ -1427,7 +1427,7 @@ class VastdbApi:
1427
1427
  is_truncated = res_headers['tabular-is-truncated'] == 'true'
1428
1428
  lists = list_tables.GetRootAs(res.content)
1429
1429
  tables_length = lists.TablesLength()
1430
- count = int(res_headers['tabular-list-count']) if 'tabular-list-count' in res_headers else tables_length
1430
+ count = int(res_headers['tabular-list-count']) if count_only else tables_length
1431
1431
  return lists, next_key, is_truncated, count
1432
1432
 
1433
1433
  def _list_tables_internal(self, bucket, schema, parse_properties, txid=0, client_tags=[], max_keys=1000, next_key=0, name_prefix="",
@@ -1574,8 +1574,8 @@ class VastdbApi:
1574
1574
  res_headers = res.headers
1575
1575
  next_key = int(res_headers['tabular-next-key'])
1576
1576
  is_truncated = res_headers['tabular-is-truncated'] == 'true'
1577
- count = int(res_headers['tabular-list-count'])
1578
1577
  columns = [] if count_only else pa.ipc.open_stream(res.content).schema
1578
+ count = int(res_headers['tabular-list-count']) if count_only else len(columns)
1579
1579
 
1580
1580
  return columns, next_key, is_truncated, count
1581
1581
 
@@ -2044,7 +2044,6 @@ class VastdbApi:
2044
2044
  res_headers = res.headers
2045
2045
  next_key = int(res_headers['tabular-next-key'])
2046
2046
  is_truncated = res_headers['tabular-is-truncated'] == 'true'
2047
- count = int(res_headers['tabular-list-count'])
2048
2047
  lists = list_projections.GetRootAs(res.content)
2049
2048
  bucket_name = lists.BucketName().decode()
2050
2049
  schema_name = lists.SchemaName().decode()
@@ -2052,6 +2051,7 @@ class VastdbApi:
2052
2051
  if not bucket.startswith(bucket_name): # ignore snapshot name
2053
2052
  raise ValueError(f'bucket: {bucket} did not start from {bucket_name}')
2054
2053
  projections_length = lists.ProjectionsLength()
2054
+ count = int(res_headers['tabular-list-count']) if count_only else projections_length
2055
2055
  for i in range(projections_length):
2056
2056
  projections.append(_parse_table_info(lists.Projections(i), lambda x: x))
2057
2057
 
@@ -2092,10 +2092,10 @@ class VastdbApi:
2092
2092
  res_headers = res.headers
2093
2093
  next_key = int(res_headers['tabular-next-key'])
2094
2094
  is_truncated = res_headers['tabular-is-truncated'] == 'true'
2095
- count = int(res_headers['tabular-list-count'])
2096
2095
  columns = [] if count_only else [[f.name, f.type, f.metadata] for f in
2097
2096
  pa.ipc.open_stream(res.content).schema]
2098
2097
 
2098
+ count = int(res_headers['tabular-list-count']) if count_only else len(columns)
2099
2099
  return columns, next_key, is_truncated, count
2100
2100
 
2101
2101
 
vastdb/schema.py CHANGED
@@ -89,6 +89,7 @@ class Schema:
89
89
  See https://support.vastdata.com/s/article/UUID-48d0a8cf-5786-5ef3-3fa3-9c64e63a0967 for more details.
90
90
 
91
91
  Args:
92
+ ----
92
93
  table_name: Name of the table to create
93
94
  columns: PyArrow schema defining the table columns
94
95
  fail_if_exists: Whether to fail if the table already exists
@@ -97,6 +98,7 @@ class Schema:
97
98
  vector_index: Optional vector index.
98
99
 
99
100
  Returns:
101
+ -------
100
102
  The created table
101
103
 
102
104
  """
vastdb/session.py CHANGED
@@ -25,7 +25,8 @@ class Session:
25
25
  ssl_verify=True,
26
26
  timeout=None,
27
27
  backoff_config: Optional["BackoffConfig"] = None,
28
- adbc_driver: Optional[AdbcDriver] = None):
28
+ adbc_driver: Optional[AdbcDriver] = None,
29
+ end_user: Optional[str] = None):
29
30
  """Connect to a VAST Database endpoint, using specified credentials."""
30
31
  from . import _internal, features
31
32
 
@@ -49,6 +50,7 @@ class Session:
49
50
  backoff_config=backoff_config)
50
51
  self.features = features.Features(self.api.vast_version)
51
52
  self.adbc_driver: Optional[AdbcDriver] = adbc_driver
53
+ self._end_user = end_user
52
54
 
53
55
  def __repr__(self):
54
56
  """Don't show the secret key."""
@@ -63,4 +65,4 @@ class Session:
63
65
  tx.bucket("bucket").create_schema("schema")
64
66
  """
65
67
  from . import transaction
66
- return transaction.Transaction(self, _adbc_driver=self.adbc_driver)
68
+ return transaction.Transaction(self, _adbc_driver=self.adbc_driver, _end_user=self._end_user)
vastdb/table.py CHANGED
@@ -626,13 +626,12 @@ class TableInTransaction(ITable):
626
626
  log.debug(
627
627
  "one worker thread finished, remaining: %d", tasks_running)
628
628
 
629
- # all host threads ended - wait for all futures to complete
630
- propagate_first_exception(futures, block=True)
631
629
  finally:
632
630
  stop_event.set()
633
631
  while tasks_running > 0:
634
632
  if record_batches_queue.get() is None:
635
633
  tasks_running -= 1
634
+ propagate_first_exception(futures, block=True)
636
635
 
637
636
  return pa.RecordBatchReader.from_batches(query_data_request.response_schema, batches_iterator())
638
637
 
@@ -1,6 +1,11 @@
1
+ from typing import Optional
2
+ from unittest.mock import MagicMock, patch
3
+
1
4
  import pyarrow as pa
2
5
  import pytest
3
6
 
7
+ from vastdb._adbc import END_USER_PROPERTY, AdbcDriver
8
+ from vastdb.session import Session
4
9
  from vastdb.table_metadata import TableRef
5
10
  from vastdb.transaction import NoAdbcConnectionError
6
11
 
@@ -87,3 +92,38 @@ def test_two_simulatnious_txs_with_adbc(session_factory, clean_bucket_name: str)
87
92
  # expecting adbc execute to "see" table if it shares the transaction with the pysdk
88
93
  tx.adbc_conn.cursor.execute(f"SELECT * FROM {table.ref.query_engine_full_path}")
89
94
  assert tx.adbc_conn.cursor.fetchall() == [(1,), (2,), (3,), (4,), (5,)]
95
+
96
+
97
+ @pytest.mark.parametrize("end_user", [("mock-end-user",), (None,)])
98
+ def test_end_user_passed_to_adbc_connect(end_user: Optional[str]):
99
+ mock_driver = MagicMock(spec=AdbcDriver)
100
+ mock_driver.local_path = "/mock/driver/path"
101
+
102
+ with (
103
+ patch("vastdb._adbc.connect") as mock_connect,
104
+ patch("vastdb._internal.VastdbApi") as MockVastdbApi,
105
+ ):
106
+ mock_api_instance = MockVastdbApi.return_value
107
+ mock_api_instance.begin_transaction.return_value.headers = {
108
+ "tabular-txid": "12345"
109
+ }
110
+ # A version that supports everything needed.
111
+ mock_api_instance.vast_version = (5, 4, 0, 0)
112
+
113
+ session = Session(
114
+ access="test_access",
115
+ secret="test_secret",
116
+ endpoint="http://localhost:9090",
117
+ adbc_driver=mock_driver,
118
+ end_user=end_user,
119
+ )
120
+
121
+ with session.transaction():
122
+ # The ADBC connection is established when the transaction starts
123
+ pass
124
+
125
+ mock_connect.assert_called_once()
126
+ call_kwargs = mock_connect.call_args.kwargs
127
+ conn_kwargs = call_kwargs.get("conn_kwargs", {})
128
+ assert (end_user is None) ^ (END_USER_PROPERTY in conn_kwargs)
129
+ assert (end_user is None) ^ (conn_kwargs.get(END_USER_PROPERTY) == end_user)
@@ -163,6 +163,7 @@ def test_ibis_to_query_engine_predicates(ibis_predicate: IbisPredicate, expected
163
163
  assert _ibis_to_qe_predicates(ibis_predicate) == expected
164
164
 
165
165
 
166
+ @pytest.mark.skip(reason="see https://vastdata.atlassian.net/browse/ORION-307908")
166
167
  def test_with_predicates_get_vector_index_properties_from_server(
167
168
  session_factory: SessionFactory,
168
169
  clean_bucket_name: str
vastdb/transaction.py CHANGED
@@ -54,6 +54,7 @@ class Transaction:
54
54
  txid: Optional[int] = None
55
55
  _adbc_driver: Optional[AdbcDriver] = None
56
56
  _adbc_conn: Optional[AdbcConnection] = None
57
+ _end_user: Optional[str] = None
57
58
 
58
59
  def __enter__(self):
59
60
  """Create a transaction and store its ID."""
@@ -67,6 +68,7 @@ class Transaction:
67
68
  self._rpc.access,
68
69
  self._rpc.secret,
69
70
  self.txid,
71
+ self._end_user
70
72
  )
71
73
 
72
74
  log.debug("opened txid=%016x", self.txid)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vastdb
3
- Version: 2.0.3
3
+ Version: 2.0.5
4
4
  Summary: VAST Data SDK
5
5
  Home-page: https://github.com/vast-data/vastdb_sdk
6
6
  Author: VAST DATA
@@ -1,18 +1,18 @@
1
1
  vastdb/__init__.py,sha256=uf-AXdzsD4nPxFP7WxkcAXGG0whv8BHLrrXCJtsPGaQ,436
2
- vastdb/_adbc.py,sha256=jJphuI9vFv9TNw6hbV2XzDRjOboxBKcgyf-7voPbuco,5735
2
+ vastdb/_adbc.py,sha256=aUjn0hC92U5Jh2jQYeMFzTHYnVP086dVHlMoIoxhvh0,5985
3
3
  vastdb/_ibis_support.py,sha256=sJieOMvDWpsciPKh1mJzS56jxLtCRVlvK41hW84vexM,866
4
- vastdb/_internal.py,sha256=gZZAV3p4ya9bUUkVghgEXUbzR3HukkAu757mtlexpzw,112715
4
+ vastdb/_internal.py,sha256=7c6tySuEacwZ5jqdW-HSAtbIIk8ep-_jA4uGrEU9gwc,112767
5
5
  vastdb/_table_interface.py,sha256=dRcXzC7j1SSpBQ4jCOPF_Zgg66LSt0tBeILM8W_A71c,4130
6
6
  vastdb/bucket.py,sha256=ulkTI_7xw5FYVzcrTFC7G2ijmTTVSmvJZUdgzycGHR0,2588
7
7
  vastdb/config.py,sha256=OehnsWrjzv0-SUouEXmkrKBugiWyhXOn4XiSLV3s9yk,2342
8
8
  vastdb/conftest.py,sha256=vDNqhYMsF630_ueXofnT2zhuSEpjcc4hxcXAjPqlxDI,5525
9
9
  vastdb/errors.py,sha256=GVmiwyrfHrag8GL55ivcF5Kwc1Ro4wvvaJAcuIWvmO0,5764
10
10
  vastdb/features.py,sha256=ivYbvhiGA858B00vhs_CNzlVV9QDUe53yW6V3J5EoxM,1874
11
- vastdb/schema.py,sha256=apU2NATGg_Cv8Fnq8a1_g6Cc2-Fake2vV0NzsB5Xe8Q,7753
12
- vastdb/session.py,sha256=UEtYmrcOn5t80PkPUFaD7pGYkDKDWc-0LbNQ3BTsk58,2420
13
- vastdb/table.py,sha256=PXKZenXdtCXWiZ48D_2XLrSq2t1D256uJcAAGwXr4qE,46321
11
+ vastdb/schema.py,sha256=7k6Su8xjXzeLZeqNzsXIk06q9sIWMG9PBBlwy1aEAG0,7782
12
+ vastdb/session.py,sha256=oUiTx8x_5XOs6EnNvFjon9dSVTk89XhOZ-SfLR8sITQ,2529
13
+ vastdb/table.py,sha256=X0uOMlxA9R2ER1-uEyB1lBv_nn-c_kM_jjaM2ai2IrQ,46241
14
14
  vastdb/table_metadata.py,sha256=PSwx1A25AmcCs4ig-Sx_xyXr7xqyGaNIk2LMnIvrwmM,7358
15
- vastdb/transaction.py,sha256=qdCdPgqT1CH73ut2mGPg0VZL90jyeShXD_QR-fGBWvw,4667
15
+ vastdb/transaction.py,sha256=JaTvUw86HZ-qFiqjR1fmHndF5bSgMtVWj549MtGsZ5Q,4734
16
16
  vastdb/util.py,sha256=8CUnVRsJukC3uNHNoB5D0qPf0FxS8OSdVB84nNoLJKc,6290
17
17
  vastdb/bench/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  vastdb/bench/test_perf.py,sha256=0kbCxK8U9vYO0zCMUYcZHzEICaaII3I0-6FeR5-CNtM,4040
@@ -44,7 +44,7 @@ vastdb/bench/perf_bench/query/query_pyarrow.py,sha256=Dj5YPUvb4dAj7RskHfJcPijJnM
44
44
  vastdb/bench/perf_bench/query/query_vastdb.py,sha256=SZYem_EmsaynEftAa_VFobjSJZDAcli9BckyRS3SFvg,2810
45
45
  vastdb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  vastdb/tests/metrics.py,sha256=ZCSeBYFSPMG3yI0JrAHs2CrY6wFjx_5GwRTYHVAwLKA,1026
47
- vastdb/tests/test_adbc_integration.py,sha256=7huOOe9ww6M6RABDo8nzv2uW1A6Xg7XnnhQ0-_e4Woc,3056
47
+ vastdb/tests/test_adbc_integration.py,sha256=6Zt4plbKrr4lIQ2AxQN7GP4yh5vzOgYdSU0ql5g97SY,4521
48
48
  vastdb/tests/test_duckdb.py,sha256=XZxlw3SXb8tbd2BsJdr9F7jBBka4dW9PVtwvwqEcOXo,2057
49
49
  vastdb/tests/test_fixed_list.py,sha256=1KpsijmGvxHcM-pHJcm4zn2o_G8-ISbCFuoKSkXjmfk,14099
50
50
  vastdb/tests/test_imports.py,sha256=FhIHjYpttiQW_x3fMe8ENd9ynn7OyUtjxr2ca4z1F-s,21783
@@ -56,7 +56,7 @@ vastdb/tests/test_table_in_tx.py,sha256=-OFGaZMZQc78HOmR23xHIsH7d0VBneFG3tGdDlog
56
56
  vastdb/tests/test_tables.py,sha256=yU5fBeHentNe22Rc1e73mj33M0nl63Y_acOy6VTzF-4,54496
57
57
  vastdb/tests/test_util.py,sha256=n7gvT5Wg6b6bxgqkFXkYqvFd_W1GlUdVfmPv66XYXyA,1956
58
58
  vastdb/tests/test_vector_index.py,sha256=qgppSQG77PUgmdXzfprX1mxUkkqq7tbxCA3MRaYFFgQ,6460
59
- vastdb/tests/test_vector_search.py,sha256=z3oxzejIaJw8nPZEvrG74k-zhDGRvu9C5Dhkqv--Zpc,7020
59
+ vastdb/tests/test_vector_search.py,sha256=50mnBFuw0PAApMLkYwDUMV5VxQorswzD_f_XdpaEXTo,7103
60
60
  vastdb/tests/util.py,sha256=cv8Qcvy92vpBbiiuqXr7pAfbh2K8ziBVZ_j1EQ4vT6o,5994
61
61
  vastdb/vast_flatbuf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  vastdb/vast_flatbuf/org/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -219,8 +219,8 @@ vastdb/vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
219
219
  vastdb/vast_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
220
220
  vastdb/vast_tests/test_ha.py,sha256=744P4G6VJ09RIkHhMQL4wlipCBJWQVMhyvUrSc4k1HQ,975
221
221
  vastdb/vast_tests/test_scale.py,sha256=5jGwOdZH6Tv5tPdZYPWoqcxOceI2jA5i2D1zNKZHER4,3958
222
- vastdb-2.0.3.dist-info/licenses/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
223
- vastdb-2.0.3.dist-info/METADATA,sha256=lGMKtf0KnNZhPAtFyXCXu6HA0jbsmIDMVw1II061vww,1721
224
- vastdb-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
225
- vastdb-2.0.3.dist-info/top_level.txt,sha256=nnKAaZaQa8GFbYpWAexr_B9HrhonZbUlX6hL6AC--yA,7
226
- vastdb-2.0.3.dist-info/RECORD,,
222
+ vastdb-2.0.5.dist-info/licenses/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
223
+ vastdb-2.0.5.dist-info/METADATA,sha256=4wi1lvs2ENDLmNaGUK4cFq_AS_IpWtYBIQJdNvrV7Nc,1721
224
+ vastdb-2.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
225
+ vastdb-2.0.5.dist-info/top_level.txt,sha256=nnKAaZaQa8GFbYpWAexr_B9HrhonZbUlX6hL6AC--yA,7
226
+ vastdb-2.0.5.dist-info/RECORD,,
File without changes