|
23 | 23 | set_target_db_params, |
24 | 24 | write_to_app_db, |
25 | 25 | ) |
26 | | -from testgen.common.database.database_service import empty_cache |
| 26 | +from testgen.common.database.database_service import empty_cache, get_flavor_service |
27 | 27 | from testgen.common.mixpanel_service import MixpanelService |
28 | 28 | from testgen.common.models import with_database_session |
29 | 29 | from testgen.common.models.connection import Connection |
@@ -279,12 +279,15 @@ def run_profiling_queries(table_group_id: str, username: str | None = None, spin |
279 | 279 | column_count = len(lstResult) |
280 | 280 |
|
281 | 281 | if lstResult: |
| 282 | + flavor_service = get_flavor_service(connection.sql_flavor) |
| 283 | + quote = flavor_service.quote_character |
| 284 | + |
282 | 285 | # Get distinct tables |
283 | 286 | distinct_tables = set() |
284 | 287 | for item in lstResult: |
285 | 288 | schema_name = item["table_schema"] |
286 | 289 | table_name = item["table_name"] |
287 | | - distinct_tables.add(f"{schema_name}.{table_name}") |
| 290 | + distinct_tables.add(f"{quote}{schema_name}{quote}.{quote}{table_name}{quote}") |
288 | 291 |
|
289 | 292 | # Convert the set to a list |
290 | 293 | distinct_tables_list = list(distinct_tables) |
@@ -326,16 +329,11 @@ def run_profiling_queries(table_group_id: str, username: str | None = None, spin |
326 | 329 | clsProfiling.parm_do_sample = "N" |
327 | 330 |
|
328 | 331 | if clsProfiling.profile_use_sampling == "Y": |
329 | | - if dctSampleTables[clsProfiling.data_schema + "." + clsProfiling.data_table][0] > -1: |
330 | | - clsProfiling.parm_sample_size = dctSampleTables[ |
331 | | - clsProfiling.data_schema + "." + clsProfiling.data_table |
332 | | - ][0] |
333 | | - clsProfiling.sample_ratio = dctSampleTables[ |
334 | | - clsProfiling.data_schema + "." + clsProfiling.data_table |
335 | | - ][1] |
336 | | - clsProfiling.sample_percent_calc = dctSampleTables[ |
337 | | - clsProfiling.data_schema + "." + clsProfiling.data_table |
338 | | - ][2] |
| 332 | + table_identifier = f"{quote}{clsProfiling.data_schema}{quote}.{quote}{clsProfiling.data_table}{quote}" |
| 333 | + if dctSampleTables[table_identifier][0] > -1: |
| 334 | + clsProfiling.parm_sample_size = dctSampleTables[table_identifier][0] |
| 335 | + clsProfiling.sample_ratio = dctSampleTables[table_identifier][1] |
| 336 | + clsProfiling.sample_percent_calc = dctSampleTables[table_identifier][2] |
339 | 337 | clsProfiling.parm_do_sample = clsProfiling.profile_use_sampling |
340 | 338 | else: |
341 | 339 | clsProfiling.parm_sample_size = 0 |
|
0 commit comments