pygtvdb 0.1.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.
- gtvdb/__init__.py +143 -0
- gtvdb/_params.py +193 -0
- gtvdb/_stubs/__init__.py +26 -0
- gtvdb/_stubs/gtvquery_pb2.py +48 -0
- gtvdb/_stubs/gtvquery_pb2.pyi +90 -0
- gtvdb/_stubs/gtvquery_pb2_grpc.py +216 -0
- gtvdb/_version.py +9 -0
- gtvdb/client.py +450 -0
- gtvdb/connection.py +214 -0
- gtvdb/cursor.py +265 -0
- gtvdb/errors.py +83 -0
- gtvdb/py.typed +0 -0
- pygtvdb-0.1.0.dist-info/METADATA +147 -0
- pygtvdb-0.1.0.dist-info/RECORD +17 -0
- pygtvdb-0.1.0.dist-info/WHEEL +5 -0
- pygtvdb-0.1.0.dist-info/licenses/LICENSE.md +201 -0
- pygtvdb-0.1.0.dist-info/top_level.txt +1 -0
gtvdb/__init__.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""gtvdb — a DB-API 2.0 driver for the gtv temporal-graph engine.
|
|
2
|
+
|
|
3
|
+
import gtvdb
|
|
4
|
+
|
|
5
|
+
with gtvdb.connect("gtv://127.0.0.1:50051") as con:
|
|
6
|
+
with con.cursor() as cur:
|
|
7
|
+
cur.execute("SELECT * FROM numbers WHERE n <= ?", (3,))
|
|
8
|
+
print(cur.fetchall()) # [(1, 1.0), (2, 4.0), (3, 9.0)]
|
|
9
|
+
|
|
10
|
+
import pandas as pd
|
|
11
|
+
print(pd.read_sql("SELECT * FROM prices", con))
|
|
12
|
+
|
|
13
|
+
Install with `pip install pygtvdb`; there is nothing to compile — the driver is
|
|
14
|
+
pure Python over gRPC, and Arrow comes from `pyarrow`.
|
|
15
|
+
|
|
16
|
+
# The three layers, in case you need to drop below DB-API
|
|
17
|
+
|
|
18
|
+
| layer | object | what it adds |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| DB-API 2.0 | `Connection` / `Cursor` | `execute` / `fetchall` / `description`, pandas, SQLAlchemy |
|
|
21
|
+
| session | `Session` / `Result` | `as_of` pinning, `QueryReceipt`, `tri_state` |
|
|
22
|
+
| wire | `gtvdb._stubs` | `gtvquery.QueryService`, protocol v1 |
|
|
23
|
+
|
|
24
|
+
DB-API has no vocabulary for "this empty result proves nothing", so the cursor
|
|
25
|
+
keeps the engine's own answer: `cur.tri_state == "no_match"` means absence was
|
|
26
|
+
proven, `"incomplete"` means it was not. Detection workloads must read it;
|
|
27
|
+
reporting workloads can ignore it.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
from typing import Any, Optional
|
|
33
|
+
|
|
34
|
+
from . import _version
|
|
35
|
+
from .client import DEFAULT_ADDR, GtvError, Result, Session
|
|
36
|
+
from .connection import Connection
|
|
37
|
+
from .cursor import (
|
|
38
|
+
BINARY,
|
|
39
|
+
BOOLEAN,
|
|
40
|
+
DATETIME,
|
|
41
|
+
INTEGER,
|
|
42
|
+
NUMBER,
|
|
43
|
+
ROWID,
|
|
44
|
+
STRING,
|
|
45
|
+
Cursor,
|
|
46
|
+
)
|
|
47
|
+
from .errors import (
|
|
48
|
+
DataError,
|
|
49
|
+
DatabaseError,
|
|
50
|
+
Error,
|
|
51
|
+
IntegrityError,
|
|
52
|
+
InterfaceError,
|
|
53
|
+
InternalError,
|
|
54
|
+
NotSupportedError,
|
|
55
|
+
OperationalError,
|
|
56
|
+
ProgrammingError,
|
|
57
|
+
Warning,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
#: Single-sourced from `_version.py` so `pyproject.toml` and the runtime can
|
|
61
|
+
#: never disagree about what was published.
|
|
62
|
+
__version__ = _version.__version__
|
|
63
|
+
|
|
64
|
+
# --- PEP 249 module attributes ---------------------------------------------
|
|
65
|
+
apilevel = "2.0"
|
|
66
|
+
#: Threads may share the module and connections (the gRPC channel is thread
|
|
67
|
+
#: safe, and each cursor owns its result). Cursors themselves are not shared.
|
|
68
|
+
threadsafety = 2
|
|
69
|
+
#: `?` placeholders, rendered client-side (see `_params.py` for the exact rules).
|
|
70
|
+
paramstyle = "qmark"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def connect(
|
|
74
|
+
dsn: Optional[str] = None,
|
|
75
|
+
*,
|
|
76
|
+
host: str = "127.0.0.1",
|
|
77
|
+
port: int = 50051,
|
|
78
|
+
as_of: Optional[int] = None,
|
|
79
|
+
snapshot_id: Optional[int] = None,
|
|
80
|
+
token: Optional[str] = None,
|
|
81
|
+
ca_cert: Optional[str] = None,
|
|
82
|
+
timeout_ms: Optional[int] = None,
|
|
83
|
+
**kwargs: Any,
|
|
84
|
+
) -> Connection:
|
|
85
|
+
"""Open a connection. `dsn` is `gtv://host:port`, or pass `host`/`port`.
|
|
86
|
+
|
|
87
|
+
gtvdb.connect() # 127.0.0.1:50051
|
|
88
|
+
gtvdb.connect("gtv://engine.internal:50061")
|
|
89
|
+
gtvdb.connect("gtv://host:50051?as_of=1700000000000000000")
|
|
90
|
+
gtvdb.connect(host="10.0.0.5", port=50051, token="...")
|
|
91
|
+
|
|
92
|
+
`as_of` pins business time for every query on this connection — the
|
|
93
|
+
equivalent of opening a kdb+ session at T. `token` is sent as a bearer
|
|
94
|
+
token; `ca_cert` is a PEM path and switches the channel to TLS.
|
|
95
|
+
"""
|
|
96
|
+
if kwargs:
|
|
97
|
+
unknown = ", ".join(sorted(kwargs))
|
|
98
|
+
raise TypeError(f"connect() got unexpected keyword argument(s): {unknown}")
|
|
99
|
+
return Connection.open(
|
|
100
|
+
dsn,
|
|
101
|
+
host=host,
|
|
102
|
+
port=port,
|
|
103
|
+
as_of=as_of,
|
|
104
|
+
snapshot_id=snapshot_id,
|
|
105
|
+
token=token,
|
|
106
|
+
ca_cert=ca_cert,
|
|
107
|
+
timeout_ms=timeout_ms,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
__all__ = [
|
|
112
|
+
# PEP 249
|
|
113
|
+
"apilevel",
|
|
114
|
+
"threadsafety",
|
|
115
|
+
"paramstyle",
|
|
116
|
+
"connect",
|
|
117
|
+
"Connection",
|
|
118
|
+
"Cursor",
|
|
119
|
+
"Warning",
|
|
120
|
+
"Error",
|
|
121
|
+
"InterfaceError",
|
|
122
|
+
"DatabaseError",
|
|
123
|
+
"DataError",
|
|
124
|
+
"OperationalError",
|
|
125
|
+
"IntegrityError",
|
|
126
|
+
"InternalError",
|
|
127
|
+
"ProgrammingError",
|
|
128
|
+
"NotSupportedError",
|
|
129
|
+
# type objects for `description`
|
|
130
|
+
"STRING",
|
|
131
|
+
"BINARY",
|
|
132
|
+
"NUMBER",
|
|
133
|
+
"INTEGER",
|
|
134
|
+
"DATETIME",
|
|
135
|
+
"ROWID",
|
|
136
|
+
"BOOLEAN",
|
|
137
|
+
# lower layers
|
|
138
|
+
"Session",
|
|
139
|
+
"Result",
|
|
140
|
+
"GtvError",
|
|
141
|
+
"DEFAULT_ADDR",
|
|
142
|
+
"__version__",
|
|
143
|
+
]
|
gtvdb/_params.py
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""Client-side parameter rendering (`paramstyle = "qmark"`).
|
|
2
|
+
|
|
3
|
+
Why client-side: protocol v1 carries SQL as a string with no bind slots
|
|
4
|
+
(`QueryRequest` has no parameter array). Rather than pretend, this module
|
|
5
|
+
renders values into literals *carefully* and says so:
|
|
6
|
+
|
|
7
|
+
* `?` placeholders are replaced only outside string literals, quoted
|
|
8
|
+
identifiers and comments, so `WHERE s = 'a?b'` is untouched;
|
|
9
|
+
* values are rendered as literals of the right type (quoted text with `''`
|
|
10
|
+
doubled, `X'..'` for bytes, `TIMESTAMP '..'` for datetimes) — never by
|
|
11
|
+
`str()`-ing them into the SQL;
|
|
12
|
+
* `None` becomes `NULL`, which is the only rendering that can never be wrong.
|
|
13
|
+
|
|
14
|
+
This is the same compromise `sqlite3` makes when it interpolates, and it is
|
|
15
|
+
safe against injection because values never reach the SQL text unquoted. It is
|
|
16
|
+
*not* as strong as a real bind protocol: a parameter cannot be used in places
|
|
17
|
+
where a literal is illegal (an identifier, a `LIMIT` clause in some planners),
|
|
18
|
+
and the engine re-plans on every call. Bound parameters are a protocol v2 item;
|
|
19
|
+
until then, `paramstyle` tells the truth about what happens.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import datetime as _dt
|
|
25
|
+
import decimal
|
|
26
|
+
from typing import Any, Mapping, Sequence
|
|
27
|
+
|
|
28
|
+
from .errors import ProgrammingError, DataError
|
|
29
|
+
|
|
30
|
+
_NAMED_START = set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_")
|
|
31
|
+
_NAMED_BODY = _NAMED_START | set("0123456789")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def render(sql: str, params: Any) -> str:
|
|
35
|
+
"""Substitute `params` into `sql`. `None`/empty means "nothing to do"."""
|
|
36
|
+
if params is None:
|
|
37
|
+
return sql
|
|
38
|
+
if isinstance(params, Mapping):
|
|
39
|
+
return _render_named(sql, params)
|
|
40
|
+
if isinstance(params, (str, bytes)):
|
|
41
|
+
raise ProgrammingError("parameters must be a sequence or a mapping, not a string")
|
|
42
|
+
return _render_qmark(sql, list(params))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _render_qmark(sql: str, values: Sequence[Any]) -> str:
|
|
46
|
+
out: list[str] = []
|
|
47
|
+
used = 0
|
|
48
|
+
i, n = 0, len(sql)
|
|
49
|
+
while i < n:
|
|
50
|
+
ch = sql[i]
|
|
51
|
+
if ch in ("'", '"'):
|
|
52
|
+
chunk, i = _quoted(sql, i)
|
|
53
|
+
out.append(chunk)
|
|
54
|
+
continue
|
|
55
|
+
if sql.startswith("--", i):
|
|
56
|
+
chunk, i = _to_eol(sql, i)
|
|
57
|
+
out.append(chunk)
|
|
58
|
+
continue
|
|
59
|
+
if sql.startswith("/*", i):
|
|
60
|
+
chunk, i = _block_comment(sql, i)
|
|
61
|
+
out.append(chunk)
|
|
62
|
+
continue
|
|
63
|
+
if ch == "?":
|
|
64
|
+
if used >= len(values):
|
|
65
|
+
raise ProgrammingError(
|
|
66
|
+
f"not enough parameters: query has more than {len(values)} placeholder(s)"
|
|
67
|
+
)
|
|
68
|
+
out.append(literal(values[used]))
|
|
69
|
+
used += 1
|
|
70
|
+
i += 1
|
|
71
|
+
continue
|
|
72
|
+
out.append(ch)
|
|
73
|
+
i += 1
|
|
74
|
+
|
|
75
|
+
if used != len(values):
|
|
76
|
+
raise ProgrammingError(
|
|
77
|
+
f"parameter count mismatch: {len(values)} given, {used} placeholder(s)"
|
|
78
|
+
)
|
|
79
|
+
return "".join(out)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _render_named(sql: str, values: Mapping[str, Any]) -> str:
|
|
83
|
+
out: list[str] = []
|
|
84
|
+
seen: set[str] = set()
|
|
85
|
+
i, n = 0, len(sql)
|
|
86
|
+
while i < n:
|
|
87
|
+
ch = sql[i]
|
|
88
|
+
if ch in ("'", '"'):
|
|
89
|
+
chunk, i = _quoted(sql, i)
|
|
90
|
+
out.append(chunk)
|
|
91
|
+
continue
|
|
92
|
+
if sql.startswith("--", i):
|
|
93
|
+
chunk, i = _to_eol(sql, i)
|
|
94
|
+
out.append(chunk)
|
|
95
|
+
continue
|
|
96
|
+
if sql.startswith("/*", i):
|
|
97
|
+
chunk, i = _block_comment(sql, i)
|
|
98
|
+
out.append(chunk)
|
|
99
|
+
continue
|
|
100
|
+
# `::` is a cast, not two placeholders: consume it whole so the second
|
|
101
|
+
# colon cannot be re-read as `:bigint`.
|
|
102
|
+
if sql.startswith("::", i):
|
|
103
|
+
out.append("::")
|
|
104
|
+
i += 2
|
|
105
|
+
continue
|
|
106
|
+
if ch == ":" and i + 1 < n and sql[i + 1] in _NAMED_START:
|
|
107
|
+
j = i + 1
|
|
108
|
+
while j < n and sql[j] in _NAMED_BODY:
|
|
109
|
+
j += 1
|
|
110
|
+
name = sql[i + 1 : j]
|
|
111
|
+
if name not in values:
|
|
112
|
+
raise ProgrammingError(f"missing value for parameter :{name}")
|
|
113
|
+
out.append(literal(values[name]))
|
|
114
|
+
seen.add(name)
|
|
115
|
+
i = j
|
|
116
|
+
continue
|
|
117
|
+
out.append(ch)
|
|
118
|
+
i += 1
|
|
119
|
+
|
|
120
|
+
unused = set(values) - seen
|
|
121
|
+
if unused:
|
|
122
|
+
raise ProgrammingError(
|
|
123
|
+
"unused parameter(s): " + ", ".join(sorted(unused))
|
|
124
|
+
)
|
|
125
|
+
return "".join(out)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# ---------------------------------------------------------------------------
|
|
129
|
+
# Literal rendering
|
|
130
|
+
# ---------------------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def literal(value: Any) -> str:
|
|
134
|
+
"""Render one Python value as a SQL literal of the matching type."""
|
|
135
|
+
if value is None:
|
|
136
|
+
return "NULL"
|
|
137
|
+
if isinstance(value, bool): # before int: bool is an int subclass
|
|
138
|
+
return "TRUE" if value else "FALSE"
|
|
139
|
+
if isinstance(value, int):
|
|
140
|
+
return str(value)
|
|
141
|
+
if isinstance(value, float):
|
|
142
|
+
if value != value or value in (float("inf"), float("-inf")):
|
|
143
|
+
raise DataError(f"non-finite float cannot be a literal: {value!r}")
|
|
144
|
+
return repr(value)
|
|
145
|
+
if isinstance(value, decimal.Decimal):
|
|
146
|
+
if not value.is_finite():
|
|
147
|
+
raise DataError(f"non-finite decimal cannot be a literal: {value!r}")
|
|
148
|
+
return str(value)
|
|
149
|
+
if isinstance(value, str):
|
|
150
|
+
return "'" + value.replace("'", "''") + "'"
|
|
151
|
+
if isinstance(value, (bytes, bytearray, memoryview)):
|
|
152
|
+
return "X'" + bytes(value).hex() + "'"
|
|
153
|
+
if isinstance(value, _dt.datetime):
|
|
154
|
+
return "TIMESTAMP '" + value.isoformat(sep=" ") + "'"
|
|
155
|
+
if isinstance(value, _dt.date):
|
|
156
|
+
return "DATE '" + value.isoformat() + "'"
|
|
157
|
+
if isinstance(value, _dt.time):
|
|
158
|
+
return "TIME '" + value.isoformat() + "'"
|
|
159
|
+
raise DataError(
|
|
160
|
+
f"unsupported parameter type {type(value).__name__}; "
|
|
161
|
+
"pass a scalar, str, bytes, date, datetime, Decimal, or None"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# ---------------------------------------------------------------------------
|
|
166
|
+
# Scanner helpers: skip regions where `?` / `:name` are just text
|
|
167
|
+
# ---------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _quoted(sql: str, i: int) -> tuple[str, int]:
|
|
171
|
+
"""Read a '...' or "..." region starting at `i`, honouring doubled quotes."""
|
|
172
|
+
quote = sql[i]
|
|
173
|
+
j = i + 1
|
|
174
|
+
n = len(sql)
|
|
175
|
+
while j < n:
|
|
176
|
+
if sql[j] == quote:
|
|
177
|
+
if j + 1 < n and sql[j + 1] == quote:
|
|
178
|
+
j += 2
|
|
179
|
+
continue
|
|
180
|
+
j += 1
|
|
181
|
+
break
|
|
182
|
+
j += 1
|
|
183
|
+
return sql[i:j], j
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def _to_eol(sql: str, i: int) -> tuple[str, int]:
|
|
187
|
+
j = sql.find("\n", i)
|
|
188
|
+
return (sql[i:], len(sql)) if j < 0 else (sql[i:j], j)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _block_comment(sql: str, i: int) -> tuple[str, int]:
|
|
192
|
+
j = sql.find("*/", i + 2)
|
|
193
|
+
return (sql[i:], len(sql)) if j < 0 else (sql[i : j + 2], j + 2)
|
gtvdb/_stubs/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Generated gRPC stubs for `gtvquery.proto` (protocol v1).
|
|
2
|
+
|
|
3
|
+
Generated by `gen_stubs.py`; do not edit by hand. The only post-processing
|
|
4
|
+
applied is turning protoc's absolute `import gtvquery_pb2` into a relative
|
|
5
|
+
import so this directory works as a package.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .gtvquery_pb2 import ( # noqa: F401
|
|
9
|
+
ErrorCode,
|
|
10
|
+
QueryRequest,
|
|
11
|
+
QueryResponse,
|
|
12
|
+
TriState,
|
|
13
|
+
VersionRequest,
|
|
14
|
+
VersionResponse,
|
|
15
|
+
)
|
|
16
|
+
from .gtvquery_pb2_grpc import QueryServiceStub # noqa: F401
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"ErrorCode",
|
|
20
|
+
"QueryRequest",
|
|
21
|
+
"QueryResponse",
|
|
22
|
+
"QueryServiceStub",
|
|
23
|
+
"TriState",
|
|
24
|
+
"VersionRequest",
|
|
25
|
+
"VersionResponse",
|
|
26
|
+
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: gtvquery.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.1
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
1,
|
|
17
|
+
'',
|
|
18
|
+
'gtvquery.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0egtvquery.proto\x12\x08gtvquery\":\n\x0eVersionRequest\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x0e\n\x06\x63lient\x18\x02 \x01(\t\"\x80\x01\n\x0fVersionResponse\x12\x18\n\x10protocol_version\x18\x01 \x01(\r\x12\x15\n\rmin_supported\x18\x02 \x01(\r\x12\x15\n\rmax_supported\x18\x03 \x01(\r\x12\x16\n\x0e\x65ngine_version\x18\x04 \x01(\t\x12\r\n\x05\x65rror\x18\x05 \x01(\t\"\xb9\x01\n\x0cQueryRequest\x12\x0b\n\x03sql\x18\x01 \x01(\t\x12\x18\n\x10protocol_version\x18\x02 \x01(\r\x12\x12\n\x05\x61s_of\x18\x03 \x01(\x03H\x00\x88\x01\x01\x12\x18\n\x0bsnapshot_id\x18\x04 \x01(\x04H\x01\x88\x01\x01\x12\x12\n\nrequest_id\x18\x05 \x01(\t\x12\x17\n\ntimeout_ms\x18\x06 \x01(\x04H\x02\x88\x01\x01\x42\x08\n\x06_as_ofB\x0e\n\x0c_snapshot_idB\r\n\x0b_timeout_ms\"\xab\x01\n\rQueryResponse\x12\x11\n\tarrow_ipc\x18\x01 \x01(\x0c\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x18\n\x10protocol_version\x18\x03 \x01(\r\x12!\n\x04\x63ode\x18\x04 \x01(\x0e\x32\x13.gtvquery.ErrorCode\x12%\n\ttri_state\x18\x05 \x01(\x0e\x32\x12.gtvquery.TriState\x12\x14\n\x0creceipt_json\x18\x06 \x01(\t*\xa4\x01\n\tErrorCode\x12\x06\n\x02OK\x10\x00\x12\x14\n\x10INVALID_ARGUMENT\x10\x01\x12\x17\n\x13UNSUPPORTED_VERSION\x10\x02\x12\x15\n\x11RESULT_INCOMPLETE\x10\x03\x12\x15\n\x11SNAPSHOT_MISMATCH\x10\x04\x12\r\n\tCANCELLED\x10\x05\x12\x15\n\x11\x44\x45\x41\x44LINE_EXCEEDED\x10\x06\x12\x0c\n\x08INTERNAL\x10\x07*D\n\x08TriState\x12\t\n\x05\x46OUND\x10\x00\x12\x0c\n\x08NO_MATCH\x10\x01\x12\x0e\n\nINCOMPLETE\x10\x02\x12\x0f\n\x0bUNSPECIFIED\x10\x03\x32\xcd\x01\n\x0cQueryService\x12:\n\x07\x45xecute\x12\x16.gtvquery.QueryRequest\x1a\x17.gtvquery.QueryResponse\x12?\n\x0c\x45xecuteQuery\x12\x16.gtvquery.QueryRequest\x1a\x17.gtvquery.QueryResponse\x12@\n\tNegotiate\x12\x18.gtvquery.VersionRequest\x1a\x19.gtvquery.VersionResponseb\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'gtvquery_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_ERRORCODE']._serialized_start=582
|
|
35
|
+
_globals['_ERRORCODE']._serialized_end=746
|
|
36
|
+
_globals['_TRISTATE']._serialized_start=748
|
|
37
|
+
_globals['_TRISTATE']._serialized_end=816
|
|
38
|
+
_globals['_VERSIONREQUEST']._serialized_start=28
|
|
39
|
+
_globals['_VERSIONREQUEST']._serialized_end=86
|
|
40
|
+
_globals['_VERSIONRESPONSE']._serialized_start=89
|
|
41
|
+
_globals['_VERSIONRESPONSE']._serialized_end=217
|
|
42
|
+
_globals['_QUERYREQUEST']._serialized_start=220
|
|
43
|
+
_globals['_QUERYREQUEST']._serialized_end=405
|
|
44
|
+
_globals['_QUERYRESPONSE']._serialized_start=408
|
|
45
|
+
_globals['_QUERYRESPONSE']._serialized_end=579
|
|
46
|
+
_globals['_QUERYSERVICE']._serialized_start=819
|
|
47
|
+
_globals['_QUERYSERVICE']._serialized_end=1024
|
|
48
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
|
|
2
|
+
from google.protobuf import descriptor as _descriptor
|
|
3
|
+
from google.protobuf import message as _message
|
|
4
|
+
from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
|
|
5
|
+
|
|
6
|
+
DESCRIPTOR: _descriptor.FileDescriptor
|
|
7
|
+
|
|
8
|
+
class ErrorCode(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
9
|
+
__slots__ = ()
|
|
10
|
+
OK: _ClassVar[ErrorCode]
|
|
11
|
+
INVALID_ARGUMENT: _ClassVar[ErrorCode]
|
|
12
|
+
UNSUPPORTED_VERSION: _ClassVar[ErrorCode]
|
|
13
|
+
RESULT_INCOMPLETE: _ClassVar[ErrorCode]
|
|
14
|
+
SNAPSHOT_MISMATCH: _ClassVar[ErrorCode]
|
|
15
|
+
CANCELLED: _ClassVar[ErrorCode]
|
|
16
|
+
DEADLINE_EXCEEDED: _ClassVar[ErrorCode]
|
|
17
|
+
INTERNAL: _ClassVar[ErrorCode]
|
|
18
|
+
|
|
19
|
+
class TriState(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
|
|
20
|
+
__slots__ = ()
|
|
21
|
+
FOUND: _ClassVar[TriState]
|
|
22
|
+
NO_MATCH: _ClassVar[TriState]
|
|
23
|
+
INCOMPLETE: _ClassVar[TriState]
|
|
24
|
+
UNSPECIFIED: _ClassVar[TriState]
|
|
25
|
+
OK: ErrorCode
|
|
26
|
+
INVALID_ARGUMENT: ErrorCode
|
|
27
|
+
UNSUPPORTED_VERSION: ErrorCode
|
|
28
|
+
RESULT_INCOMPLETE: ErrorCode
|
|
29
|
+
SNAPSHOT_MISMATCH: ErrorCode
|
|
30
|
+
CANCELLED: ErrorCode
|
|
31
|
+
DEADLINE_EXCEEDED: ErrorCode
|
|
32
|
+
INTERNAL: ErrorCode
|
|
33
|
+
FOUND: TriState
|
|
34
|
+
NO_MATCH: TriState
|
|
35
|
+
INCOMPLETE: TriState
|
|
36
|
+
UNSPECIFIED: TriState
|
|
37
|
+
|
|
38
|
+
class VersionRequest(_message.Message):
|
|
39
|
+
__slots__ = ("protocol_version", "client")
|
|
40
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
41
|
+
CLIENT_FIELD_NUMBER: _ClassVar[int]
|
|
42
|
+
protocol_version: int
|
|
43
|
+
client: str
|
|
44
|
+
def __init__(self, protocol_version: _Optional[int] = ..., client: _Optional[str] = ...) -> None: ...
|
|
45
|
+
|
|
46
|
+
class VersionResponse(_message.Message):
|
|
47
|
+
__slots__ = ("protocol_version", "min_supported", "max_supported", "engine_version", "error")
|
|
48
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
49
|
+
MIN_SUPPORTED_FIELD_NUMBER: _ClassVar[int]
|
|
50
|
+
MAX_SUPPORTED_FIELD_NUMBER: _ClassVar[int]
|
|
51
|
+
ENGINE_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
52
|
+
ERROR_FIELD_NUMBER: _ClassVar[int]
|
|
53
|
+
protocol_version: int
|
|
54
|
+
min_supported: int
|
|
55
|
+
max_supported: int
|
|
56
|
+
engine_version: str
|
|
57
|
+
error: str
|
|
58
|
+
def __init__(self, protocol_version: _Optional[int] = ..., min_supported: _Optional[int] = ..., max_supported: _Optional[int] = ..., engine_version: _Optional[str] = ..., error: _Optional[str] = ...) -> None: ...
|
|
59
|
+
|
|
60
|
+
class QueryRequest(_message.Message):
|
|
61
|
+
__slots__ = ("sql", "protocol_version", "as_of", "snapshot_id", "request_id", "timeout_ms")
|
|
62
|
+
SQL_FIELD_NUMBER: _ClassVar[int]
|
|
63
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
64
|
+
AS_OF_FIELD_NUMBER: _ClassVar[int]
|
|
65
|
+
SNAPSHOT_ID_FIELD_NUMBER: _ClassVar[int]
|
|
66
|
+
REQUEST_ID_FIELD_NUMBER: _ClassVar[int]
|
|
67
|
+
TIMEOUT_MS_FIELD_NUMBER: _ClassVar[int]
|
|
68
|
+
sql: str
|
|
69
|
+
protocol_version: int
|
|
70
|
+
as_of: int
|
|
71
|
+
snapshot_id: int
|
|
72
|
+
request_id: str
|
|
73
|
+
timeout_ms: int
|
|
74
|
+
def __init__(self, sql: _Optional[str] = ..., protocol_version: _Optional[int] = ..., as_of: _Optional[int] = ..., snapshot_id: _Optional[int] = ..., request_id: _Optional[str] = ..., timeout_ms: _Optional[int] = ...) -> None: ...
|
|
75
|
+
|
|
76
|
+
class QueryResponse(_message.Message):
|
|
77
|
+
__slots__ = ("arrow_ipc", "error", "protocol_version", "code", "tri_state", "receipt_json")
|
|
78
|
+
ARROW_IPC_FIELD_NUMBER: _ClassVar[int]
|
|
79
|
+
ERROR_FIELD_NUMBER: _ClassVar[int]
|
|
80
|
+
PROTOCOL_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
81
|
+
CODE_FIELD_NUMBER: _ClassVar[int]
|
|
82
|
+
TRI_STATE_FIELD_NUMBER: _ClassVar[int]
|
|
83
|
+
RECEIPT_JSON_FIELD_NUMBER: _ClassVar[int]
|
|
84
|
+
arrow_ipc: bytes
|
|
85
|
+
error: str
|
|
86
|
+
protocol_version: int
|
|
87
|
+
code: ErrorCode
|
|
88
|
+
tri_state: TriState
|
|
89
|
+
receipt_json: str
|
|
90
|
+
def __init__(self, arrow_ipc: _Optional[bytes] = ..., error: _Optional[str] = ..., protocol_version: _Optional[int] = ..., code: _Optional[_Union[ErrorCode, str]] = ..., tri_state: _Optional[_Union[TriState, str]] = ..., receipt_json: _Optional[str] = ...) -> None: ...
|