diff --git a/evadb/executor/load_executor.py b/evadb/executor/load_executor.py index 254465c1a2..c90c7ccec3 100644 --- a/evadb/executor/load_executor.py +++ b/evadb/executor/load_executor.py @@ -14,6 +14,7 @@ # limitations under the License. from evadb.database import EvaDBDatabase from evadb.executor.abstract_executor import AbstractExecutor +from evadb.executor.executor_utils import ExecutorError from evadb.executor.load_csv_executor import LoadCSVExecutor from evadb.executor.load_multimedia_executor import LoadMultimediaExecutor from evadb.parser.types import FileFormatType @@ -30,6 +31,9 @@ def exec(self, *args, **kwargs): """ # invoke the appropriate executor + if self.node.file_options["file_format"] is None: + err_msg = "Invalid file format, please use supported file formats: CSV | VIDEO | IMAGE | DOCUMENT | PDF" + raise ExecutorError(err_msg) if self.node.file_options["file_format"] in [ FileFormatType.VIDEO, FileFormatType.IMAGE, diff --git a/test/integration_tests/long/test_load_executor.py b/test/integration_tests/long/test_load_executor.py index c7e486b84a..05a479a8f4 100644 --- a/test/integration_tests/long/test_load_executor.py +++ b/test/integration_tests/long/test_load_executor.py @@ -500,6 +500,13 @@ def test_load_pdfs(self): self.assertEqual(len(result.columns), 4) self.assertEqual(len(result), 26) + def test_load_query_incorrect_fileFormat(self): + with self.assertRaises(ExecutorError): + execute_query_fetch_all( + self.evadb, + f"""LOAD document '{EvaDB_ROOT_DIR}/data/documents/*.pdf' INTO pdfs;""", + ) + if __name__ == "__main__": unittest.main()