Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load query exception for invalid file format #1159

Merged
merged 7 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please loop over all the possible enum values so that we don’t need to update this if we add more types later. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaurav274 , in this if condition we are checking if we are receiving the file format none. It would be the case only if the file format is not their in lark parser.
And after this there is a condition already available where we are checking all the available file format and passing it to the load executor

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()