From 85112bb0be2415e659ad892b457699885b6741f6 Mon Sep 17 00:00:00 2001 From: affan00733 <42251896+affan00733@users.noreply.github.com> Date: Wed, 20 Sep 2023 03:14:15 +0530 Subject: [PATCH] Load query exception for invalid file format (#1159) --- evadb/executor/load_executor.py | 4 ++++ test/integration_tests/long/test_load_executor.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/evadb/executor/load_executor.py b/evadb/executor/load_executor.py index 254465c1a..c90c7ccec 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 c7e486b84..05a479a8f 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()