diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c250ce..3ff7bb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +0.6.3 +----- + - The DynamoDBStatementParser will now throw a DocumentNotFoundException if the table referenced in the statement was not provided + 0.6.2 ----- - Support negative numbers (both integers and floats) diff --git a/py_partiql_parser/_internal/parser.py b/py_partiql_parser/_internal/parser.py index 14e417c..664559b 100644 --- a/py_partiql_parser/_internal/parser.py +++ b/py_partiql_parser/_internal/parser.py @@ -2,7 +2,7 @@ from typing import Dict, Any, List, Optional, Tuple -from ..exceptions import ParserException +from ..exceptions import DocumentNotFoundException, ParserException from .delete_parser import DeleteParser from .from_parser import DynamoDBFromParser, S3FromParser, FromParser from .insert_parser import InsertParser @@ -110,7 +110,10 @@ def _parse_select( # FROM from_parser = DynamoDBFromParser(from_clause=clauses[2]) - source_data = self.documents[list(from_parser.clauses.values())[0]] + table_name = list(from_parser.clauses.values())[0] + if table_name not in self.documents: + raise DocumentNotFoundException(name=table_name) + source_data = self.documents[table_name] # WHERE if len(clauses) > 3: diff --git a/py_partiql_parser/exceptions.py b/py_partiql_parser/exceptions.py index 4fe13bf..d0a40a1 100644 --- a/py_partiql_parser/exceptions.py +++ b/py_partiql_parser/exceptions.py @@ -3,3 +3,9 @@ def __init__(self, name: str, message: str): self.name = name self.message = message super().__init__(message) + + +class DocumentNotFoundException(Exception): + def __init__(self, name: str): + self.name = name + super().__init__(f"Document not found: {name}") diff --git a/pyproject.toml b/pyproject.toml index ef74190..91b29ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "py-partiql-parser" -version = "0.6.2" +version = "0.6.3" description = "Pure Python PartiQL Parser" readme = "README.md" keywords = ["pypartiql", "parser"]