Skip to content

Commit eb881d6

Browse files
author
Tobias Kopp
committed
[Benchmark] Fix type hints considering dict.get()
1 parent be20c48 commit eb881d6

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

benchmark/Benchmark.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ def perform_experiment(
296296
if name in config_name:
297297
if 'args' in conf:
298298
config = conf['args']
299-
else:
300-
config = conf
299+
elif 'variables' in conf:
300+
config = ' '.join([f'{key}={value}' for key, value in conf['variables'].items()])
301+
break
301302

302303
measurements_list: list[list[str | int | float]] = list()
303304
for case, times in config_result.items():
@@ -420,10 +421,9 @@ def run_benchmarks(args: argparse.Namespace) -> None:
420421
if info.experiment_data:
421422
table_access_error: bool = False
422423
for table_name, table in info.experiment_data.items():
423-
p: str = table.get('file') # Path to file
424-
if not p:
424+
if 'file' not in table:
425425
continue # Skip counting files when table does not have a file with data
426-
p = os.path.join(p)
426+
p: str = os.path.join(table['file']) # Path to file
427427
if not os.path.isfile(p):
428428
tqdm.write(f'Table file \'{p}\' not found. Skipping benchmark.\n', file=sys.stderr)
429429
table_access_error = True

benchmark/database_connectors/duckdb.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,22 +188,18 @@ def generate_create_table_stmts(self, data: dict[str, dict[str, Any]], with_scal
188188
for table_name, table in data.items():
189189
columns: str = self.parse_attributes(table['attributes'])
190190

191-
delimiter: str = table.get('delimiter')
192-
header: int = table.get('header')
193-
format: str = table.get('format')
194-
195191
if with_scale_factors:
196192
table_name += "_tmp"
197193

198194
create: str = f'CREATE TABLE "{table_name}" {columns};'
199195
copy: str = f'COPY "{table_name}" FROM \'{table["file"]}\' ( '
200-
if delimiter:
201-
delim = delimiter.replace("'", "")
196+
if 'delimiter' in table:
197+
delim = table['delimiter'].replace("'", "")
202198
copy += f" DELIMITER \'{delim}\',"
203-
if format:
204-
copy += f" FORMAT {format.upper()},"
205-
if header:
206-
copy += f" HEADER," if (header==1) else ""
199+
if 'format' in table:
200+
copy += f" FORMAT {table['format'].upper()},"
201+
if 'header' in table:
202+
copy += f" HEADER," if table['header'] == 1 else ""
207203

208204
copy = copy[:-1] + " );"
209205

benchmark/database_connectors/mutable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ def get_setup_statements(suite: str, path_to_data: str, data: dict[str, dict[str
356356
statements.append(create)
357357

358358
# Create an IMPORT statement for current table
359-
lines: int = table.get('lines_in_file')
360-
if not lines:
359+
if 'lines_in_file' not in table:
361360
continue # Only import data when lines are given
361+
lines: int = table['lines_in_file']
362362

363363
path: str = table.get('file', os.path.join(path_to_data, f'{table_name}.csv'))
364364
sf: float | int

benchmark/database_connectors/postgresql.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,20 @@ def create_tables(self, cursor: psycopg2.extensions.cursor, data: dict[str, dict
233233
for table_name, table in data.items():
234234
columns: str = self.parse_attributes(table['attributes'])
235235

236-
delimiter: str = table.get('delimiter')
237-
header: int = table.get('header')
238-
format: str = table.get('format')
239-
240236
# Use an additional table with the *complete* data set to quickly recreate the table with the benchmark
241237
# data, in case of varying scale factor.
242238
complete_table_name: str = table_name + COMPLETE_TABLE_SUFFIX if with_scale_factors else table_name
243239
quoted_table_name: str = f'"{complete_table_name}"'
244240

245241
create: str = f"CREATE UNLOGGED TABLE {quoted_table_name} {columns};"
246242
copy: str = f"COPY {quoted_table_name} FROM STDIN"
247-
if delimiter:
248-
delim: str = delimiter.replace("'", "")
243+
if 'delimiter' in table:
244+
delim: str = table['delimiter'].replace("'", "")
249245
copy += f" WITH DELIMITER \'{delim}\'"
250-
if format:
251-
copy += f" {format.upper()}"
252-
if header:
253-
copy += ' HEADER' if header == 1 else ''
246+
if 'format' in table:
247+
copy += f" {table['format'].upper()}"
248+
if 'header' in table:
249+
copy += ' HEADER' if table['header'] == 1 else ''
254250

255251
copy += ";"
256252

0 commit comments

Comments
 (0)