Skip to content

Commit

Permalink
supporting spaces in column names for csv files
Browse files Browse the repository at this point in the history
  • Loading branch information
fikremen committed Nov 24, 2023
1 parent 69b39b8 commit 4017bef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions evadb/parser/lark_visitor/_common_clauses_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def full_id(self, tree):
return (self.visit(tree.children[0]), self.visit(tree.children[1]))

def uid(self, tree):
if (hasattr(tree.children[0],"type") and tree.children[0].type == "REVERSE_QUOTE_ID"):
# tree.children[0].value = tree.children[0].value.replace("`","")
temp = str(tree.children[0]).replace("`","")
tree.children[0].type = "simple_id"
return temp
return self.visit(tree.children[0])

def full_column_name(self, tree):
Expand Down
4 changes: 2 additions & 2 deletions test/integration_tests/short/test_load_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_should_load_csv_in_table(self):
CREATE TABLE IF NOT EXISTS MyVideoCSV (
id INTEGER UNIQUE,
frame_id INTEGER,
`frame_id` INTEGER,
video_id INTEGER,
dataset_name TEXT(30),
label TEXT(30),
Expand All @@ -100,7 +100,7 @@ def test_should_load_csv_in_table(self):
execute_query_fetch_all(self.evadb, load_query)

# execute a select query
select_query = """SELECT id, frame_id, video_id,
select_query = """SELECT id, `frame_id`, video_id,
dataset_name, label, bbox,
object_id
FROM MyVideoCSV;"""
Expand Down
2 changes: 1 addition & 1 deletion test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def create_sample_csv(num_frames=NUM_FRAMES):
random_coords = 200 + 300 * np.random.random(4)
sample_meta[index] = {
"id": index,
"frame_id": frame_id,
"frame id": frame_id,
"video_id": video_id,
"dataset_name": "test_dataset",
"label": sample_labels[np.random.choice(len(sample_labels))],
Expand Down

0 comments on commit 4017bef

Please sign in to comment.