Skip to content

Commit 50316a3

Browse files
authored
Merge pull request #30 from getmoto/document-not-found-exception
Introduce DocumentNotFound exception for DynamoDB
2 parents 86921de + 054b8be commit 50316a3

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
0.6.3
5+
-----
6+
- The DynamoDBStatementParser will now throw a DocumentNotFoundException if the table referenced in the statement was not provided
7+
48
0.6.2
59
-----
610
- Support negative numbers (both integers and floats)

py_partiql_parser/_internal/parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Dict, Any, List, Optional, Tuple
44

5-
from ..exceptions import ParserException
5+
from ..exceptions import DocumentNotFoundException, ParserException
66
from .delete_parser import DeleteParser
77
from .from_parser import DynamoDBFromParser, S3FromParser, FromParser
88
from .insert_parser import InsertParser
@@ -110,7 +110,10 @@ def _parse_select(
110110
# FROM
111111
from_parser = DynamoDBFromParser(from_clause=clauses[2])
112112

113-
source_data = self.documents[list(from_parser.clauses.values())[0]]
113+
table_name = list(from_parser.clauses.values())[0]
114+
if table_name not in self.documents:
115+
raise DocumentNotFoundException(name=table_name)
116+
source_data = self.documents[table_name]
114117

115118
# WHERE
116119
if len(clauses) > 3:

py_partiql_parser/exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@ def __init__(self, name: str, message: str):
33
self.name = name
44
self.message = message
55
super().__init__(message)
6+
7+
8+
class DocumentNotFoundException(Exception):
9+
def __init__(self, name: str):
10+
self.name = name
11+
super().__init__(f"Document not found: {name}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "py-partiql-parser"
3-
version = "0.6.2"
3+
version = "0.6.3"
44
description = "Pure Python PartiQL Parser"
55
readme = "README.md"
66
keywords = ["pypartiql", "parser"]

0 commit comments

Comments
 (0)