real-ladybug 0.0.1.dev1__cp312-cp312-win_amd64.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.
Potentially problematic release.
This version of real-ladybug might be problematic. Click here for more details.
- real_ladybug/__init__.py +83 -0
- real_ladybug/_lbug.cp312-win_amd64.pyd +0 -0
- real_ladybug/_lbug.exp +0 -0
- real_ladybug/_lbug.lib +0 -0
- real_ladybug/async_connection.py +226 -0
- real_ladybug/connection.py +323 -0
- real_ladybug/constants.py +7 -0
- real_ladybug/database.py +307 -0
- real_ladybug/prepared_statement.py +51 -0
- real_ladybug/py.typed +0 -0
- real_ladybug/query_result.py +511 -0
- real_ladybug/torch_geometric_feature_store.py +185 -0
- real_ladybug/torch_geometric_graph_store.py +131 -0
- real_ladybug/torch_geometric_result_converter.py +282 -0
- real_ladybug/types.py +39 -0
- real_ladybug-0.0.1.dev1.dist-info/METADATA +88 -0
- real_ladybug-0.0.1.dev1.dist-info/RECORD +114 -0
- real_ladybug-0.0.1.dev1.dist-info/WHEEL +5 -0
- real_ladybug-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
- real_ladybug-0.0.1.dev1.dist-info/top_level.txt +3 -0
- real_ladybug-0.0.1.dev1.dist-info/zip-safe +1 -0
- real_ladybug-source/scripts/antlr4/hash.py +2 -0
- real_ladybug-source/scripts/antlr4/keywordhandler.py +47 -0
- real_ladybug-source/scripts/collect-extensions.py +68 -0
- real_ladybug-source/scripts/collect-single-file-header.py +126 -0
- real_ladybug-source/scripts/export-dbs.py +101 -0
- real_ladybug-source/scripts/export-import-test.py +345 -0
- real_ladybug-source/scripts/extension/purge-beta.py +34 -0
- real_ladybug-source/scripts/generate-cpp-docs/collect_files.py +122 -0
- real_ladybug-source/scripts/generate-tinysnb.py +34 -0
- real_ladybug-source/scripts/get-clangd-diagnostics.py +233 -0
- real_ladybug-source/scripts/migrate-lbug-db.py +308 -0
- real_ladybug-source/scripts/multiplatform-test-helper/collect-results.py +71 -0
- real_ladybug-source/scripts/multiplatform-test-helper/notify-discord.py +68 -0
- real_ladybug-source/scripts/pip-package/package_tar.py +90 -0
- real_ladybug-source/scripts/pip-package/setup.py +130 -0
- real_ladybug-source/scripts/run-clang-format.py +408 -0
- real_ladybug-source/scripts/setup-extension-repo.py +67 -0
- real_ladybug-source/scripts/test-simsimd-dispatch.py +45 -0
- real_ladybug-source/scripts/update-nightly-build-version.py +81 -0
- real_ladybug-source/third_party/brotli/scripts/dictionary/step-01-download-rfc.py +16 -0
- real_ladybug-source/third_party/brotli/scripts/dictionary/step-02-rfc-to-bin.py +34 -0
- real_ladybug-source/third_party/brotli/scripts/dictionary/step-03-validate-bin.py +35 -0
- real_ladybug-source/third_party/brotli/scripts/dictionary/step-04-generate-java-literals.py +85 -0
- real_ladybug-source/third_party/pybind11/tools/codespell_ignore_lines_from_errors.py +35 -0
- real_ladybug-source/third_party/pybind11/tools/libsize.py +36 -0
- real_ladybug-source/third_party/pybind11/tools/make_changelog.py +63 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/__init__.py +83 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/async_connection.py +226 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/connection.py +323 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/constants.py +7 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/database.py +307 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/prepared_statement.py +51 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/py.typed +0 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/query_result.py +511 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_feature_store.py +185 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_graph_store.py +131 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_result_converter.py +282 -0
- real_ladybug-source/tools/python_api/build/real_ladybug/types.py +39 -0
- real_ladybug-source/tools/python_api/src_py/__init__.py +83 -0
- real_ladybug-source/tools/python_api/src_py/async_connection.py +226 -0
- real_ladybug-source/tools/python_api/src_py/connection.py +323 -0
- real_ladybug-source/tools/python_api/src_py/constants.py +7 -0
- real_ladybug-source/tools/python_api/src_py/database.py +307 -0
- real_ladybug-source/tools/python_api/src_py/prepared_statement.py +51 -0
- real_ladybug-source/tools/python_api/src_py/py.typed +0 -0
- real_ladybug-source/tools/python_api/src_py/query_result.py +511 -0
- real_ladybug-source/tools/python_api/src_py/torch_geometric_feature_store.py +185 -0
- real_ladybug-source/tools/python_api/src_py/torch_geometric_graph_store.py +131 -0
- real_ladybug-source/tools/python_api/src_py/torch_geometric_result_converter.py +282 -0
- real_ladybug-source/tools/python_api/src_py/types.py +39 -0
- real_ladybug-source/tools/python_api/test/conftest.py +230 -0
- real_ladybug-source/tools/python_api/test/disabled_test_extension.py +73 -0
- real_ladybug-source/tools/python_api/test/ground_truth.py +430 -0
- real_ladybug-source/tools/python_api/test/test_arrow.py +694 -0
- real_ladybug-source/tools/python_api/test/test_async_connection.py +159 -0
- real_ladybug-source/tools/python_api/test/test_blob_parameter.py +145 -0
- real_ladybug-source/tools/python_api/test/test_connection.py +49 -0
- real_ladybug-source/tools/python_api/test/test_database.py +234 -0
- real_ladybug-source/tools/python_api/test/test_datatype.py +372 -0
- real_ladybug-source/tools/python_api/test/test_df.py +564 -0
- real_ladybug-source/tools/python_api/test/test_dict.py +112 -0
- real_ladybug-source/tools/python_api/test/test_exception.py +54 -0
- real_ladybug-source/tools/python_api/test/test_fsm.py +227 -0
- real_ladybug-source/tools/python_api/test/test_get_header.py +49 -0
- real_ladybug-source/tools/python_api/test/test_helper.py +8 -0
- real_ladybug-source/tools/python_api/test/test_issue.py +147 -0
- real_ladybug-source/tools/python_api/test/test_iteration.py +96 -0
- real_ladybug-source/tools/python_api/test/test_networkx.py +437 -0
- real_ladybug-source/tools/python_api/test/test_parameter.py +340 -0
- real_ladybug-source/tools/python_api/test/test_prepared_statement.py +117 -0
- real_ladybug-source/tools/python_api/test/test_query_result.py +54 -0
- real_ladybug-source/tools/python_api/test/test_query_result_close.py +44 -0
- real_ladybug-source/tools/python_api/test/test_scan_pandas.py +676 -0
- real_ladybug-source/tools/python_api/test/test_scan_pandas_pyarrow.py +714 -0
- real_ladybug-source/tools/python_api/test/test_scan_polars.py +165 -0
- real_ladybug-source/tools/python_api/test/test_scan_pyarrow.py +167 -0
- real_ladybug-source/tools/python_api/test/test_timeout.py +11 -0
- real_ladybug-source/tools/python_api/test/test_torch_geometric.py +640 -0
- real_ladybug-source/tools/python_api/test/test_torch_geometric_remote_backend.py +111 -0
- real_ladybug-source/tools/python_api/test/test_udf.py +207 -0
- real_ladybug-source/tools/python_api/test/test_version.py +6 -0
- real_ladybug-source/tools/python_api/test/test_wal.py +80 -0
- real_ladybug-source/tools/python_api/test/type_aliases.py +10 -0
- real_ladybug-source/tools/rust_api/update_version.py +47 -0
- real_ladybug-source/tools/shell/test/conftest.py +218 -0
- real_ladybug-source/tools/shell/test/test_helper.py +60 -0
- real_ladybug-source/tools/shell/test/test_shell_basics.py +325 -0
- real_ladybug-source/tools/shell/test/test_shell_commands.py +656 -0
- real_ladybug-source/tools/shell/test/test_shell_control_edit.py +438 -0
- real_ladybug-source/tools/shell/test/test_shell_control_search.py +468 -0
- real_ladybug-source/tools/shell/test/test_shell_esc_edit.py +232 -0
- real_ladybug-source/tools/shell/test/test_shell_esc_search.py +162 -0
- real_ladybug-source/tools/shell/test/test_shell_flags.py +645 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import datetime
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
from uuid import UUID
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import pandas as pd
|
|
9
|
+
import pytz
|
|
10
|
+
from type_aliases import ConnDB
|
|
11
|
+
from real_ladybug.constants import ID, LABEL, SRC, DST, NODES, RELS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_bool(conn_db_readonly: ConnDB) -> None:
|
|
15
|
+
conn, _ = conn_db_readonly
|
|
16
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.isStudent;")
|
|
17
|
+
assert result.has_next()
|
|
18
|
+
assert result.get_next() == [True]
|
|
19
|
+
assert not result.has_next()
|
|
20
|
+
result.close()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_int(conn_db_readonly: ConnDB) -> None:
|
|
24
|
+
conn, _ = conn_db_readonly
|
|
25
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.age;")
|
|
26
|
+
assert result.has_next()
|
|
27
|
+
assert result.get_next() == [35]
|
|
28
|
+
assert not result.has_next()
|
|
29
|
+
result.close()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_int8(conn_db_readonly: ConnDB) -> None:
|
|
33
|
+
conn, _ = conn_db_readonly
|
|
34
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.level;")
|
|
35
|
+
assert result.has_next()
|
|
36
|
+
assert result.get_next() == [5]
|
|
37
|
+
assert not result.has_next()
|
|
38
|
+
result.close()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_uint8(conn_db_readonly: ConnDB) -> None:
|
|
42
|
+
conn, _ = conn_db_readonly
|
|
43
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.ulevel;")
|
|
44
|
+
assert result.has_next()
|
|
45
|
+
assert result.get_next() == [250]
|
|
46
|
+
assert not result.has_next()
|
|
47
|
+
result.close()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_uint16(conn_db_readonly: ConnDB) -> None:
|
|
51
|
+
conn, _ = conn_db_readonly
|
|
52
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.ulength;")
|
|
53
|
+
assert result.has_next()
|
|
54
|
+
assert result.get_next() == [33768]
|
|
55
|
+
assert not result.has_next()
|
|
56
|
+
result.close()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_uint32(conn_db_readonly: ConnDB) -> None:
|
|
60
|
+
conn, _ = conn_db_readonly
|
|
61
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.temperature;")
|
|
62
|
+
assert result.has_next()
|
|
63
|
+
assert result.get_next() == [32800]
|
|
64
|
+
assert not result.has_next()
|
|
65
|
+
result.close()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_uint64(conn_db_readonly: ConnDB) -> None:
|
|
69
|
+
conn, _ = conn_db_readonly
|
|
70
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.code;")
|
|
71
|
+
assert result.has_next()
|
|
72
|
+
assert result.get_next() == [9223372036854775808]
|
|
73
|
+
assert not result.has_next()
|
|
74
|
+
result.close()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_int128(conn_db_readonly: ConnDB) -> None:
|
|
78
|
+
conn, _ = conn_db_readonly
|
|
79
|
+
result = conn.execute("MATCH (a:person) -[r:studyAt]-> (b:organisation) WHERE r.length = 5 RETURN r.hugedata;")
|
|
80
|
+
assert result.has_next()
|
|
81
|
+
assert result.get_next() == [1844674407370955161811111111]
|
|
82
|
+
assert not result.has_next()
|
|
83
|
+
result.close()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_serial(conn_db_readonly: ConnDB) -> None:
|
|
87
|
+
conn, _ = conn_db_readonly
|
|
88
|
+
result = conn.execute("MATCH (a:moviesSerial) WHERE a.ID = 2 RETURN a.ID;")
|
|
89
|
+
assert result.has_next()
|
|
90
|
+
assert result.get_next() == [2]
|
|
91
|
+
assert not result.has_next()
|
|
92
|
+
result.close()
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_double(conn_db_readonly: ConnDB) -> None:
|
|
96
|
+
conn, _ = conn_db_readonly
|
|
97
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.eyeSight;")
|
|
98
|
+
assert result.has_next()
|
|
99
|
+
assert result.get_next() == [5.0]
|
|
100
|
+
assert not result.has_next()
|
|
101
|
+
result.close()
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_decimal(conn_db_readonly: ConnDB) -> None:
|
|
105
|
+
conn, _ = conn_db_readonly
|
|
106
|
+
res = conn.execute(
|
|
107
|
+
"UNWIND [1, 2, 3] AS A UNWIND [5.7, 8.3, 2.9] AS B WITH cast(CAST(A AS DECIMAL) * CAST(B AS DECIMAL) AS DECIMAL(18, 1)) AS PROD RETURN COLLECT(PROD) AS RES"
|
|
108
|
+
)
|
|
109
|
+
assert sorted(res.get_next()[0]) == sorted([
|
|
110
|
+
Decimal("5.7"),
|
|
111
|
+
Decimal("8.3"),
|
|
112
|
+
Decimal("2.9"),
|
|
113
|
+
Decimal("11.4"),
|
|
114
|
+
Decimal("16.6"),
|
|
115
|
+
Decimal("5.8"),
|
|
116
|
+
Decimal("17.1"),
|
|
117
|
+
Decimal("24.9"),
|
|
118
|
+
Decimal("8.7"),
|
|
119
|
+
])
|
|
120
|
+
res = conn.execute(
|
|
121
|
+
"UNWIND [1, 2, 3] AS A UNWIND [5.7, 8.3, 2.9] AS B WITH CAST(CAST(A AS DECIMAL) * CAST(B AS DECIMAL) AS DECIMAL(4, 1)) AS PROD RETURN COLLECT(PROD) AS RES"
|
|
122
|
+
)
|
|
123
|
+
assert sorted(res.get_next()[0]) == sorted([
|
|
124
|
+
Decimal("5.7"),
|
|
125
|
+
Decimal("8.3"),
|
|
126
|
+
Decimal("2.9"),
|
|
127
|
+
Decimal("11.4"),
|
|
128
|
+
Decimal("16.6"),
|
|
129
|
+
Decimal("5.8"),
|
|
130
|
+
Decimal("17.1"),
|
|
131
|
+
Decimal("24.9"),
|
|
132
|
+
Decimal("8.7"),
|
|
133
|
+
])
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_string(conn_db_readonly: ConnDB) -> None:
|
|
137
|
+
conn, _ = conn_db_readonly
|
|
138
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.fName;")
|
|
139
|
+
assert result.has_next()
|
|
140
|
+
assert result.get_next() == ["Alice"]
|
|
141
|
+
assert not result.has_next()
|
|
142
|
+
result.close()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def test_blob(conn_db_readonly: ConnDB) -> None:
|
|
146
|
+
conn, _ = conn_db_readonly
|
|
147
|
+
result = conn.execute("RETURN BLOB('\\\\xAA\\\\xBB\\\\xCD\\\\x1A')")
|
|
148
|
+
assert result.has_next()
|
|
149
|
+
result_blob = result.get_next()[0]
|
|
150
|
+
assert len(result_blob) == 4
|
|
151
|
+
assert result_blob[0] == 0xAA
|
|
152
|
+
assert result_blob[1] == 0xBB
|
|
153
|
+
assert result_blob[2] == 0xCD
|
|
154
|
+
assert result_blob[3] == 0x1A
|
|
155
|
+
assert not result.has_next()
|
|
156
|
+
result.close()
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_uuid(conn_db_readonly: ConnDB) -> None:
|
|
160
|
+
conn, _ = conn_db_readonly
|
|
161
|
+
result = conn.execute("RETURN UUID('A0EEBC99-9c0b-4ef8-bb6d-6bb9bd380a12')")
|
|
162
|
+
assert result.has_next()
|
|
163
|
+
assert result.get_next() == [UUID("a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12")]
|
|
164
|
+
assert not result.has_next()
|
|
165
|
+
result.close()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_date(conn_db_readonly: ConnDB) -> None:
|
|
169
|
+
conn, _ = conn_db_readonly
|
|
170
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.birthdate;")
|
|
171
|
+
assert result.has_next()
|
|
172
|
+
assert result.get_next() == [datetime.date(1900, 1, 1)]
|
|
173
|
+
assert not result.has_next()
|
|
174
|
+
result.close()
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_timestamp(conn_db_readonly: ConnDB) -> None:
|
|
178
|
+
conn, _ = conn_db_readonly
|
|
179
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.registerTime;")
|
|
180
|
+
assert result.has_next()
|
|
181
|
+
assert result.get_next() == [datetime.datetime(2011, 8, 20, 11, 25, 30)]
|
|
182
|
+
assert not result.has_next()
|
|
183
|
+
result.close()
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_timestamp_tz(conn_db_readonly: ConnDB) -> None:
|
|
187
|
+
conn, _ = conn_db_readonly
|
|
188
|
+
result = conn.execute("MATCH (a:movies) WHERE a.length = 126 RETURN a.description.release_tz;")
|
|
189
|
+
assert result.has_next()
|
|
190
|
+
assert result.get_next() == [datetime.datetime(2011, 8, 20, 11, 25, 30, 123456, pytz.UTC)]
|
|
191
|
+
assert not result.has_next()
|
|
192
|
+
result.close()
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_timestamp_ns(conn_db_readonly: ConnDB) -> None:
|
|
196
|
+
conn, _ = conn_db_readonly
|
|
197
|
+
result = conn.execute("MATCH (a:movies) WHERE a.length = 126 RETURN a.description.release_ns;")
|
|
198
|
+
assert result.has_next()
|
|
199
|
+
assert result.get_next() == [datetime.datetime(2011, 8, 20, 11, 25, 30, 123456)]
|
|
200
|
+
assert not result.has_next()
|
|
201
|
+
result.close()
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_timestamp_ms(conn_db_readonly: ConnDB) -> None:
|
|
205
|
+
conn, _ = conn_db_readonly
|
|
206
|
+
result = conn.execute("MATCH (a:movies) WHERE a.length = 126 RETURN a.description.release_ms;")
|
|
207
|
+
assert result.has_next()
|
|
208
|
+
assert result.get_next() == [datetime.datetime(2011, 8, 20, 11, 25, 30, 123000)]
|
|
209
|
+
assert not result.has_next()
|
|
210
|
+
result.close()
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def test_timestamp_s(conn_db_readonly: ConnDB) -> None:
|
|
214
|
+
conn, _ = conn_db_readonly
|
|
215
|
+
result = conn.execute("MATCH (a:movies) WHERE a.length = 126 RETURN a.description.release_sec;")
|
|
216
|
+
assert result.has_next()
|
|
217
|
+
assert result.get_next() == [datetime.datetime(2011, 8, 20, 11, 25, 30)]
|
|
218
|
+
assert not result.has_next()
|
|
219
|
+
result.close()
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def test_interval(conn_db_readonly: ConnDB) -> None:
|
|
223
|
+
conn, _ = conn_db_readonly
|
|
224
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.lastJobDuration;")
|
|
225
|
+
assert result.has_next()
|
|
226
|
+
assert result.get_next() == [datetime.timedelta(days=1082, seconds=46920)]
|
|
227
|
+
assert not result.has_next()
|
|
228
|
+
result.close()
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def test_list(conn_db_readonly: ConnDB) -> None:
|
|
232
|
+
conn, _ = conn_db_readonly
|
|
233
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a.courseScoresPerTerm;")
|
|
234
|
+
assert result.has_next()
|
|
235
|
+
assert result.get_next() == [[[10, 8], [6, 7, 8]]]
|
|
236
|
+
assert not result.has_next()
|
|
237
|
+
result.close()
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def test_map(conn_db_readonly: ConnDB) -> None:
|
|
241
|
+
conn, _ = conn_db_readonly
|
|
242
|
+
result = conn.execute("MATCH (m:movies) WHERE m.length = 2544 RETURN m.audience;")
|
|
243
|
+
assert result.has_next()
|
|
244
|
+
assert result.get_next() == [{"audience1": 33}]
|
|
245
|
+
assert not result.has_next()
|
|
246
|
+
result.close()
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def test_union(conn_db_readonly: ConnDB) -> None:
|
|
250
|
+
conn, _ = conn_db_readonly
|
|
251
|
+
result = conn.execute("MATCH (m:movies) WHERE m.length = 2544 RETURN m.grade;")
|
|
252
|
+
assert result.has_next()
|
|
253
|
+
assert result.get_next() == [8.989]
|
|
254
|
+
assert not result.has_next()
|
|
255
|
+
result.close()
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_node(conn_db_readonly: ConnDB) -> None:
|
|
259
|
+
conn, _ = conn_db_readonly
|
|
260
|
+
result = conn.execute("MATCH (a:person) WHERE a.ID = 0 RETURN a")
|
|
261
|
+
assert result.has_next()
|
|
262
|
+
n = result.get_next()
|
|
263
|
+
assert len(n) == 1
|
|
264
|
+
n = n[0]
|
|
265
|
+
assert n[LABEL] == "person"
|
|
266
|
+
assert n["ID"] == 0
|
|
267
|
+
assert n["fName"] == "Alice"
|
|
268
|
+
assert n["gender"] == 1
|
|
269
|
+
assert n["isStudent"] is True
|
|
270
|
+
assert n["eyeSight"] == 5.0
|
|
271
|
+
assert n["birthdate"] == datetime.date(1900, 1, 1)
|
|
272
|
+
assert n["registerTime"] == datetime.datetime(2011, 8, 20, 11, 25, 30)
|
|
273
|
+
assert n["lastJobDuration"] == datetime.timedelta(days=1082, seconds=46920)
|
|
274
|
+
assert n["courseScoresPerTerm"] == [[10, 8], [6, 7, 8]]
|
|
275
|
+
assert n["usedNames"] == ["Aida"]
|
|
276
|
+
assert not result.has_next()
|
|
277
|
+
result.close()
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def test_rel(conn_db_readonly: ConnDB) -> None:
|
|
281
|
+
conn, _ = conn_db_readonly
|
|
282
|
+
result = conn.execute("MATCH (p:person)-[r:workAt]->(o:organisation) WHERE p.ID = 5 RETURN p, r, o")
|
|
283
|
+
assert result.has_next()
|
|
284
|
+
n = result.get_next()
|
|
285
|
+
assert len(n) == 3
|
|
286
|
+
p = n[0]
|
|
287
|
+
r = n[1]
|
|
288
|
+
o = n[2]
|
|
289
|
+
assert p[LABEL] == "person"
|
|
290
|
+
assert p["ID"] == 5
|
|
291
|
+
assert o[LABEL] == "organisation"
|
|
292
|
+
assert o["ID"] == 6
|
|
293
|
+
assert r["year"] == 2010
|
|
294
|
+
assert r[SRC] == p[ID]
|
|
295
|
+
assert r[DST] == o[ID]
|
|
296
|
+
assert r[LABEL] == "workAt"
|
|
297
|
+
assert not result.has_next()
|
|
298
|
+
result.close()
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def test_struct(conn_db_readonly: ConnDB) -> None:
|
|
302
|
+
conn, _ = conn_db_readonly
|
|
303
|
+
result = conn.execute('MATCH (m:movies) WHERE m.name="Roma" RETURN m.description')
|
|
304
|
+
assert result.has_next()
|
|
305
|
+
n = result.get_next()
|
|
306
|
+
assert len(n) == 1
|
|
307
|
+
description = n[0]
|
|
308
|
+
print(description)
|
|
309
|
+
assert description["rating"] == 1223
|
|
310
|
+
assert description["views"] == 10003
|
|
311
|
+
assert description["release"] == datetime.datetime(2011, 2, 11, 16, 44, 22)
|
|
312
|
+
assert description["release_ns"] == datetime.datetime(2011, 2, 11, 16, 44, 22, 123456)
|
|
313
|
+
assert description["release_ms"] == datetime.datetime(2011, 2, 11, 16, 44, 22, 123000)
|
|
314
|
+
assert description["release_sec"] == datetime.datetime(2011, 2, 11, 16, 44, 22)
|
|
315
|
+
assert description["release_tz"] == datetime.datetime(2011, 2, 11, 16, 44, 22, 123456, pytz.UTC)
|
|
316
|
+
assert description["film"] == datetime.date(2013, 2, 22)
|
|
317
|
+
assert description["stars"] == 100
|
|
318
|
+
assert description["u8"] == 1
|
|
319
|
+
assert description["u16"] == 15
|
|
320
|
+
assert description["u32"] == 200
|
|
321
|
+
assert description["u64"] == 4
|
|
322
|
+
assert description["hugedata"] == -15
|
|
323
|
+
assert not result.has_next()
|
|
324
|
+
result.close()
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def test_recursive_rel(conn_db_readonly: ConnDB) -> None:
|
|
328
|
+
conn, _ = conn_db_readonly
|
|
329
|
+
result = conn.execute("MATCH (a:person)-[e:studyAt*1..1]->(b:organisation) WHERE a.fName = 'Alice' RETURN e;")
|
|
330
|
+
assert result.has_next()
|
|
331
|
+
n = result.get_next()
|
|
332
|
+
assert len(n) == 1
|
|
333
|
+
e = n[0]
|
|
334
|
+
assert NODES in e
|
|
335
|
+
assert RELS in e
|
|
336
|
+
assert len(e[NODES]) == 0
|
|
337
|
+
assert len(e[RELS]) == 1
|
|
338
|
+
rel = e[RELS][0]
|
|
339
|
+
excepted_rel = {
|
|
340
|
+
ID: {"offset": 0, "table": 5},
|
|
341
|
+
SRC: {"offset": 0, "table": 0},
|
|
342
|
+
DST: {"offset": 0, "table": 1},
|
|
343
|
+
LABEL: "studyAt",
|
|
344
|
+
"year": 2021,
|
|
345
|
+
"places": ["wwAewsdndweusd", "wek"],
|
|
346
|
+
"length": 5,
|
|
347
|
+
"level": 5,
|
|
348
|
+
"code": 9223372036854775808,
|
|
349
|
+
"temperature": 32800,
|
|
350
|
+
"ulength": 33768,
|
|
351
|
+
"ulevel": 250,
|
|
352
|
+
"hugedata": 1844674407370955161811111111,
|
|
353
|
+
}
|
|
354
|
+
assert rel == excepted_rel
|
|
355
|
+
assert not result.has_next()
|
|
356
|
+
result.close()
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def test_large_array(conn_db_readwrite: ConnDB) -> None:
|
|
360
|
+
conn, _ = conn_db_readwrite
|
|
361
|
+
|
|
362
|
+
data = []
|
|
363
|
+
for i in range(1000):
|
|
364
|
+
data.append({"id": i, "embedding": np.random.rand(1670).tolist()})
|
|
365
|
+
|
|
366
|
+
df = pd.DataFrame(data)
|
|
367
|
+
conn.execute("CREATE NODE TABLE _User(id INT64, embedding DOUBLE[1670], PRIMARY KEY (id))")
|
|
368
|
+
conn.execute("COPY _User FROM df")
|
|
369
|
+
db_df = conn.execute("MATCH (u:_User) RETURN u.id as id, u.embedding as embedding ORDER BY u.id").get_as_df()
|
|
370
|
+
sorted_df = df.sort_values(by="id").reset_index(drop=True)
|
|
371
|
+
sorted_db_df = db_df.sort_values(by="id").reset_index(drop=True)
|
|
372
|
+
assert sorted_df.equals(sorted_db_df)
|