Skip to content

Commit

Permalink
Add test that columns missing from some row slices cannot be aggregated
Browse files Browse the repository at this point in the history
  • Loading branch information
alexowens90 committed Apr 19, 2024
1 parent 6a4d98a commit 36fa6df
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions python/tests/unit/arcticdb/version_store/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,6 @@ def test_resampling_datetime_columns(lmdb_version_store_v1):
def test_resampling_dynamic_schema_types_changing(lmdb_version_store_dynamic_schema_v1):
lib = lmdb_version_store_dynamic_schema_v1
sym = "test_resampling_dynamic_schema_types_changing"
# Create 5 buckets worth of data, each containing 3 values:
# - No nans
# - All nans
# - First value nan
# - Middle value nan
# - Last value nan
# Will group on microseconds
idx_0 = [0, 1, 2, 1000]
idx_0 = np.array(idx_0, dtype="datetime64[ns]")
Expand Down Expand Up @@ -451,6 +445,25 @@ def test_resampling_dynamic_schema_types_changing(lmdb_version_store_dynamic_sch
assert_frame_equal(expected, received)


def test_resampling_dynamic_schema_missing_column(lmdb_version_store_dynamic_schema_v1):
lib = lmdb_version_store_dynamic_schema_v1
sym = "test_resampling_dynamic_schema_missing_column"

lib.write(sym, pd.DataFrame({"col_0": [0]}, index=[pd.Timestamp(0)]))
lib.append(sym, pd.DataFrame({"col_1": [1000]}, index=[pd.Timestamp(1)]))

# Schema exception should be thrown regardless of whether there are any buckets that span segments or not
q = QueryBuilder()
q = q.resample("us").agg({"col_0": "sum"})
with pytest.raises(SchemaException):
lib.read(sym, query_builder=q)

q = QueryBuilder()
q = q.resample("s").agg({"col_1": "sum"})
with pytest.raises(SchemaException):
lib.read(sym, query_builder=q)


def test_resampling_named_agg(lmdb_version_store_v1):
lib = lmdb_version_store_v1
sym = "test_resampling_named_agg"
Expand Down

0 comments on commit 36fa6df

Please sign in to comment.