vastdb 0.1.8__py3-none-any.whl → 0.1.9__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/errors.py CHANGED
@@ -3,6 +3,7 @@ import xml.etree.ElementTree
3
3
  from dataclasses import dataclass
4
4
  from enum import Enum
5
5
 
6
+ import pyarrow as pa
6
7
  import requests
7
8
 
8
9
 
@@ -169,6 +170,11 @@ class NotSupportedCommand(NotSupported):
169
170
  table: str
170
171
 
171
172
 
173
+ @dataclass
174
+ class NotSupportedType(NotSupported):
175
+ field: pa.Field
176
+
177
+
172
178
  @dataclass
173
179
  class NotSupportedVersion(NotSupported):
174
180
  err_msg: str
vastdb/schema.py CHANGED
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Iterable, List, Optional
10
10
 
11
11
  import pyarrow as pa
12
12
 
13
- from . import bucket, errors, schema, table
13
+ from . import bucket, errors, schema, table, util
14
14
 
15
15
  if TYPE_CHECKING:
16
16
  from .table import Table
@@ -86,6 +86,7 @@ class Schema:
86
86
  if use_external_row_ids_allocation:
87
87
  self.tx._rpc.features.check_external_row_ids_allocation()
88
88
 
89
+ util.check_supported_types(columns)
89
90
  self.tx._rpc.api.create_table(self.bucket.name, self.name, table_name, columns, txid=self.tx.txid,
90
91
  use_external_row_ids_allocation=use_external_row_ids_allocation)
91
92
  log.info("Created table: %s", table_name)
vastdb/table.py CHANGED
@@ -486,6 +486,7 @@ class Table:
486
486
  raise errors.NotSupportedCommand(self.bucket.name, self.schema.name, self.name)
487
487
  try:
488
488
  row_ids = []
489
+ util.check_supported_types(rows.schema)
489
490
  serialized_slices = util.iter_serialized_slices(rows, MAX_INSERT_ROWS_PER_PATCH)
490
491
  for slice in serialized_slices:
