vastdb 0.0.5.3__py3-none-any.whl → 0.1.1__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.
- vast_flatbuf/tabular/GetTableStatsResponse.py +45 -1
- vast_flatbuf/tabular/VipRange.py +56 -0
- vastdb/__init__.py +7 -0
- vastdb/bench/test_perf.py +29 -0
- vastdb/bucket.py +85 -0
- vastdb/{tests/conftest.py → conftest.py} +29 -14
- vastdb/errors.py +175 -0
- vastdb/{api.py → internal_commands.py} +373 -875
- vastdb/schema.py +85 -0
- vastdb/session.py +47 -0
- vastdb/table.py +483 -0
- vastdb/tests/test_imports.py +123 -0
- vastdb/tests/test_nested.py +28 -0
- vastdb/tests/test_projections.py +42 -0
- vastdb/tests/test_sanity.py +34 -15
- vastdb/tests/test_schemas.py +30 -6
- vastdb/tests/test_tables.py +628 -13
- vastdb/tests/util.py +18 -0
- vastdb/transaction.py +54 -0
- vastdb/util.py +11 -10
- vastdb-0.1.1.dist-info/METADATA +38 -0
- {vastdb-0.0.5.3.dist-info → vastdb-0.1.1.dist-info}/RECORD +26 -31
- vast_protobuf/substrait/__init__.py +0 -0
- vast_protobuf/substrait/algebra_pb2.py +0 -1344
- vast_protobuf/substrait/capabilities_pb2.py +0 -46
- vast_protobuf/substrait/ddl_pb2.py +0 -57
- vast_protobuf/substrait/extended_expression_pb2.py +0 -49
- vast_protobuf/substrait/extensions/__init__.py +0 -0
- vast_protobuf/substrait/extensions/extensions_pb2.py +0 -89
- vast_protobuf/substrait/function_pb2.py +0 -168
- vast_protobuf/substrait/parameterized_types_pb2.py +0 -181
- vast_protobuf/substrait/plan_pb2.py +0 -67
- vast_protobuf/substrait/type_expressions_pb2.py +0 -198
- vast_protobuf/substrait/type_pb2.py +0 -350
- vast_protobuf/tabular/__init__.py +0 -0
- vast_protobuf/tabular/rpc_pb2.py +0 -344
- vastdb/bench_scan.py +0 -45
- vastdb/tests/test_create_table_from_parquets.py +0 -50
- vastdb/v2.py +0 -360
- vastdb-0.0.5.3.dist-info/METADATA +0 -47
- {vast_protobuf → vastdb/bench}/__init__.py +0 -0
- {vastdb-0.0.5.3.dist-info → vastdb-0.1.1.dist-info}/LICENSE +0 -0
- {vastdb-0.0.5.3.dist-info → vastdb-0.1.1.dist-info}/WHEEL +0 -0
- {vastdb-0.0.5.3.dist-info → vastdb-0.1.1.dist-info}/top_level.txt +0 -0
vastdb/transaction.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""VAST Database transaction.
|
|
2
|
+
|
|
3
|
+
A transcation is used as a context manager, since every Database-related operation in VAST requires a transaction.
|
|
4
|
+
|
|
5
|
+
with session.transaction() as tx:
|
|
6
|
+
tx.bucket("bucket").create_schema("schema")
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
import botocore
|
|
13
|
+
|
|
14
|
+
from . import bucket, errors, session
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class Transaction:
|
|
20
|
+
"""A holder of a single VAST transaction."""
|
|
21
|
+
|
|
22
|
+
_rpc: "session.Session"
|
|
23
|
+
txid: int = None
|
|
24
|
+
|
|
25
|
+
def __enter__(self):
|
|
26
|
+
"""Create a transaction and store its ID."""
|
|
27
|
+
response = self._rpc.api.begin_transaction()
|
|
28
|
+
self.txid = int(response.headers['tabular-txid'])
|
|
29
|
+
log.debug("opened txid=%016x", self.txid)
|
|
30
|
+
return self
|
|
31
|
+
|
|
32
|
+
def __exit__(self, exc_type, exc_value, exc_traceback):
|
|
33
|
+
"""On success, the transaction is committed. Otherwise, it is rolled back."""
|
|
34
|
+
if (exc_type, exc_value, exc_traceback) == (None, None, None):
|
|
35
|
+
log.debug("committing txid=%016x", self.txid)
|
|
36
|
+
self._rpc.api.commit_transaction(self.txid)
|
|
37
|
+
else:
|
|
38
|
+
log.exception("rolling back txid=%016x due to:", self.txid)
|
|
39
|
+
self._rpc.api.rollback_transaction(self.txid)
|
|
40
|
+
|
|
41
|
+
def __repr__(self):
|
|
42
|
+
"""Don't show the session details."""
|
|
43
|
+
return f'Transaction(id=0x{self.txid:016x})'
|
|
44
|
+
|
|
45
|
+
def bucket(self, name: str) -> "bucket.Bucket":
|
|
46
|
+
"""Return a VAST Bucket, if exists."""
|
|
47
|
+
try:
|
|
48
|
+
self._rpc.s3.head_bucket(Bucket=name)
|
|
49
|
+
except botocore.exceptions.ClientError as e:
|
|
50
|
+
log.warning("res: %s", e.response)
|
|
51
|
+
if e.response['Error']['Code'] == '404':
|
|
52
|
+
raise errors.MissingBucket(name)
|
|
53
|
+
raise
|
|
54
|
+
return bucket.Bucket(name, self)
|
vastdb/util.py
CHANGED
|
@@ -4,14 +4,16 @@ from typing import Callable
|
|
|
4
4
|
import pyarrow as pa
|
|
5
5
|
import pyarrow.parquet as pq
|
|
6
6
|
|
|
7
|
-
from
|
|
8
|
-
|
|
7
|
+
from .errors import InvalidArgument
|
|
8
|
+
from .schema import Schema
|
|
9
|
+
from .table import ImportConfig, Table
|
|
9
10
|
|
|
10
11
|
log = logging.getLogger(__name__)
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def create_table_from_files(
|
|
14
|
-
schema: Schema, table_name: str, parquet_files: [str], schema_merge_func: Callable = None
|
|
15
|
+
schema: Schema, table_name: str, parquet_files: [str], schema_merge_func: Callable = None,
|
|
16
|
+
config: ImportConfig = None) -> Table:
|
|
15
17
|
if not schema_merge_func:
|
|
16
18
|
schema_merge_func = default_schema_merge
|
|
17
19
|
else:
|
|
@@ -22,17 +24,16 @@ def create_table_from_files(
|
|
|
22
24
|
access_key=tx._rpc.api.access_key, secret_key=tx._rpc.api.secret_key, endpoint_override=tx._rpc.api.url)
|
|
23
25
|
for prq_file in parquet_files:
|
|
24
26
|
if not prq_file.startswith('/'):
|
|
25
|
-
raise
|
|
27
|
+
raise InvalidArgument(f"Path {prq_file} must start with a '/'")
|
|
26
28
|
parquet_ds = pq.ParquetDataset(prq_file.lstrip('/'), filesystem=s3fs)
|
|
27
29
|
current_schema = schema_merge_func(current_schema, parquet_ds.schema)
|
|
28
30
|
|
|
29
|
-
|
|
30
31
|
log.info("Creating table %s from %d Parquet files, with columns: %s",
|
|
31
32
|
table_name, len(parquet_files), list(current_schema))
|
|
32
33
|
table = schema.create_table(table_name, current_schema)
|
|
33
34
|
|
|
34
35
|
log.info("Starting import of %d files to table: %s", len(parquet_files), table)
|
|
35
|
-
table.import_files(parquet_files)
|
|
36
|
+
table.import_files(parquet_files, config=config)
|
|
36
37
|
log.info("Finished import of %d files to table: %s", len(parquet_files), table)
|
|
37
38
|
return table
|
|
38
39
|
|
|
@@ -40,7 +41,7 @@ def create_table_from_files(
|
|
|
40
41
|
def default_schema_merge(current_schema: pa.Schema, new_schema: pa.Schema) -> pa.Schema:
|
|
41
42
|
"""
|
|
42
43
|
This function validates a schema is contained in another schema
|
|
43
|
-
Raises an
|
|
44
|
+
Raises an InvalidArgument if a certain field does not exist in the target schema
|
|
44
45
|
"""
|
|
45
46
|
if not current_schema.names:
|
|
46
47
|
return new_schema
|
|
@@ -55,17 +56,17 @@ def default_schema_merge(current_schema: pa.Schema, new_schema: pa.Schema) -> pa
|
|
|
55
56
|
|
|
56
57
|
if not s1.issubset(s2):
|
|
57
58
|
log.error("Schema mismatch. schema: %s isn't contained in schema: %s.", s1, s2)
|
|
58
|
-
raise
|
|
59
|
+
raise InvalidArgument("Found mismatch in parquet files schemas.")
|
|
59
60
|
return result
|
|
60
61
|
|
|
61
62
|
|
|
62
63
|
def strict_schema_merge(current_schema: pa.Schema, new_schema: pa.Schema) -> pa.Schema:
|
|
63
64
|
"""
|
|
64
65
|
This function validates two Schemas are identical.
|
|
65
|
-
Raises an
|
|
66
|
+
Raises an InvalidArgument if schemas aren't identical.
|
|
66
67
|
"""
|
|
67
68
|
if current_schema.names and current_schema != new_schema:
|
|
68
|
-
raise
|
|
69
|
+
raise InvalidArgument(f"Schemas are not identical. \n {current_schema} \n vs \n {new_schema}")
|
|
69
70
|
|
|
70
71
|
return new_schema
|
|
71
72
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vastdb
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: VAST Data SDK
|
|
5
|
+
Home-page: https://github.com/vast-data/vastdb_sdk
|
|
6
|
+
Author: VAST DATA
|
|
7
|
+
Author-email: hello@vastdata.com
|
|
8
|
+
License: Copyright (C) VAST Data Ltd.
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Database
|
|
18
|
+
Classifier: Topic :: Database :: Front-Ends
|
|
19
|
+
Requires-Python: >=3.9.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: aws-requests-auth
|
|
23
|
+
Requires-Dist: boto3
|
|
24
|
+
Requires-Dist: flatbuffers
|
|
25
|
+
Requires-Dist: ibis-framework
|
|
26
|
+
Requires-Dist: pyarrow
|
|
27
|
+
Requires-Dist: requests
|
|
28
|
+
Requires-Dist: xmltodict
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
`vastdb` is a Python-based SDK designed for interacting
|
|
32
|
+
with [VAST Database](https://vastdata.com/database)
|
|
33
|
+
and [VAST Catalog](https://vastdata.com/blog/vast-catalog-treat-your-file-system-like-a-database),
|
|
34
|
+
enabling schema and table management, efficient ingest, query and modification of columnar data.
|
|
35
|
+
|
|
36
|
+
For more details, see [our whitepaper](https://vastdata.com/whitepaper/#TheVASTDataBase).
|
|
37
|
+
|
|
38
|
+
|
|
@@ -139,42 +139,37 @@ vast_flatbuf/tabular/ColumnType.py,sha256=_4-jMG08VR2zdn1ZH7F4aahYPxWsBSm7adUoVf
|
|
|
139
139
|
vast_flatbuf/tabular/CreateProjectionRequest.py,sha256=POlK1DrYMAldNJscLIRL3j4jAT0Sv_fRzfvBXwZAAMw,2516
|
|
140
140
|
vast_flatbuf/tabular/CreateSchemaRequest.py,sha256=MrOfWaFu0Q1-mxLlGV8YMPajZ5kASyvowVSrKU-NPx8,1626
|
|
141
141
|
vast_flatbuf/tabular/GetProjectionTableStatsResponse.py,sha256=Bp-ln-0lcZEiUvp3vWYmnCP6t2UsZ5J-lezgkUUWhzo,3474
|
|
142
|
-
vast_flatbuf/tabular/GetTableStatsResponse.py,sha256=
|
|
142
|
+
vast_flatbuf/tabular/GetTableStatsResponse.py,sha256=_UsKj6-VAvyDZ8Eku9fegQlRKV-T_0Dsb7qjulYoZus,4655
|
|
143
143
|
vast_flatbuf/tabular/ImportDataRequest.py,sha256=f1chKp5d5NUxfNjI8YI1o4MYInF8UDhIhpWkT3vG4Do,2450
|
|
144
144
|
vast_flatbuf/tabular/ListProjectionsResponse.py,sha256=secqrBsJY3ydbA28j09rmxzBqj-c1JNqaP7JMuib7nE,4240
|
|
145
145
|
vast_flatbuf/tabular/ListSchemasResponse.py,sha256=V8tbwcWAC96eNwuoqDNqCSb02BnMdq60TpyISuWTVMk,3036
|
|
146
146
|
vast_flatbuf/tabular/ListTablesResponse.py,sha256=V7jZAS8ryKY8s6o_QyjWzgan-rsGm17zjKEmi7K6qTM,3550
|
|
147
147
|
vast_flatbuf/tabular/ObjectDetails.py,sha256=qW0WtbkCYYE_L-Kw6VNRDCLYaRm5lKvTbLNkfD4zV4A,3589
|
|
148
148
|
vast_flatbuf/tabular/S3File.py,sha256=KC9c2oS5-JXwTTriUVFdjOvRG0B54Cq9kviSDZY3NI0,4450
|
|
149
|
+
vast_flatbuf/tabular/VipRange.py,sha256=_BJd1RRZAcK76T9vlsHzXKYVsPVaz6WTEAqStMQCAUQ,2069
|
|
149
150
|
vast_flatbuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
vast_protobuf/substrait/extensions/extensions_pb2.py,sha256=I_6c6nMmMaYvVtzF-5ycqpzFYlsAVlKQDyatoU8RewQ,6110
|
|
163
|
-
vast_protobuf/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
|
-
vast_protobuf/tabular/rpc_pb2.py,sha256=7kW2WrA2sGk6WVbD83mc_cKkZ2MxoImSO5GOVz6NbbE,23776
|
|
165
|
-
vastdb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
166
|
-
vastdb/api.py,sha256=u5Cf01LeHGN7x_pcjnzfLV-lU485FGFCv7eTIKpSaB0,124883
|
|
167
|
-
vastdb/bench_scan.py,sha256=95O34oHS0UehX2ad4T2mok87CKszCFLCDZASMnZp77M,1208
|
|
168
|
-
vastdb/util.py,sha256=EF892Gbs08BxHVgG3FZ6QvhpKI2-eIL5bPzzrYE_Qd8,2905
|
|
169
|
-
vastdb/v2.py,sha256=gWZUnhSLEvtrXPxoTpTAwNuzU9qxrCaWKXmeNBpMrGY,12601
|
|
151
|
+
vastdb/__init__.py,sha256=GY30IfZQApfl7HfcFmfTzFpx48oHgQIrDcUQCiTnxpo,206
|
|
152
|
+
vastdb/bucket.py,sha256=5J8KBdRViaz5bZ8WEPggQj7DfJaIhY7CqpoWP6reaDo,2854
|
|
153
|
+
vastdb/conftest.py,sha256=pKpo_46Vq4QHzTDQAFxasrVhnZ2V2L-y6IMLxojxaFM,2132
|
|
154
|
+
vastdb/errors.py,sha256=wCJp70QyBW8US2KMwhB6e5ZnKRft4GiN8jyJ36f1Yuo,3315
|
|
155
|
+
vastdb/internal_commands.py,sha256=rmxOjIq229gsxFFZ4nKXwVIFJcu8WR1DVsE-91w4-BY,101564
|
|
156
|
+
vastdb/schema.py,sha256=x9Yn4tFTFkSpJbQqpqlecKUSOK214XsRLdOUrNW0jzM,3192
|
|
157
|
+
vastdb/session.py,sha256=VZOFGZbAdr5Tl4cp88VRQYnR4Q16UNuYjSmX_QPW1II,1718
|
|
158
|
+
vastdb/table.py,sha256=eALN5YpUfDFqZNF_lp6lZD5RJkBKqp5Mlc6hpwGI8Rg,20443
|
|
159
|
+
vastdb/transaction.py,sha256=2I5k81YvcgDsp07BrAWkmXf41qUP6m88Y40rFfuIKvI,1796
|
|
160
|
+
vastdb/util.py,sha256=VR0UJ1D0WUpqS5edG_mkxDZYZJ_qqce8y7iJOvqeyWE,2974
|
|
161
|
+
vastdb/bench/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
162
|
+
vastdb/bench/test_perf.py,sha256=X7BIo60L5Oj7H-56e8pDFtXY9rNLerkywKexXWiqvrY,1111
|
|
170
163
|
vastdb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
171
|
-
vastdb/tests/
|
|
172
|
-
vastdb/tests/
|
|
173
|
-
vastdb/tests/
|
|
174
|
-
vastdb/tests/
|
|
175
|
-
vastdb/tests/
|
|
176
|
-
vastdb
|
|
177
|
-
vastdb
|
|
178
|
-
vastdb-0.
|
|
179
|
-
vastdb-0.
|
|
180
|
-
vastdb-0.
|
|
164
|
+
vastdb/tests/test_imports.py,sha256=fDUjO5U-5i4QTIMoNnSSW4X_ZnOStLbx0mJkNq2pj9Q,5033
|
|
165
|
+
vastdb/tests/test_nested.py,sha256=3kejEvtSqV0LrUgb1QglRjrlxnKI4_AXTFw2nE7Q520,951
|
|
166
|
+
vastdb/tests/test_projections.py,sha256=0ZiFya6rzGvnKOrdb1xxxv-BEerNmiK_ymfZM6eIvvw,1254
|
|
167
|
+
vastdb/tests/test_sanity.py,sha256=kaOmZWDGBc-XhZ8eFQ3sks2Mo9De8q41Z5pqYWzJsHM,2958
|
|
168
|
+
vastdb/tests/test_schemas.py,sha256=8ZlEvnU7Fyg-TDQDxD65GAql4rU8R2_SFWVGrdv564o,1721
|
|
169
|
+
vastdb/tests/test_tables.py,sha256=o_JPqr2GX1DDpPB4Zq4E1YPFgmlsiXyVe1S3TcCjF-w,26226
|
|
170
|
+
vastdb/tests/util.py,sha256=_euE3fKJqgNssT9gVxlcHjdE61mnsNQcwDPzn1tTe9g,597
|
|
171
|
+
vastdb-0.1.1.dist-info/LICENSE,sha256=obffan7LYrq7hLHNrY7vHcn2pKUTBUYXMKu-VOAvDxU,11333
|
|
172
|
+
vastdb-0.1.1.dist-info/METADATA,sha256=e84OEOXS09DEXniHJAU2aeK80-1h2rIZmYNBCMLa1AM,1331
|
|
173
|
+
vastdb-0.1.1.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
174
|
+
vastdb-0.1.1.dist-info/top_level.txt,sha256=Vsj2MKtlhPg0J4so64slQtnwjhgoPmJgcG-6YcVAwVc,20
|
|
175
|
+
vastdb-0.1.1.dist-info/RECORD,,
|
|
File without changes
|