Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav274 committed Sep 10, 2023
1 parent 0e6c890 commit 1a29c1b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 47 deletions.
4 changes: 1 addition & 3 deletions evadb/binder/binder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ def resolve_alias_table_value_expression(node: FunctionExpression):
if not len(node.alias.col_names):
node.alias = Alias(node.alias.alias_name, default_output_col_aliases)
else:
output_aliases = [
str(col_name) for col_name in node.alias.col_names
]
output_aliases = [str(col_name) for col_name in node.alias.col_names]
node.alias = Alias(node.alias.alias_name, output_aliases)

assert len(node.alias.col_names) == len(
Expand Down
4 changes: 2 additions & 2 deletions evadb/binder/statement_binder_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _check_table_alias_map(self, alias, col_name) -> ColumnCatalogEntry:
if table_obj is not None:
if table_obj.table_type == TableType.NATIVE_DATA:
for column_catalog_entry in table_obj.columns:
if column_catalog_entry.name == col_name:
if column_catalog_entry.name.lower() == col_name.lower():
return column_catalog_entry
else:
return self._catalog().get_column_catalog_entry(table_obj, col_name)
Expand All @@ -191,7 +191,7 @@ def _check_derived_table_alias_map(self, alias, col_name) -> CatalogColumnType:
return None

for name, obj in col_objs_map.items():
if name == col_name:
if name.lower() == col_name.lower():
return obj

def _get_all_alias_and_col_name(self) -> List[Tuple[str, str]]:
Expand Down
35 changes: 7 additions & 28 deletions test/integration_tests/long/test_huggingface_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,13 @@ def test_object_detection(self):
# Test that there exists a column with function_name.score and each entry is a list of floats
self.assertTrue(function_name + ".score" in output_frames.columns)
self.assertTrue(
all(
isinstance(x, list)
for x in output.frames[function_name + ".score"]
)
all(isinstance(x, list) for x in output.frames[function_name + ".score"])
)

# Test that there exists a column with function_name.label and each entry is a list of strings
self.assertTrue(function_name + ".label" in output_frames.columns)
self.assertTrue(
all(
isinstance(x, list)
for x in output.frames[function_name + ".label"]
)
all(isinstance(x, list) for x in output.frames[function_name + ".label"])
)

# Test that there exists a column with function_name.box and each entry is a dictionary with 4 keys
Expand Down Expand Up @@ -160,19 +154,13 @@ def test_image_classification(self):
# Test that there exists a column with function_name.score and each entry is a list of floats
self.assertTrue(function_name + ".score" in output.frames.columns)
self.assertTrue(
all(
isinstance(x, list)
for x in output.frames[function_name + ".score"]
)
all(isinstance(x, list) for x in output.frames[function_name + ".score"])
)

# Test that there exists a column with function_name.label and each entry is a list of strings
self.assertTrue(function_name + ".label" in output.frames.columns)
self.assertTrue(
all(
isinstance(x, list)
for x in output.frames[function_name + ".label"]
)
all(isinstance(x, list) for x in output.frames[function_name + ".label"])
)

drop_function_query = f"DROP FUNCTION {function_name};"
Expand Down Expand Up @@ -214,10 +202,7 @@ def test_text_classification(self):
# Test that there exists a column with function_name.score and each entry is a float
self.assertTrue(function_name + ".score" in output.frames.columns)
self.assertTrue(
all(
isinstance(x, float)
for x in output.frames[function_name + ".score"]
)
all(isinstance(x, float) for x in output.frames[function_name + ".score"])
)

drop_function_query = f"DROP FUNCTION {function_name};"
Expand Down Expand Up @@ -326,10 +311,7 @@ def test_toxicity_classification(self):
# and each entry is a float
self.assertTrue(function_name + ".score" in output.frames.columns)
self.assertTrue(
all(
isinstance(x, float)
for x in output.frames[function_name + ".score"]
)
all(isinstance(x, float) for x in output.frames[function_name + ".score"])
)

drop_function_query = f"DROP FUNCTION {function_name};"
Expand Down Expand Up @@ -375,10 +357,7 @@ def test_multilingual_toxicity_classification(self):
# Test that there exists a column with function_name.score and each entry is a float
self.assertTrue(function_name + ".score" in output.frames.columns)
self.assertTrue(
all(
isinstance(x, float)
for x in output.frames[function_name + ".score"]
)
all(isinstance(x, float) for x in output.frames[function_name + ".score"])
)

drop_function_query = f"DROP FUNCTION {function_name};"
Expand Down
2 changes: 1 addition & 1 deletion test/integration_tests/short/test_insert_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_should_insert_tuples_in_table(self):

self.assertIsNone(
np.testing.assert_array_equal(
batch.frames["csvtable.name"].array,
batch.frames["CSVTable.name"].array,
np.array(
[
"test_evadb/similarity/data/sad.jpg",
Expand Down
2 changes: 1 addition & 1 deletion test/integration_tests/short/test_load_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_should_load_csv_in_table(self):

# assert the batches are equal
expected_batch = next(create_dummy_csv_batches())
expected_batch.modify_column_alias("myvideocsv")
expected_batch.modify_column_alias("MyVideoCSV")
self.assertEqual(actual_batch, expected_batch)

# clean up
Expand Down
22 changes: 11 additions & 11 deletions test/integration_tests/short/test_select_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def test_should_load_and_sort_in_table(self):
actual_batch = execute_query_fetch_all(self.evadb, select_query)
expected_rows = [
{
"myvideo.id": i,
"myvideo.data": np.array(np.ones((32, 32, 3)) * i, dtype=np.uint8),
"MyVideo.id": i,
"MyVideo.data": np.array(np.ones((32, 32, 3)) * i, dtype=np.uint8),
}
for i in range(NUM_FRAMES)
]
Expand All @@ -85,7 +85,7 @@ def test_should_load_and_select_in_table(self):
select_query = "SELECT id FROM MyVideo;"
actual_batch = execute_query_fetch_all(self.evadb, select_query)
actual_batch.sort()
expected_rows = [{"myvideo.id": i} for i in range(NUM_FRAMES)]
expected_rows = [{"MyVideo.id": i} for i in range(NUM_FRAMES)]
expected_batch = Batch(frames=pd.DataFrame(expected_rows))
self.assertEqual(actual_batch, expected_batch)

Expand Down Expand Up @@ -121,7 +121,7 @@ def test_select_star_in_lateral_join(self):
select_query = """SELECT * FROM MyVideo JOIN LATERAL
Yolo(data);"""
actual_batch = execute_query_fetch_all(self.evadb, select_query)
self.assertEqual(actual_batch.frames.columns, ["myvideo.id"])
self.assertEqual(actual_batch.frames.columns, ["MyVideo.id"])

def test_should_throw_error_when_both_audio_and_video_selected(self):
query = """LOAD VIDEO 'data/sample_videos/touchdown.mp4'
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_select_and_iframe_sample(self):
actual_batch.sort()

expected_batch = list(create_dummy_batches(filters=range(0, NUM_FRAMES, 7)))
expected_batch[0] = expected_batch[0].project(["myvideo.id"])
expected_batch[0] = expected_batch[0].project(["MyVideo.id"])

self.assertEqual(len(actual_batch), len(expected_batch[0]))
self.assertEqual(actual_batch, expected_batch[0])
Expand All @@ -170,7 +170,7 @@ def test_select_and_iframe_sample_without_sampling_rate(self):
actual_batch.sort()

expected_batch = list(create_dummy_batches(filters=range(0, NUM_FRAMES, 1)))
expected_batch[0] = expected_batch[0].project(["myvideo.id"])
expected_batch[0] = expected_batch[0].project(["MyVideo.id"])

self.assertEqual(len(actual_batch), len(expected_batch[0]))
self.assertEqual(actual_batch, expected_batch[0])
Expand All @@ -193,7 +193,7 @@ def test_select_and_groupby_first(self):
self.assertEqual(len(actual_batch), len(expected_batch))

expected_batch.rename(
columns={"myvideo.id": "FIRST.id", "myvideo.data": "SEGMENT.data"}
columns={"MyVideo.id": "FIRST.id", "MyVideo.data": "SEGMENT.data"}
)
self.assertEqual(
actual_batch,
Expand All @@ -220,7 +220,7 @@ def test_select_and_groupby_with_last(self):
self.assertEqual(len(actual_batch), len(expected_batch))

expected_batch.rename(
columns={"myvideo.id": "LAST.id", "myvideo.data": "SEGMENT.data"}
columns={"MyVideo.id": "LAST.id", "MyVideo.data": "SEGMENT.data"}
)
self.assertEqual(
actual_batch,
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_select_and_groupby_with_sample(self):
self.assertEqual(len(actual_batch), len(expected_batch))

expected_batch.rename(
columns={"myvideo.id": "FIRST.id", "myvideo.data": "SEGMENT.data"}
columns={"MyVideo.id": "FIRST.id", "MyVideo.data": "SEGMENT.data"}
)

self.assertEqual(
Expand All @@ -286,12 +286,12 @@ def test_lateral_join_with_unnest_and_sample(self):
query = """SELECT id, label
FROM MyVideo SAMPLE 2 JOIN LATERAL
UNNEST(DummyMultiObjectDetector(data).labels) AS T(label)
WHERE id < 10 ORDER BY id;"""
WHERE iD < 10 ORDER BY id;"""
unnest_batch = execute_query_fetch_all(self.evadb, query)
expected = Batch(
pd.DataFrame(
{
"myvideo.id": np.array(
"MyVideo.id": np.array(
[0, 0, 2, 2, 4, 4, 6, 6, 8, 8], dtype=np.intp
),
"T.label": np.array(
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/optimizer/test_cascade_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_logical_to_physical_function(self):
actual_batch = execute_query_fetch_all(self.evadb, select_query)
actual_batch.sort()
expected = [
{"myvideo.id": i * 2, "dummyobjectdetector.label": ["person"]}
{"MyVideo.id": i * 2, "DummyObjectDetector.label": ["person"]}
for i in range(NUM_FRAMES // 2)
]
expected_batch = Batch(frames=pd.DataFrame(expected))
Expand Down

0 comments on commit 1a29c1b

Please sign in to comment.