491
492
  res = self.tx._rpc.api.insert_rows(self.bucket.name, self.schema.name, self.name, record_batch=slice,
@@ -528,6 +529,7 @@ class Table:
528
529
 
529
530
  update_rows_rb = util.sort_record_batch_if_needed(update_rows_rb, INTERNAL_ROW_ID)
530
531
 
532
+ util.check_supported_types(update_rows_rb.schema)
531
533
  serialized_slices = util.iter_serialized_slices(update_rows_rb, MAX_ROWS_PER_BATCH)
532
534
  for slice in serialized_slices:
533
535
  self.tx._rpc.api.update_rows(self.bucket.name, self.schema.name, self.name, record_batch=slice,
@@ -572,6 +574,7 @@ class Table:
572
574
  """Add a new column."""
573
575
  if self._imports_table:
574
576
  raise errors.NotSupportedCommand(self.bucket.name, self.schema.name, self.name)
577
+ util.check_supported_types(new_column)
575
578
  self.tx._rpc.api.add_columns(self.bucket.name, self.schema.name, self.name, new_column, txid=self.tx.txid)
576
579
  log.info("Added column(s): %s", new_column)
577
580
  self.arrow_schema = self.columns()
@@ -311,6 +311,46 @@ def test_types(session, clean_bucket_name):
311
311
  assert select(t['ts9'] == ts_literal) == expected.filter(pc.field('ts9') == ts_literal)
312
312
 
313
313
 
314
+ TIMESTAMP_UNITS = ['s', 'ms', 'us', 'ns']
315
+
316
+
317
+ def test_unsupported_timezone(session, clean_bucket_name):
318
+ with session.transaction() as tx:
319
+ s = tx.bucket(clean_bucket_name).create_schema('s1')
320
+ for unit in TIMESTAMP_UNITS:
321
+ col_type = pa.timestamp(unit, 'UTC')
322
+ with pytest.raises(errors.NotSupportedType):
323
+ s.create_table('t1', pa.schema([('ts', col_type)]))
324
+ assert s.tables() == []
325
+
326
+ cols = [('c', pa.int64())]
327
+ t1 = s.create_table('t1', pa.schema(cols))
328
+ for unit in TIMESTAMP_UNITS:
329
+ col_type = pa.timestamp(unit, 'UTC')
330
+ with pytest.raises(errors.NotSupportedType):
331
+ t1.add_column(pa.schema([('ts', col_type)]))
332
+
333
+ cols = [(f'c_{unit}', pa.timestamp(unit)) for unit in TIMESTAMP_UNITS]
334
+ t2 = s.create_table('t2', pa.schema(cols))
335
+
336
+ for unit in TIMESTAMP_UNITS:
337
+ col_type = pa.timestamp(unit, 'UTC')
338
+
339
+ rb = pa.record_batch(
340
+ data=[[None]],
341
+ schema=pa.schema([(f'c_{unit}', col_type)]))
342
+ with pytest.raises(errors.NotSupportedType):
343
+ t2.insert(rb)
344
+
345
+ rb = pa.record_batch(
346
+ data=[[0], [None]],
347
+ schema=pa.schema([
348
+ (INTERNAL_ROW_ID, pa.uint64()),
349
+ (f'c_{unit}', col_type)]))
350
+ with pytest.raises(errors.NotSupportedType):
351
+ t2.update(rb)
352
+
353
+
314
354
  def test_filters(session, clean_bucket_name):
315
355
  columns = pa.schema([
316
356
  ('a', pa.int32()),
vastdb/util.py CHANGED
@@ -6,7 +6,7 @@ import pyarrow as pa
6
6
  import pyarrow.compute as pc
7
7
  import pyarrow.parquet as pq
8
8
 
9
- from .errors import InvalidArgument, TooWideRow
9
+ from .errors import InvalidArgument, NotSupportedType, TooWideRow
10
10
 
11
11
  log = logging.getLogger(__name__)
12
12
 
@@ -152,3 +152,10 @@ def sort_record_batch_if_needed(record_batch, sort_column):
152
152
  return record_batch.sort_by(sort_column)
153
153
  else:
154
154
  return record_batch
155
+
156
+
157
+ def check_supported_types(fields: pa.Schema):
158
+ for f in fields:
159
+ if isinstance(f.type, pa.TimestampType):
160
+ if f.type.tz:
161
+ raise NotSupportedType(f)
@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
10
10
 
11
11
 
12
12
  @pytest.mark.ha
13
- def test_ha_query(session, crater_path, test_bucket_name, schema_name, table_name):
13
+ def test_ha_query(session, test_bucket_name, schema_name, table_name):
14
14
  # runs in parallel to ha scenario
15
15
  times_to_query, records_in_table = 50, 100_000_000
16
16
  arrow_array = pa.array(range(0, records_in_table), type=pa.int64())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vastdb
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: VAST Data SDK
5
5
  Home-page: https://github.com/vast-data/vastdb_sdk
6
6
  Author: VAST DATA
@@ -152,12 +152,12 @@ vastdb/__init__.py,sha256=8PLcZowy_vM0zuiYSQPXuxIEMcwHD7IRFpgcPK-03bk,386
152
152
  vastdb/_internal.py,sha256=bENTnMZFAXolkFaWa7op9bsPWMk3wVE6oKKU--0ukXk,89971
153
153
  vastdb/bucket.py,sha256=5KuKhPjZOevznZqWHDVVocejvAy7dcwobPuV6BJCfPc,2544
154
154
  vastdb/conftest.py,sha256=wnnPXjeLems2zpOBB1UGbZ_YW5S169NhGA5UZu7H5SM,2831
155
- vastdb/errors.py,sha256=2XR1ko7J5nkfiHSAgwuVAADw0SsyqxOwSeFaGgKZEXM,4186
156
- vastdb/schema.py,sha256=X7IRrogXH7Z0kes-DsDh1bRqIhvjH6owlFigGBXy7XQ,5913
155
+ vastdb/errors.py,sha256=jER5RQYsBRlQsjym1ItQYRukggMypATOo_sKvsJtMbo,4278
156
+ vastdb/schema.py,sha256=yaueil92MSMYJf6bWseov_8fXTdW5zaKLXNjP5uuyzI,5963
157
157
  vastdb/session.py,sha256=3YHhG7IamFOKuy-Fkq_IVtPNriSfI6IN_4z4arBFbDU,3349
158
- vastdb/table.py,sha256=qnyttTUF4SPCOcwx8HQZmKZFZlasMEfwEa5r_EalRxo,32723
158
+ vastdb/table.py,sha256=TGBiIp0pB7vHd-92q4_sDRDjd4klHDLFOeEgdn1ACQI,32880
159
159
  vastdb/transaction.py,sha256=qu2rOlR7AS1ojMOzgWapQMpcorrutelZZLH1mLmTHxk,3186
160
- vastdb/util.py,sha256=4LTYBBR13na376AmDm5lQILJzLcfelIKdkNPy0IqI0o,5684
160
+ vastdb/util.py,sha256=2W5bBnlihIFvdV4im4HiDLArEhU8zjKMZB3Xw0lzgz0,5888
161
161
  vastdb/bench/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
162
162
  vastdb/bench/test_perf.py,sha256=yn5gE7t_nzmJHBl9bCs1hxQOgzhvFphuYElsWGko8ts,1084
163
163
  vastdb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -167,13 +167,13 @@ vastdb/tests/test_nested.py,sha256=22NAxBTm7Aq-Vn6AIYbi5Cb1ET8W0XeLK3pp4D8BYWI,3
167
167
  vastdb/tests/test_projections.py,sha256=3y1kubwVrzO-xoR0hyps7zrjOJI8niCYspaFTN16Q9w,4540
168
168
  vastdb/tests/test_sanity.py,sha256=V6dO5Y44B6pG8Eet6atTTGGH1yPz75_k0ZybHY-IiF8,3039
169
169
  vastdb/tests/test_schemas.py,sha256=l70YQMlx2UL1KRQhApriiG2ZM7GJF-IzWU31H3Yqn1U,3312
170
- vastdb/tests/test_tables.py,sha256=YhkeeTHq8aW1RgU86GolJl1dG3KGTlVG97Bny9RzyrM,30124
170
+ vastdb/tests/test_tables.py,sha256=RlwVfzs2hjfs2gchiRY0hnWoOAu4MV_9NbQCeHR6_us,31590
171
171
  vastdb/tests/test_util.py,sha256=Ok_sAEBJsRGF5Voa_v5eu3eAd52GWu8jMjjQbadwW-s,1260
172
172
  vastdb/tests/util.py,sha256=dpRJYbboDnlqL4qIdvScpp8--5fxRUBIcIYitrfcj9o,555
173
173
  vastdb/vast_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
174
- vastdb/vast_tests/test_ha.py,sha256=icLgf88wR_O_cy0x37zDPfjQLkHxboah1J2xZBjjA7E,988
175
- vastdb-0.1.8.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
176
- vastdb-0.1.8.dist-info/METADATA,sha256=uGYK9n-Li00OBDVWsK5qiTYN9yN5FApeLHgvSJ9ksEU,1350
177
- vastdb-0.1.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
178
- vastdb-0.1.8.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
179
- vastdb-0.1.8.dist-info/RECORD,,
174
+ vastdb/vast_tests/test_ha.py,sha256=744P4G6VJ09RIkHhMQL4wlipCBJWQVMhyvUrSc4k1HQ,975
175
+ vastdb-0.1.9.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
176
+ vastdb-0.1.9.dist-info/METADATA,sha256=YRP3W_JzaDywneqZ0cFWJzLbLE_NGf9QYja6-CFwQl4,1350
177
+ vastdb-0.1.9.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
178
+ vastdb-0.1.9.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
179
+ vastdb-0.1.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5