Skip to content

Commit

Permalink
add an integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
haozihong committed Nov 21, 2023
1 parent 3bd47e0 commit 38bcdd4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions evadb/functions/function_bootstrap_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
EvaDB_INSTALLATION_DIR
)

DummyAccessColumnByName_function_query = """CREATE FUNCTION
IF NOT EXISTS DummyAccessColumnByName
IMPL '{}/../test/util.py';
""".format(
EvaDB_INSTALLATION_DIR
)

fuzzy_function_query = """CREATE FUNCTION IF NOT EXISTS FuzzDistance
INPUT (Input_Array1 NDARRAY ANYTYPE, Input_Array2 NDARRAY ANYTYPE)
OUTPUT (distance FLOAT(32, 7))
Expand Down Expand Up @@ -299,6 +306,7 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
DummyFeatureExtractor_function_query,
DummyNoInputFunction_function_query,
DummyLLM_function_query,
DummyAccessColumnByName_function_query,
]
)

Expand Down
15 changes: 15 additions & 0 deletions test/integration_tests/short/test_select_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,18 @@ def test_function_with_no_input_arguments(self):
pd.DataFrame([{"dummynoinputfunction.label": "DummyNoInputFunction"}])
)
self.assertEqual(actual_batch, expected)

def test_nested_function_calls(self):
select_query = "SELECT DummyAccessColumnByName(DummyAccessColumnByName(id, data)) from MyVideo;"
actual_batch = execute_query_fetch_all(self.evadb, select_query)
expected = Batch(
pd.DataFrame(
[
{
"dummyaccesscolumnbyname.output1": True,
"dummyaccesscolumnbyname.output2": True,
}
]
)
)
self.assertEqual(actual_batch, expected)
32 changes: 32 additions & 0 deletions test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,35 @@ def forward(self, text_df):
# Make it slower
time.sleep(1)
return df


class DummyAccessColumnByName(AbstractFunction):
@decorators.setup(cacheable=False, function_type="test", batchable=False)
def setup(self, *args, **kwargs):
pass

@property
def name(self) -> str:
return "DummyAccessColumnByName"

@decorators.forward(
input_signatures=[
PandasDataframe(
columns=["input1", "input2"],
column_types=[NdArrayType.ANYTYPE, NdArrayType.ANYTYPE],
column_shapes=[(None,), (None,)],
)
],
output_signatures=[
PandasDataframe(
columns=["output1", "output2"],
column_types=[NdArrayType.ANYTYPE, NdArrayType.ANYTYPE],
column_shapes=[(None,), (None,)],
)
],
)
def forward(self, df: pd.DataFrame) -> pd.DataFrame:
ret = pd.DataFrame(
[{"output1": df["input1"] is not None, "output2": df["input2"] is not None}]
)
return ret

0 comments on commit 38bcdd4

Please sign in to comment.