vastdb 2.0.1__py3-none-any.whl → 2.0.2__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/table.py CHANGED
@@ -231,11 +231,11 @@ class TableInTransaction(ITable):
231
231
  raise errors.NotSupportedCommand(
232
232
  self.ref.bucket, self.ref.schema, self.ref.table)
233
233
 
234
- def projection(self, name: str) -> "Projection":
234
+ def projection(self, name: str, include_stats: bool = True) -> "Projection":
235
235
  """Get a specific semi-sorted projection of this table."""
236
236
  self._assert_not_imports_table()
237
237
 
238
- projs = tuple(self.projections(projection_name=name))
238
+ projs = tuple(self.projections(projection_name=name, include_stats=include_stats))
239
239
  if not projs:
240
240
  raise errors.MissingProjection(
241
241
  self.ref.bucket, self.ref.schema, self.ref.table, name)
@@ -245,7 +245,7 @@ class TableInTransaction(ITable):
245
245
  log.debug("Found projection: %s", projs[0])
246
246
  return projs[0]
247
247
 
248
- def projections(self, projection_name: str = "") -> Iterable["Projection"]:
248
+ def projections(self, projection_name: str = "", include_stats: bool = True) -> Iterable["Projection"]:
249
249
  """List all semi-sorted projections of this table if `projection_name` is empty.
250
250
 
251
251
  Otherwise, list only the specific projection (if exists).
@@ -260,7 +260,7 @@ class TableInTransaction(ITable):
260
260
  _bucket_name, _schema_name, _table_name, curr_projections, next_key, is_truncated, _ = \
261
261
  self._tx._rpc.api.list_projections(
262
262
  bucket=self.ref.bucket, schema=self.ref.schema, table=self.ref.table, next_key=next_key, txid=self._tx.active_txid,
263
- exact_match=exact_match, name_prefix=name_prefix)
263
+ exact_match=exact_match, name_prefix=name_prefix, include_list_stats=include_stats)
264
264
  if not curr_projections:
265
265
  break
266
266
  projections.extend(curr_projections)
@@ -8,6 +8,9 @@ from vastdb.table import QueryConfig
8
8
  log = logging.getLogger(__name__)
9
9
 
10
10
 
11
+ DELAY_TO_LET_SERVER_UPDATE: int = 3
12
+
13
+
11
14
  def test_basic_projections(session, clean_bucket_name):
12
15
  with session.transaction() as tx:
13
16
  s = tx.bucket(clean_bucket_name).create_schema('s1')
@@ -94,7 +97,7 @@ def test_query_data_with_projection(session, clean_bucket_name):
94
97
  actual = pa.Table.from_batches(t.select(columns=['a', 'b', 's']))
95
98
  assert actual == expected
96
99
 
97
- time.sleep(3)
100
+ time.sleep(DELAY_TO_LET_SERVER_UPDATE)
98
101
 
99
102
  with session.transaction() as tx:
100
103
  config = QueryConfig()
@@ -123,3 +126,48 @@ def test_query_data_with_projection(session, clean_bucket_name):
123
126
 
124
127
  t.drop()
125
128
  s.drop()
129
+
130
+
131
+ def test_projection_stats(session, clean_bucket_name):
132
+ columns = pa.schema([
133
+ ('a', pa.int64()),
134
+ ('b', pa.int64()),
135
+ ])
136
+
137
+ # min size to be considered as a projection
138
+ GROUP_SIZE = 64 * 1024
139
+ expected = pa.table(schema=columns, data=[
140
+ [i for i in range(GROUP_SIZE)],
141
+ [i for i in reversed(range(GROUP_SIZE))],
142
+ ])
143
+
144
+ schema_name = "schema"
145
+ table_name = "table"
146
+ with session.transaction() as tx:
147
+ s = tx.bucket(clean_bucket_name).create_schema(schema_name)
148
+ t = s.create_table(table_name, expected.schema)
149
+
150
+ sorted_columns = ['b']
151
+ unsorted_columns = ['a']
152
+ t.create_projection('p1', sorted_columns, unsorted_columns)
153
+
154
+ with session.transaction() as tx:
155
+ s = tx.bucket(clean_bucket_name).schema(schema_name)
156
+ t = s.table(table_name)
157
+ t.insert(expected)
158
+ actual = pa.Table.from_batches(t.select(columns=['a', 'b']))
159
+ assert actual == expected
160
+
161
+ time.sleep(DELAY_TO_LET_SERVER_UPDATE)
162
+
163
+ with session.transaction() as tx:
164
+ s = tx.bucket(clean_bucket_name).schema(schema_name)
165
+ t = s.table(table_name)
166
+ projections = t.projections()
167
+ assert len(projections) == 1
168
+ stats = projections[0].stats
169
+ assert stats.num_rows == GROUP_SIZE
170
+ assert stats.size_in_bytes > 0
171
+
172
+ t.drop()
173
+ s.drop()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vastdb
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: VAST Data SDK
5
5
  Home-page: https://github.com/vast-data/vastdb_sdk
6
6
  Author: VAST DATA
@@ -9,7 +9,7 @@ vastdb/errors.py,sha256=NiKdwbfVsWJIixP2Tf3JgiBoEt8rRaZ0VeCyD9mXnoM,5645
9
9
  vastdb/features.py,sha256=ivYbvhiGA858B00vhs_CNzlVV9QDUe53yW6V3J5EoxM,1874
10
10
  vastdb/schema.py,sha256=0o7HOGR2STJQ6itCDP5Lez6OOfKBl6tS0T7KLgL5Gbk,7104
11
11
  vastdb/session.py,sha256=Au0L67SzSQXG9ZlrfN5MEqIEX2LeIgzUpdFkGLIpjMs,2126
12
- vastdb/table.py,sha256=DipsklV03_oEvQGcE67ST8uQbtC_s-HtyCTs_majfNQ,44756
12
+ vastdb/table.py,sha256=W9FwXGxJ_1m73oHLnFPqI3hMitGUB-ZFxj-b6CmGE50,44875
13
13
  vastdb/table_metadata.py,sha256=ecQ7u0fMbJtdKByQ9CZ0kPnZN20QGZU8_YGCM3RXQe4,6685
14
14
  vastdb/transaction.py,sha256=GR-urtN4XCIUbbK5TV4xWGvDY6vit-HJyMGRvfnIi8k,3799
15
15
  vastdb/util.py,sha256=8CUnVRsJukC3uNHNoB5D0qPf0FxS8OSdVB84nNoLJKc,6290
@@ -47,7 +47,7 @@ vastdb/tests/test_duckdb.py,sha256=XZxlw3SXb8tbd2BsJdr9F7jBBka4dW9PVtwvwqEcOXo,2
47
47
  vastdb/tests/test_fixed_list.py,sha256=1KpsijmGvxHcM-pHJcm4zn2o_G8-ISbCFuoKSkXjmfk,14099
48
48
  vastdb/tests/test_imports.py,sha256=FhIHjYpttiQW_x3fMe8ENd9ynn7OyUtjxr2ca4z1F-s,21783
49
49
  vastdb/tests/test_nested.py,sha256=SKiXDX8RhR20DSdJNTZLHOGWduXVUPuG1uwfC_C5hTk,6663
50
- vastdb/tests/test_projections.py,sha256=3y1kubwVrzO-xoR0hyps7zrjOJI8niCYspaFTN16Q9w,4540
50
+ vastdb/tests/test_projections.py,sha256=v43WrIdz_Ru4j3VeZ7medRPafzuw1eKMZfbAE56xpfg,5983
51
51
  vastdb/tests/test_sanity.py,sha256=bv1ypGDzvOgmMvGbucDYiLQu8krQLlE6NB3M__q87x8,3303
52
52
  vastdb/tests/test_schemas.py,sha256=l70YQMlx2UL1KRQhApriiG2ZM7GJF-IzWU31H3Yqn1U,3312
53
53
  vastdb/tests/test_table_in_tx.py,sha256=-OFGaZMZQc78HOmR23xHIsH7d0VBneFG3tGdDlogceM,9105
@@ -214,8 +214,8 @@ vastdb/vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
214
214
  vastdb/vast_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
215
215
  vastdb/vast_tests/test_ha.py,sha256=744P4G6VJ09RIkHhMQL4wlipCBJWQVMhyvUrSc4k1HQ,975
216
216
  vastdb/vast_tests/test_scale.py,sha256=5jGwOdZH6Tv5tPdZYPWoqcxOceI2jA5i2D1zNKZHER4,3958
217
- vastdb-2.0.1.dist-info/licenses/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
218
- vastdb-2.0.1.dist-info/METADATA,sha256=3AyWHxel0lNv7ORfAoUhZXnol-vuGM12aprOBLAVVKo,1686
219
- vastdb-2.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
220
- vastdb-2.0.1.dist-info/top_level.txt,sha256=nnKAaZaQa8GFbYpWAexr_B9HrhonZbUlX6hL6AC--yA,7
221
- vastdb-2.0.1.dist-info/RECORD,,
217
+ vastdb-2.0.2.dist-info/licenses/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
218
+ vastdb-2.0.2.dist-info/METADATA,sha256=grJK4w_X_W1PPv8Fv50KhxEGG4SdzN6EGfKSwWNsAKQ,1686
219
+ vastdb-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
220
+ vastdb-2.0.2.dist-info/top_level.txt,sha256=nnKAaZaQa8GFbYpWAexr_B9HrhonZbUlX6hL6AC--yA,7
221
+ vastdb-2.0.2.dist-info/RECORD,,
File without changes