Skip to content

Commit

Permalink
address pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav274 committed Oct 17, 2023
1 parent c5a66f6 commit 1ea26be
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions evadb/binder/statement_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from evadb.binder.statement_binder_context import StatementBinderContext
from evadb.catalog.catalog_type import ColumnType, TableType
from evadb.catalog.catalog_utils import get_metadata_properties, is_document_table
from evadb.catalog.sql_config import RESTRICTED_COL_NAMES
from evadb.configuration.constants import EvaDB_INSTALLATION_DIR
from evadb.expression.abstract_expression import AbstractExpression, ExpressionType
from evadb.expression.function_expression import FunctionExpression
Expand Down Expand Up @@ -201,6 +202,12 @@ def _bind_delete_statement(self, node: DeleteTableStatement):

@bind.register(CreateTableStatement)
def _bind_create_statement(self, node: CreateTableStatement):
# we don't allow certain keywords in the column_names
for col in node.column_list:
assert (
col.name.lower() not in RESTRICTED_COL_NAMES
), f"EvaDB does not allow to create a table with column name {col.name}"

if node.query is not None:
self.bind(node.query)

Expand Down
3 changes: 3 additions & 0 deletions evadb/catalog/sql_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"function_cost_catalog",
"function_metadata_catalog",
]
# Add all keywords that are restricted by EvaDB

RESTRICTED_COL_NAMES = [IDENTIFIER_COLUMN]


class SingletonMeta(type):
Expand Down
9 changes: 9 additions & 0 deletions test/integration_tests/long/test_create_table_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ def test_create_table_with_incorrect_info(self):
execute_query_fetch_all(self.evadb, create_table)
execute_query_fetch_all(self.evadb, "DROP TABLE SlackCSV;")

def test_create_table_with_restricted_keywords(self):
create_table = "CREATE TABLE hello (_row_id INTEGER, price TEXT);"
with self.assertRaises(AssertionError):
execute_query_fetch_all(self.evadb, create_table)

create_table = "CREATE TABLE hello2 (_ROW_id INTEGER, price TEXT);"
with self.assertRaises(AssertionError):
execute_query_fetch_all(self.evadb, create_table)


if __name__ == "__main__":
unittest.main()

0 comments on commit 1ea26be

Please sign in to comment.