Skip to content

Commit

Permalink
Load query exception for invalid file format (#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
affan00733 committed Sep 19, 2023
1 parent ea6bfc6 commit 85112bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions evadb/executor/load_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions test/integration_tests/long/test_load_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 85112bb

Please sign in to comment.