vastdb 1.3.11__py3-none-any.whl → 1.4.0__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 +9 -4
- vastdb/tests/test_tables.py +6 -5
- vastdb/tests/util.py +12 -2
- {vastdb-1.3.11.dist-info → vastdb-1.4.0.dist-info}/METADATA +1 -1
- {vastdb-1.3.11.dist-info → vastdb-1.4.0.dist-info}/RECORD +8 -8
- {vastdb-1.3.11.dist-info → vastdb-1.4.0.dist-info}/LICENSE +0 -0
- {vastdb-1.3.11.dist-info → vastdb-1.4.0.dist-info}/WHEEL +0 -0
- {vastdb-1.3.11.dist-info → vastdb-1.4.0.dist-info}/top_level.txt +0 -0
vastdb/table.py
CHANGED
|
@@ -532,19 +532,24 @@ class Table:
|
|
|
532
532
|
columns_name_chunk = columns_names[start:end]
|
|
533
533
|
columns_chunks = columns[start:end]
|
|
534
534
|
arrays_chunks = arrays[start:end]
|
|
535
|
-
columns_chunks.append(INTERNAL_ROW_ID_FIELD)
|
|
535
|
+
columns_chunks.append(INTERNAL_ROW_ID_SORTED_FIELD if self.sorted_table else INTERNAL_ROW_ID_FIELD)
|
|
536
536
|
arrays_chunks.append(row_ids.to_pylist())
|
|
537
537
|
column_record_batch = pa.RecordBatch.from_arrays(arrays_chunks, schema=pa.schema(columns_chunks))
|
|
538
538
|
self.update(rows=column_record_batch, columns=columns_name_chunk)
|
|
539
539
|
return row_ids
|
|
540
540
|
|
|
541
|
-
def insert(self, rows: Union[pa.RecordBatch, pa.Table]):
|
|
541
|
+
def insert(self, rows: Union[pa.RecordBatch, pa.Table], by_columns: bool = False):
|
|
542
542
|
"""Insert a RecordBatch into this table."""
|
|
543
543
|
if self._imports_table:
|
|
544
544
|
raise errors.NotSupportedCommand(self.bucket.name, self.schema.name, self.name)
|
|
545
545
|
if 0 == rows.num_rows:
|
|
546
546
|
log.debug("Ignoring empty insert into %s", self.name)
|
|
547
|
-
return pa.chunked_array([], type=INTERNAL_ROW_ID_FIELD.type)
|
|
547
|
+
return pa.chunked_array([], type=(INTERNAL_ROW_ID_SORTED_FIELD if self.sorted_table else INTERNAL_ROW_ID_FIELD).type)
|
|
548
|
+
|
|
549
|
+
if by_columns:
|
|
550
|
+
self.tx._rpc.features.check_return_row_ids()
|
|
551
|
+
return self.insert_in_column_batches(rows)
|
|
552
|
+
|
|
548
553
|
try:
|
|
549
554
|
row_ids = []
|
|
550
555
|
serialized_slices = util.iter_serialized_slices(rows, MAX_INSERT_ROWS_PER_PATCH)
|
|
@@ -557,7 +562,7 @@ class Table:
|
|
|
557
562
|
self.tx._rpc.features.check_return_row_ids()
|
|
558
563
|
except errors.NotSupportedVersion:
|
|
559
564
|
return # type: ignore
|
|
560
|
-
return pa.chunked_array(row_ids, type=INTERNAL_ROW_ID_FIELD.type)
|
|
565
|
+
return pa.chunked_array(row_ids, type=(INTERNAL_ROW_ID_SORTED_FIELD if self.sorted_table else INTERNAL_ROW_ID_FIELD).type)
|
|
561
566
|
except errors.TooWideRow:
|
|
562
567
|
self.tx._rpc.features.check_return_row_ids()
|
|
563
568
|
return self.insert_in_column_batches(rows)
|
vastdb/tests/test_tables.py
CHANGED
|
@@ -15,10 +15,11 @@ import pytest
|
|
|
15
15
|
from requests.exceptions import HTTPError
|
|
16
16
|
|
|
17
17
|
from vastdb.errors import BadRequest
|
|
18
|
+
from vastdb.session import Session
|
|
18
19
|
|
|
19
20
|
from .. import errors
|
|
20
21
|
from ..table import INTERNAL_ROW_ID, QueryConfig
|
|
21
|
-
from .util import prepare_data
|
|
22
|
+
from .util import assert_row_ids_ascending_on_first_insertion_to_table, prepare_data
|
|
22
23
|
|
|
23
24
|
log = logging.getLogger(__name__)
|
|
24
25
|
|
|
@@ -1150,7 +1151,7 @@ def test_elysium_tx(elysium_session, clean_bucket_name):
|
|
|
1150
1151
|
t = s.create_table(table_name, arrow_table.schema)
|
|
1151
1152
|
row_ids_array = t.insert(arrow_table)
|
|
1152
1153
|
row_ids = row_ids_array.to_pylist()
|
|
1153
|
-
|
|
1154
|
+
assert_row_ids_ascending_on_first_insertion_to_table(row_ids, arrow_table.num_rows, t.sorted_table)
|
|
1154
1155
|
sorted_columns = t.sorted_columns()
|
|
1155
1156
|
assert len(sorted_columns) == 0
|
|
1156
1157
|
t.add_sorting_key(sorting)
|
|
@@ -1186,7 +1187,7 @@ def test_elysium_double_enable(elysium_session, clean_bucket_name):
|
|
|
1186
1187
|
t.add_sorting_key(sorting)
|
|
1187
1188
|
|
|
1188
1189
|
|
|
1189
|
-
def test_elysium_update_table_tx(elysium_session, clean_bucket_name):
|
|
1190
|
+
def test_elysium_update_table_tx(elysium_session: Session, clean_bucket_name):
|
|
1190
1191
|
columns = pa.schema([
|
|
1191
1192
|
('a', pa.int64()),
|
|
1192
1193
|
('b', pa.float32()),
|
|
@@ -1205,7 +1206,7 @@ def test_elysium_update_table_tx(elysium_session, clean_bucket_name):
|
|
|
1205
1206
|
t = s.create_table(table_name, arrow_table.schema, sorting_key=sorting)
|
|
1206
1207
|
row_ids_array = t.insert(arrow_table)
|
|
1207
1208
|
row_ids = row_ids_array.to_pylist()
|
|
1208
|
-
|
|
1209
|
+
assert_row_ids_ascending_on_first_insertion_to_table(row_ids, arrow_table.num_rows, t.sorted_table)
|
|
1209
1210
|
sorted_columns = t.sorted_columns()
|
|
1210
1211
|
assert sorted_columns[0].name == 's'
|
|
1211
1212
|
assert sorted_columns[1].name == 'b'
|
|
@@ -1278,7 +1279,7 @@ def test_elysium_splits(elysium_session, clean_bucket_name):
|
|
|
1278
1279
|
t = s.create_table(table_name, arrow_table.schema, sorting_key=sorting)
|
|
1279
1280
|
row_ids_array = t.insert(arrow_table)
|
|
1280
1281
|
row_ids = row_ids_array.to_pylist()
|
|
1281
|
-
|
|
1282
|
+
assert_row_ids_ascending_on_first_insertion_to_table(row_ids, arrow_table.num_rows, t.sorted_table)
|
|
1282
1283
|
sorted_columns = t.sorted_columns()
|
|
1283
1284
|
assert sorted_columns[0].name == 'a'
|
|
1284
1285
|
|
vastdb/tests/util.py
CHANGED
|
@@ -3,17 +3,27 @@ from contextlib import contextmanager
|
|
|
3
3
|
|
|
4
4
|
import pyarrow as pa
|
|
5
5
|
|
|
6
|
+
from vastdb.session import Session
|
|
7
|
+
|
|
6
8
|
log = logging.getLogger(__name__)
|
|
7
9
|
|
|
8
10
|
|
|
11
|
+
def assert_row_ids_ascending_on_first_insertion_to_table(row_ids, expected_num_rows, sorted_table):
|
|
12
|
+
adjusted_row_ids = [
|
|
13
|
+
int(row_id) & 0xFFFFFFFFFFFFFF for row_id in row_ids
|
|
14
|
+
] if sorted_table else row_ids
|
|
15
|
+
|
|
16
|
+
assert adjusted_row_ids == list(range(expected_num_rows))
|
|
17
|
+
|
|
18
|
+
|
|
9
19
|
@contextmanager
|
|
10
|
-
def prepare_data(session, clean_bucket_name, schema_name, table_name, arrow_table, sorting_key=[]):
|
|
20
|
+
def prepare_data(session: Session, clean_bucket_name, schema_name, table_name, arrow_table, sorting_key=[]):
|
|
11
21
|
with session.transaction() as tx:
|
|
12
22
|
s = tx.bucket(clean_bucket_name).create_schema(schema_name)
|
|
13
23
|
t = s.create_table(table_name, arrow_table.schema, sorting_key=sorting_key)
|
|
14
24
|
row_ids_array = t.insert(arrow_table)
|
|
15
25
|
row_ids = row_ids_array.to_pylist()
|
|
16
|
-
|
|
26
|
+
assert_row_ids_ascending_on_first_insertion_to_table(row_ids, arrow_table.num_rows, t.sorted_table)
|
|
17
27
|
yield t
|
|
18
28
|
t.drop()
|
|
19
29
|
s.drop()
|
|
@@ -7,7 +7,7 @@ vastdb/errors.py,sha256=NiKdwbfVsWJIixP2Tf3JgiBoEt8rRaZ0VeCyD9mXnoM,5645
|
|
|
7
7
|
vastdb/features.py,sha256=ivYbvhiGA858B00vhs_CNzlVV9QDUe53yW6V3J5EoxM,1874
|
|
8
8
|
vastdb/schema.py,sha256=5BZ0f3b_c-fGRKAaBBL6B3avHel5EDwwxte7t17WeTw,6718
|
|
9
9
|
vastdb/session.py,sha256=toMR0BXwTaECdWDKnIZky1F3MA1SmelRBiqCrqQ3GCM,2067
|
|
10
|
-
vastdb/table.py,sha256=
|
|
10
|
+
vastdb/table.py,sha256=rM-xJgpSuvowUH3oilVVuW-7JsPDmMJ4rbHnru1EA0Y,37268
|
|
11
11
|
vastdb/transaction.py,sha256=NlVkEowJ_pmtffjWBBDaKExYDKPekjSZyj_fK_bZPJE,3026
|
|
12
12
|
vastdb/util.py,sha256=8CUnVRsJukC3uNHNoB5D0qPf0FxS8OSdVB84nNoLJKc,6290
|
|
13
13
|
vastdb/bench/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -47,9 +47,9 @@ vastdb/tests/test_nested.py,sha256=c7q9a3MsyDymqAtShPC4cMHlzjCr18kbu_Db3u_c4IQ,6
|
|
|
47
47
|
vastdb/tests/test_projections.py,sha256=3y1kubwVrzO-xoR0hyps7zrjOJI8niCYspaFTN16Q9w,4540
|
|
48
48
|
vastdb/tests/test_sanity.py,sha256=bv1ypGDzvOgmMvGbucDYiLQu8krQLlE6NB3M__q87x8,3303
|
|
49
49
|
vastdb/tests/test_schemas.py,sha256=l70YQMlx2UL1KRQhApriiG2ZM7GJF-IzWU31H3Yqn1U,3312
|
|
50
|
-
vastdb/tests/test_tables.py,sha256=
|
|
50
|
+
vastdb/tests/test_tables.py,sha256=2m7Ao97mLwvCgzGShxTHMxFbt3vnNfb6InNe96DTJMA,51502
|
|
51
51
|
vastdb/tests/test_util.py,sha256=n7gvT5Wg6b6bxgqkFXkYqvFd_W1GlUdVfmPv66XYXyA,1956
|
|
52
|
-
vastdb/tests/util.py,sha256=
|
|
52
|
+
vastdb/tests/util.py,sha256=j8WSYOsScz7uvJljIcI9ZQWz3cA3WPykurwymnDd3s0,1690
|
|
53
53
|
vastdb/vast_flatbuf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
54
|
vastdb/vast_flatbuf/org/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
55
|
vastdb/vast_flatbuf/org/apache/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -210,8 +210,8 @@ vastdb/vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
210
210
|
vastdb/vast_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
211
211
|
vastdb/vast_tests/test_ha.py,sha256=744P4G6VJ09RIkHhMQL4wlipCBJWQVMhyvUrSc4k1HQ,975
|
|
212
212
|
vastdb/vast_tests/test_scale.py,sha256=5jGwOdZH6Tv5tPdZYPWoqcxOceI2jA5i2D1zNKZHER4,3958
|
|
213
|
-
vastdb-1.
|
|
214
|
-
vastdb-1.
|
|
215
|
-
vastdb-1.
|
|
216
|
-
vastdb-1.
|
|
217
|
-
vastdb-1.
|
|
213
|
+
vastdb-1.4.0.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
|
|
214
|
+
vastdb-1.4.0.dist-info/METADATA,sha256=7bga0VnmmT_RYdlB7abV_l-SEDegSuLMIRf7rB8UGpQ,1340
|
|
215
|
+
vastdb-1.4.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
216
|
+
vastdb-1.4.0.dist-info/top_level.txt,sha256=nnKAaZaQa8GFbYpWAexr_B9HrhonZbUlX6hL6AC--yA,7
|
|
217
|
+
vastdb-1.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|