diff --git a/evadb/parser/evadb.lark b/evadb/parser/evadb.lark index a3b76d29c8..d14c853cf6 100644 --- a/evadb/parser/evadb.lark +++ b/evadb/parser/evadb.lark @@ -8,7 +8,7 @@ ddl_statement: create_database | create_table | create_index | create_function | drop_database | drop_table | drop_function | drop_index | rename_table dml_statement: select_statement | insert_statement | update_statement - | delete_statement | load_statement + | delete_statement | load_statement | set_statement utility_statement: describe_statement | show_statement | help_statement | explain_statement @@ -80,7 +80,7 @@ drop_table: DROP TABLE if_exists? uid drop_function: DROP FUNCTION if_exists? uid // SET statements (configuration) -set_statement: SET uid EQUAL_SYMBOL (string_literal | decimal_literal | boolean_literal) +set_statement: SET uid EQUAL_SYMBOL (string_literal | decimal_literal | boolean_literal | real_literal) // Data Manipulation Language diff --git a/evadb/parser/set_statement.py b/evadb/parser/set_statement.py new file mode 100644 index 0000000000..2120abfee4 --- /dev/null +++ b/evadb/parser/set_statement.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# Copyright 2018-2023 EvaDB +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +from __future__ import annotations +from typing import Union + +from evadb.parser.statement import AbstractStatement +from evadb.parser.types import StatementType + + +class SetStatement(AbstractStatement): + def __init__(self, config_name: str, config_value: Union[int, str, float]): + super().__init__(StatementType.SET) + self.config_name = config_name + self.config_value = config_value + + @property + def config_name(self): + return self.config_name + + @property + def config_value(self): + return self.config_value + + def __str__(self): + return f"SET {str(self.config_name)} = {str(self.config_value)}" + + def __eq__(self, other: object) -> bool: + if not isinstance(other, SetStatement): + return False + return ( + self.config_name == other.config_name + and self.config_value == other.config_value + ) + + def __hash__(self) -> int: + return hash((super().__hash__(), self.config_name, self.config_value)) diff --git a/evadb/parser/types.py b/evadb/parser/types.py index a57c938db8..14011f1745 100644 --- a/evadb/parser/types.py +++ b/evadb/parser/types.py @@ -41,6 +41,7 @@ class StatementType(EvaDBEnum): CREATE_INDEX # noqa: F821 CREATE_DATABASE # noqa: F821 USE # noqa: F821 + SET # noqa: F821 # add other types