Skip to content

Commit b8f2703

Browse files
committed
Fixed regression tests
1 parent bd08e65 commit b8f2703

4 files changed

Lines changed: 62 additions & 70 deletions

File tree

opteryx/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__build__ = 1390
1+
__build__ = 1392
22

33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

opteryx/utils/file_decoders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def parquet_decoder(
270270

271271
for column in schema.names:
272272
column_index = schema.get_field_index(column)
273-
273+
274274
for rg_index in range(num_row_groups):
275275
column_chunk = metadata.row_group(rg_index).column(column_index)
276276

tests/catalog/test_catalog_iceberg.py

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import opteryx
1111
from opteryx.connectors import DiskConnector
1212
from opteryx.connectors import IcebergConnector
13+
from opteryx.compiled.structures.relation_statistics import to_int
1314

1415

1516
# this is how we get the raw list of files for the scan
@@ -73,16 +74,16 @@ def test_iceberg_get_statistics_manual():
7374
stats.update_upper(column_names[k], IcebergConnector.decode_iceberg_value(v, column_types[k]))
7475

7576
assert stats.record_count == 100000
76-
assert stats.lower_bounds["followers"] == 0
77-
assert stats.upper_bounds["followers"] == 8266250
78-
assert stats.lower_bounds["user_name"] == ""
79-
assert stats.upper_bounds["user_name"] == "🫖🔫"
80-
assert stats.lower_bounds["tweet_id"] == 1346604539013705728
81-
assert stats.upper_bounds["tweet_id"] == 1346615999009755142
82-
assert stats.lower_bounds["text"] == "!! PLEASE STOP A"
83-
assert stats.upper_bounds["text"] == "🪶Cultural approq"
84-
assert stats.lower_bounds["timestamp"] == "2021-01-05T23:48"
85-
assert stats.upper_bounds["timestamp"] == "2021-01-06T00:35"
77+
assert stats.lower_bounds[b"followers"] == 0
78+
assert stats.upper_bounds[b"followers"] == 8266250
79+
assert stats.lower_bounds[b"user_name"] == to_int("")
80+
assert stats.upper_bounds[b"user_name"] == to_int("🫖🔫")
81+
assert stats.lower_bounds[b"tweet_id"] == to_int(1346604539013705728)
82+
assert stats.upper_bounds[b"tweet_id"] == to_int(1346615999009755142)
83+
assert stats.lower_bounds[b"text"] == to_int("!! PLEASE STOP A")
84+
assert stats.upper_bounds[b"text"] == to_int("🪶Cultural approq")
85+
assert stats.lower_bounds[b"timestamp"] == to_int("2021-01-05T23:48")
86+
assert stats.upper_bounds[b"timestamp"] == to_int("2021-01-06T00:35")
8687

8788
@skip_if(is_arm() or is_windows() or is_mac())
8889
def test_iceberg_connector():
@@ -106,16 +107,16 @@ def test_iceberg_get_stats_tweets():
106107
stats = connector.relation_statistics
107108

108109
assert stats.record_count == 100000
109-
assert stats.lower_bounds["followers"] == 0
110-
assert stats.upper_bounds["followers"] == 8266250
111-
assert stats.lower_bounds["user_name"] == ""
112-
assert stats.upper_bounds["user_name"] == "🫖🔫"
113-
assert stats.lower_bounds["tweet_id"] == 1346604539013705728
114-
assert stats.upper_bounds["tweet_id"] == 1346615999009755142
115-
assert stats.lower_bounds["text"] == "!! PLEASE STOP A"
116-
assert stats.upper_bounds["text"] == "🪶Cultural approq"
117-
assert stats.lower_bounds["timestamp"] == "2021-01-05T23:48"
118-
assert stats.upper_bounds["timestamp"] == "2021-01-06T00:35"
110+
assert stats.lower_bounds[b"followers"] == 0
111+
assert stats.upper_bounds[b"followers"] == 8266250
112+
assert stats.lower_bounds[b"user_name"] == to_int("")
113+
assert stats.upper_bounds[b"user_name"] == to_int("🫖🔫")
114+
assert stats.lower_bounds[b"tweet_id"] == to_int(1346604539013705728)
115+
assert stats.upper_bounds[b"tweet_id"] == to_int(1346615999009755142)
116+
assert stats.lower_bounds[b"text"] == to_int("!! PLEASE STOP A")
117+
assert stats.upper_bounds[b"text"] == to_int("🪶Cultural approq")
118+
assert stats.lower_bounds[b"timestamp"] == to_int("2021-01-05T23:48")
119+
assert stats.upper_bounds[b"timestamp"] == to_int("2021-01-06T00:35")
119120

120121
@skip_if(is_arm() or is_windows() or is_mac())
121122
def test_iceberg_get_stats_missions():
@@ -130,16 +131,16 @@ def test_iceberg_get_stats_missions():
130131
stats = connector.relation_statistics
131132

132133
assert stats.record_count == 100000
133-
assert stats.lower_bounds["followers"] == 0
134-
assert stats.upper_bounds["followers"] == 8266250
135-
assert stats.lower_bounds["user_name"] == ""
136-
assert stats.upper_bounds["user_name"] == "🫖🔫"
137-
assert stats.lower_bounds["tweet_id"] == 1346604539013705728
138-
assert stats.upper_bounds["tweet_id"] == 1346615999009755142
139-
assert stats.lower_bounds["text"] == "!! PLEASE STOP A"
140-
assert stats.upper_bounds["text"] == "🪶Cultural approq"
141-
assert stats.lower_bounds["timestamp"] == "2021-01-05T23:48"
142-
assert stats.upper_bounds["timestamp"] == "2021-01-06T00:35"
134+
assert stats.lower_bounds[b"followers"] == 0
135+
assert stats.upper_bounds[b"followers"] == 8266250
136+
assert stats.lower_bounds[b"user_name"] == to_int("")
137+
assert stats.upper_bounds[b"user_name"] == to_int("🫖🔫")
138+
assert stats.lower_bounds[b"tweet_id"] == to_int(1346604539013705728)
139+
assert stats.upper_bounds[b"tweet_id"] == to_int(1346615999009755142)
140+
assert stats.lower_bounds[b"text"] == to_int("!! PLEASE STOP A")
141+
assert stats.upper_bounds[b"text"] == to_int("🪶Cultural approq")
142+
assert stats.lower_bounds[b"timestamp"] == to_int("2021-01-05T23:48")
143+
assert stats.upper_bounds[b"timestamp"] == to_int("2021-01-06T00:35")
143144

144145
@skip_if(is_arm() or is_windows() or is_mac())
145146
def test_iceberg_get_stats_remote():
@@ -165,18 +166,18 @@ def test_iceberg_get_stats_remote():
165166
stats = connector.relation_statistics
166167

167168
assert stats.record_count == 9
168-
assert stats.lower_bounds["id"] == 1, stats.lower_bounds["id"]
169-
assert stats.upper_bounds["id"] == 9, stats.upper_bounds["id"]
170-
assert stats.lower_bounds["name"] == "Earth", stats.lower_bounds["name"]
171-
assert stats.upper_bounds["name"] == "Venus", stats.upper_bounds["name"]
172-
assert stats.lower_bounds["mass"] == 0.0146, stats.lower_bounds["mass"]
173-
assert stats.upper_bounds["mass"] == 1898.0, stats.upper_bounds["mass"]
174-
assert stats.lower_bounds["diameter"] == 2370, stats.lower_bounds["diameter"]
175-
assert stats.upper_bounds["diameter"] == 142984, stats.upper_bounds["diameter"]
176-
assert stats.lower_bounds["gravity"] == Decimal("0.7"), stats.lower_bounds["gravity"]
177-
assert stats.upper_bounds["gravity"] == Decimal("23.1"), stats.upper_bounds["gravity"]
178-
assert stats.lower_bounds["surfacePressure"] == 0.0, stats.lower_bounds["surfacePressure"]
179-
assert stats.upper_bounds["surfacePressure"] == 92.0, stats.upper_bounds["surfacePressure"]
169+
assert stats.lower_bounds[b"id"] == 1, stats.lower_bounds[b"id"]
170+
assert stats.upper_bounds[b"id"] == 9, stats.upper_bounds[b"id"]
171+
assert stats.lower_bounds[b"name"] == to_int("Earth"), stats.lower_bounds[b"name"]
172+
assert stats.upper_bounds[b"name"] == to_int("Venus"), stats.upper_bounds[b"name"]
173+
assert stats.lower_bounds[b"mass"] == to_int(0.0146), stats.lower_bounds[b"mass"]
174+
assert stats.upper_bounds[b"mass"] == to_int(1898.0), stats.upper_bounds[b"mass"]
175+
assert stats.lower_bounds[b"diameter"] == 2370, stats.lower_bounds[b"diameter"]
176+
assert stats.upper_bounds[b"diameter"] == 142984, stats.upper_bounds[b"diameter"]
177+
assert stats.lower_bounds[b"gravity"] == to_int(Decimal("0.7")), stats.lower_bounds[b"gravity"]
178+
assert stats.upper_bounds[b"gravity"] == to_int(Decimal("23.1")), stats.upper_bounds[b"gravity"]
179+
assert stats.lower_bounds[b"surfacePressure"] == to_int(0.0), stats.lower_bounds[b"surfacePressure"]
180+
assert stats.upper_bounds[b"surfacePressure"] == to_int(92.0), stats.upper_bounds[b"surfacePressure"]
180181

181182

182183
@skip_if(is_arm() or is_windows() or is_mac())

tests/query_planner/test_read_parquet_statistics.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
sys.path.insert(1, os.path.join(sys.path[0], "../.."))
55

66
from opteryx.utils.file_decoders import parquet_decoder
7+
from opteryx.compiled.structures.relation_statistics import to_int
78

89
def test_read_statistics_tweets():
910
with open("testdata/flat/formats/parquet/tweets.parquet", "rb") as f:
@@ -13,13 +14,13 @@ def test_read_statistics_tweets():
1314

1415
assert stats.record_count == 100000, stats.record_count
1516

16-
assert stats.lower_bounds["tweet_id"] == 1346604539013705728
17-
assert stats.upper_bounds["tweet_id"] == 1346615999009755142
18-
assert stats.null_count["tweet_id"] == 0
17+
assert stats.lower_bounds[b"tweet_id"] == to_int(1346604539013705728)
18+
assert stats.upper_bounds[b"tweet_id"] == to_int(1346615999009755142)
19+
assert stats.null_count.get(b"tweet_id", 0) == 0
1920

20-
assert stats.lower_bounds["is_quoting"] == 28466111963996160
21-
assert stats.upper_bounds["is_quoting"] == 1346615755694104578, stats.upper_bounds["is_quoting"]
22-
assert stats.null_count["is_quoting"] == 85598
21+
assert stats.lower_bounds[b"is_quoting"] == to_int(28466111963996160)
22+
assert stats.upper_bounds[b"is_quoting"] == to_int(1346615755694104578)
23+
assert stats.null_count[b"is_quoting"] == 85598
2324

2425

2526
def test_read_statistics_planets():
@@ -30,32 +31,22 @@ def test_read_statistics_planets():
3031

3132
assert stats.record_count == 9
3233

33-
assert stats.lower_bounds["id"] == 1
34-
assert stats.upper_bounds["id"] == 9
35-
assert stats.null_count["id"] == 0
34+
assert stats.lower_bounds[b"id"] == 1
35+
assert stats.upper_bounds[b"id"] == 9
36+
assert stats.null_count.get(b"id", 0) == 0
3637

37-
assert stats.lower_bounds["name"] == "Earth"
38-
assert stats.upper_bounds["name"] == "Venus"
39-
assert stats.null_count["name"] == 0
38+
assert stats.lower_bounds[b"name"] == to_int("Earth")
39+
assert stats.upper_bounds[b"name"] == to_int("Venus")
40+
assert stats.null_count.get(b"name", 0) == 0
4041

41-
assert stats.lower_bounds["surfacePressure"] == 0.0
42-
assert stats.upper_bounds["surfacePressure"] == 92.0
42+
assert stats.lower_bounds[b"surfacePressure"] == to_int(0.0)
43+
assert stats.upper_bounds[b"surfacePressure"] == to_int(92.0)
4344

4445

4546

46-
def test_read_statistics():
47-
with open("testdata/astronauts/astronauts.parquet", "rb") as f:
48-
data = f.read()
49-
50-
stats = parquet_decoder(data, just_statistics=True)
51-
52-
print(stats.record_count)
53-
print(stats.lower_bounds)
54-
print(stats.upper_bounds)
55-
print(stats.null_count)
56-
57-
5847
if __name__ == "__main__": # pragma: no cover
5948
from tests.tools import run_tests
6049

50+
test_read_statistics_planets()
51+
6152
run_tests()

0 commit comments

Comments
 (0)