Skip to content

Commit

Permalink
style: run formatting script
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav274 committed Aug 10, 2022
1 parent acb0d2c commit 867bd3d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 85 deletions.
2 changes: 1 addition & 1 deletion eva/binder/statement_binder_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def add_derived_table_alias(
Add a alias -> derived table column mapping
Arguments:
alias (str): name of alias
target_list: list of Tuplevalue Expression or FunctionExpression or str
target_list: list of Tuplevalue Expression or FunctionExpression or UdfIO
"""
self._check_duplicate_alias(alias)
col_list = []
Expand Down
3 changes: 0 additions & 3 deletions test/integration_tests/test_load_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,4 @@ def test_should_load_csv_in_table(self):
# assert the batches are equal
expected_batch = create_dummy_csv_batches()
expected_batch.modify_column_alias("myvideocsv")
from pandas.testing import assert_frame_equal

assert_frame_equal(expected_batch.frames, actual_batch.frames)
self.assertEqual(actual_batch, expected_batch)
1 change: 0 additions & 1 deletion test/integration_tests/test_udf_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def test_should_load_and_select_using_udf_video(self):
expected_batch.sort()

self.assertEqual(actual_batch, expected_batch)

nested_select_query = """SELECT id, data FROM
(SELECT id, data, DummyObjectDetector(data) FROM MyVideo
WHERE id >= 2
Expand Down
105 changes: 25 additions & 80 deletions test/parser/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
from eva.expression.function_expression import FunctionExpression
from eva.expression.tuple_value_expression import TupleValueExpression
from eva.parser.alias import Alias
from eva.parser.create_mat_view_statement import (
CreateMaterializedViewStatement,
)
from eva.parser.create_mat_view_statement import CreateMaterializedViewStatement
from eva.parser.create_statement import ColumnDefinition
from eva.parser.create_udf_statement import CreateUDFStatement
from eva.parser.drop_statement import DropTableStatement
Expand All @@ -35,12 +33,7 @@
from eva.parser.rename_statement import RenameTableStatement
from eva.parser.select_statement import SelectStatement
from eva.parser.statement import AbstractStatement, StatementType
from eva.parser.table_ref import (
JoinNode,
TableInfo,
TableRef,
TableValuedExpression,
)
from eva.parser.table_ref import JoinNode, TableInfo, TableRef, TableValuedExpression
from eva.parser.types import FileFormatType, JoinType, ParserOrderBySortType
from eva.parser.upload_statement import UploadStatement

Expand Down Expand Up @@ -85,9 +78,7 @@ def test_rename_statement(self):
def test_drop_table_statement(self):
parser = Parser()
drop_queries = "DROP TABLE student_info"
expected_stmt = DropTableStatement(
[TableRef(TableInfo("student_info"))], False
)
expected_stmt = DropTableStatement([TableRef(TableInfo("student_info"))], False)
eva_statement_list = parser.parse(drop_queries)
self.assertIsInstance(eva_statement_list, list)
self.assertEqual(len(eva_statement_list), 1)
Expand All @@ -103,9 +94,7 @@ def test_drop_udf_statement(self):
eva_statement_list = parser.parse(drop_udf_query)
self.assertIsInstance(eva_statement_list, list)
self.assertEqual(len(eva_statement_list), 1)
self.assertEqual(
eva_statement_list[0].stmt_type, StatementType.DROP_UDF
)
self.assertEqual(eva_statement_list[0].stmt_type, StatementType.DROP_UDF)
drop_udf_stmt = eva_statement_list[0]
self.assertEqual(drop_udf_stmt, expected_stmt)

Expand Down Expand Up @@ -175,12 +164,8 @@ def test_select_statement(self):
# target List
self.assertIsNotNone(select_stmt.target_list)
self.assertEqual(len(select_stmt.target_list), 2)
self.assertEqual(
select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(
select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE)
self.assertEqual(select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE)

# from_table
self.assertIsNotNone(select_stmt.from_table)
Expand Down Expand Up @@ -219,9 +204,7 @@ def test_select_statement_class(self):
select_stmt_new.target_list = select_stmt.target_list
select_stmt_new.from_table = select_stmt.from_table

self.assertEqual(
select_stmt_new.where_clause, select_stmt.where_clause
)
self.assertEqual(select_stmt_new.where_clause, select_stmt.where_clause)
self.assertEqual(select_stmt_new.target_list, select_stmt.target_list)
self.assertEqual(select_stmt_new.from_table, select_stmt.from_table)
self.assertEqual(str(select_stmt_new), str(select_stmt))
Expand All @@ -247,12 +230,8 @@ def test_select_statement_orderby_class(self):
# target List
self.assertIsNotNone(select_stmt.target_list)
self.assertEqual(len(select_stmt.target_list), 2)
self.assertEqual(
select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(
select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE)
self.assertEqual(select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE)

# from_table
self.assertIsNotNone(select_stmt.from_table)
Expand All @@ -266,13 +245,9 @@ def test_select_statement_orderby_class(self):
self.assertIsNotNone(select_stmt.orderby_list)
self.assertEqual(len(select_stmt.orderby_list), 2)
self.assertEqual(select_stmt.orderby_list[0][0].col_name, "CLASS")
self.assertEqual(
select_stmt.orderby_list[0][1], ParserOrderBySortType.ASC
)
self.assertEqual(select_stmt.orderby_list[0][1], ParserOrderBySortType.ASC)
self.assertEqual(select_stmt.orderby_list[1][0].col_name, "REDNESS")
self.assertEqual(
select_stmt.orderby_list[1][1], ParserOrderBySortType.DESC
)
self.assertEqual(select_stmt.orderby_list[1][1], ParserOrderBySortType.DESC)

def test_select_statement_limit_class(self):
"""Testing limit clause in select statement
Expand All @@ -294,12 +269,8 @@ def test_select_statement_limit_class(self):
# target List
self.assertIsNotNone(select_stmt.target_list)
self.assertEqual(len(select_stmt.target_list), 2)
self.assertEqual(
select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(
select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE)
self.assertEqual(select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE)

# from_table
self.assertIsNotNone(select_stmt.from_table)
Expand All @@ -313,13 +284,9 @@ def test_select_statement_limit_class(self):
self.assertIsNotNone(select_stmt.orderby_list)
self.assertEqual(len(select_stmt.orderby_list), 2)
self.assertEqual(select_stmt.orderby_list[0][0].col_name, "CLASS")
self.assertEqual(
select_stmt.orderby_list[0][1], ParserOrderBySortType.ASC
)
self.assertEqual(select_stmt.orderby_list[0][1], ParserOrderBySortType.ASC)
self.assertEqual(select_stmt.orderby_list[1][0].col_name, "REDNESS")
self.assertEqual(
select_stmt.orderby_list[1][1], ParserOrderBySortType.DESC
)
self.assertEqual(select_stmt.orderby_list[1][1], ParserOrderBySortType.DESC)

# limit_count
self.assertIsNotNone(select_stmt.limit_count)
Expand All @@ -342,22 +309,16 @@ def test_select_statement_sample_class(self):
# target List
self.assertIsNotNone(select_stmt.target_list)
self.assertEqual(len(select_stmt.target_list), 2)
self.assertEqual(
select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(
select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE
)
self.assertEqual(select_stmt.target_list[0].etype, ExpressionType.TUPLE_VALUE)
self.assertEqual(select_stmt.target_list[1].etype, ExpressionType.TUPLE_VALUE)

# from_table
self.assertIsNotNone(select_stmt.from_table)
self.assertIsInstance(select_stmt.from_table, TableRef)
self.assertEqual(select_stmt.from_table.table.table_name, "TAIPAI")

# sample_freq
self.assertEqual(
select_stmt.from_table.sample_freq, ConstantValueExpression(5)
)
self.assertEqual(select_stmt.from_table.sample_freq, ConstantValueExpression(5))

def test_table_ref(self):
"""Testing table info in TableRef
Expand All @@ -368,12 +329,8 @@ def test_table_ref(self):
select_stmt_new = SelectStatement()
select_stmt_new.from_table = table_ref_obj
self.assertEqual(select_stmt_new.from_table.table.table_name, "TAIPAI")
self.assertEqual(
select_stmt_new.from_table.table.schema_name, "Schema"
)
self.assertEqual(
select_stmt_new.from_table.table.database_name, "Database"
)
self.assertEqual(select_stmt_new.from_table.table.schema_name, "Schema")
self.assertEqual(select_stmt_new.from_table.table.database_name, "Database")

def test_insert_statement(self):
parser = Parser()
Expand Down Expand Up @@ -420,9 +377,7 @@ def test_create_udf_statement(self):
)
],
[
ColumnDefinition(
"Labels", ColumnType.NDARRAY, NdArrayType.STR, [10]
),
ColumnDefinition("Labels", ColumnType.NDARRAY, NdArrayType.STR, [10]),
ColumnDefinition(
"Bbox", ColumnType.NDARRAY, NdArrayType.UINT8, [10, 4]
),
Expand All @@ -433,9 +388,7 @@ def test_create_udf_statement(self):
eva_statement_list = parser.parse(create_udf_query)
self.assertIsInstance(eva_statement_list, list)
self.assertEqual(len(eva_statement_list), 1)
self.assertEqual(
eva_statement_list[0].stmt_type, StatementType.CREATE_UDF
)
self.assertEqual(eva_statement_list[0].stmt_type, StatementType.CREATE_UDF)

create_udf_stmt = eva_statement_list[0]

Expand All @@ -457,9 +410,7 @@ def test_load_video_data_statement(self):
eva_statement_list = parser.parse(load_data_query)
self.assertIsInstance(eva_statement_list, list)
self.assertEqual(len(eva_statement_list), 1)
self.assertEqual(
eva_statement_list[0].stmt_type, StatementType.LOAD_DATA
)
self.assertEqual(eva_statement_list[0].stmt_type, StatementType.LOAD_DATA)

load_data_stmt = eva_statement_list[0]
self.assertEqual(load_data_stmt, expected_stmt)
Expand All @@ -486,9 +437,7 @@ def test_load_csv_data_statement(self):
eva_statement_list = parser.parse(load_data_query)
self.assertIsInstance(eva_statement_list, list)
self.assertEqual(len(eva_statement_list), 1)
self.assertEqual(
eva_statement_list[0].stmt_type, StatementType.LOAD_DATA
)
self.assertEqual(eva_statement_list[0].stmt_type, StatementType.LOAD_DATA)

load_data_stmt = eva_statement_list[0]
self.assertEqual(load_data_stmt, expected_stmt)
Expand Down Expand Up @@ -556,11 +505,7 @@ def test_should_return_false_for_unequal_expression(self):
[3, 256, 256],
)
],
[
ColumnDefinition(
"labels", ColumnType.NDARRAY, NdArrayType.STR, [10]
)
],
[ColumnDefinition("labels", ColumnType.NDARRAY, NdArrayType.STR, [10])],
Path("data/fastrcnn.py"),
"Classification",
)
Expand Down

0 comments on commit 867bd3d

Please sign in to comment.