Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
yulaicui committed Jul 10, 2023
1 parent 0a9e475 commit fec3e15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 3 additions & 1 deletion apps/youtube_qa/youtube_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ def generate_online_video_transcript(cursor: evadb.EvaDBCursor) -> str:

# extract speech texts from videos
cursor.drop_table("youtube_video_text", if_exists=True).execute()
speech_recognizer_rel = cursor.table("youtube_video").select("SpeechRecognizer(audio)")
speech_recognizer_rel = cursor.table("youtube_video").select(
"SpeechRecognizer(audio)"
)
cursor.create_table("youtube_video_text", query=speech_recognizer_rel).execute()
print("✅ Video analysis completed.")

Expand Down
11 changes: 9 additions & 2 deletions evadb/interfaces/relational/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,12 @@ def create_function(
return EvaDBQuery(self._evadb, stmt)

def create_table(
self, table_name: str, if_not_exists: bool = True, columns: str = None, query: EvaDBQuery = None, **kwargs
self,
table_name: str,
if_not_exists: bool = True,
columns: str = None,
query: EvaDBQuery = None,
**kwargs,
) -> "EvaDBQuery":
"""
Create a udf in the database.
Expand Down Expand Up @@ -424,7 +429,9 @@ def create_table(
stmt = parse_create_table(table_name, if_not_exists, columns, **kwargs)
else:
select_query = query.sql_query()
stmt = parse_create_table_from_select(table_name, if_not_exists, select_query, **kwargs)
stmt = parse_create_table_from_select(
table_name, if_not_exists, select_query, **kwargs
)
return EvaDBQuery(self._evadb, stmt)

def query(self, sql_query: str) -> EvaDBQuery:
Expand Down
7 changes: 5 additions & 2 deletions evadb/parser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,18 @@ def parse_create_table(table_name: str, if_not_exists: bool, columns: str, **kwa
assert isinstance(stmt, CreateTableStatement), "Expected a create table statement"
return stmt

def parse_create_table_from_select(table_name: str, if_not_exists: bool, query: str, **kwargs):

def parse_create_table_from_select(
table_name: str, if_not_exists: bool, query: str, **kwargs
):
mock_query = (
f"CREATE TABLE IF NOT EXISTS {table_name} AS {query};"
if if_not_exists
else f"CREATE TABLE AS {query};"
)
stmt = Parser().parse(mock_query)[0]
assert isinstance(stmt, CreateTableStatement), "Expected a create table statement"
return stmt
return stmt


def parse_show(show_type: str, **kwargs):
Expand Down
4 changes: 3 additions & 1 deletion test/interfaces/relational/test_relational_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@ def test_create_table_from_select_relational(self):
create_dummy_object_detector_udf.execute()

# Check create table from select relation
select_query_sql_rel = cursor.table("dummy_video").select("id, DummyObjectDetector(data)")
select_query_sql_rel = cursor.table("dummy_video").select(
"id, DummyObjectDetector(data)"
)
cursor.drop_table("dummy_objects", if_exists=True)
cursor.create_table("dummy_objects", query=select_query_sql_rel).execute()

Expand Down

0 comments on commit fec3e15

Please sign in to comment.