Skip to content

Commit

Permalink
Add backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
xzdandy committed Oct 7, 2023
1 parent c5948e0 commit 4ce16c2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions evadb/parser/lark_visitor/_create_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def dimension_data_type(self, tree):
elif str.upper(token) == "TEXT":
data_type = ColumnType.TEXT

if len(tree.children) > 1:
dimensions = self.visit(tree.children[1])

return data_type, array_type, dimensions

def array_data_type(self, tree):
Expand Down
47 changes: 47 additions & 0 deletions test/unit_tests/parser/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,53 @@ def test_create_table_statement(self):
self.assertIsInstance(evadb_statement_list[0], AbstractStatement)
self.assertEqual(evadb_statement_list[0], expected_stmt)

def test_create_table_with_dimension_statement(self):
# The test is for backwards compatibility
parser = Parser()

single_queries = []
single_queries.append(
"""CREATE TABLE IF NOT EXISTS Persons (
Frame_ID INTEGER UNIQUE,
Frame_Data TEXT(10),
Frame_Value FLOAT(1000, 201),
Frame_Array NDARRAY UINT8(5, 100, 2432, 4324, 100)
);"""
)

expected_cci = ColConstraintInfo()
expected_cci.nullable = True
unique_cci = ColConstraintInfo()
unique_cci.unique = True
unique_cci.nullable = False
expected_stmt = CreateTableStatement(
TableInfo("Persons"),
True,
[
ColumnDefinition("Frame_ID", ColumnType.INTEGER, None, (), unique_cci),
ColumnDefinition(
"Frame_Data", ColumnType.TEXT, None, (10,), expected_cci
),
ColumnDefinition(
"Frame_Value", ColumnType.FLOAT, None, (1000, 201), expected_cci
),
ColumnDefinition(
"Frame_Array",
ColumnType.NDARRAY,
NdArrayType.UINT8,
(5, 100, 2432, 4324, 100),
expected_cci,
),
],
)

for query in single_queries:
evadb_statement_list = parser.parse(query)
self.assertIsInstance(evadb_statement_list, list)
self.assertEqual(len(evadb_statement_list), 1)
self.assertIsInstance(evadb_statement_list[0], AbstractStatement)
self.assertEqual(evadb_statement_list[0], expected_stmt)

def test_create_table_statement_with_rare_datatypes(self):
parser = Parser()
query = """CREATE TABLE IF NOT EXISTS Dummy (
Expand Down

0 comments on commit 4ce16c2

Please sign in to comment.