Skip to content

Commit

Permalink
Added parser for set_statement
Browse files Browse the repository at this point in the history
	modified:   evadb/parser/evadb.lark
Added class for set_statement
	new file:   evadb/parser/set_statement.py
Added SET to statement_types
	modified:   evadb/parser/types.py
  • Loading branch information
hershd23 committed Sep 21, 2023
1 parent 0703cc4 commit d1a092b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions evadb/parser/evadb.lark
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
48 changes: 48 additions & 0 deletions evadb/parser/set_statement.py
Original file line number Diff line number Diff line change
@@ -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))
1 change: 1 addition & 0 deletions evadb/parser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class StatementType(EvaDBEnum):
CREATE_INDEX # noqa: F821
CREATE_DATABASE # noqa: F821
USE # noqa: F821
SET # noqa: F821
# add other types


Expand Down

0 comments on commit d1a092b

Please sign in to comment.