@@ -185,22 +185,20 @@ def get_dict_rule_for_table(dictionary_rules: List[Dict], schema: str, table: st
185
185
return result
186
186
187
187
188
- async def get_dump_query (ctx , table_schema : str , table_name : str , table_rule ,
189
- files : Dict , excluded_objs : List , included_objs : List ):
188
+ async def get_dump_query (ctx , table_schema : str , table_name : str , table_rule , files : Dict ,
189
+ excluded_objs : List , included_objs : List , nulls_last : bool = False ):
190
190
191
191
table_name_full = f'"{ table_schema } "."{ table_name } "'
192
192
193
- found_white_list = table_rule is not None
194
-
195
193
# dictionary_exclude has the highest priority
196
- if ctx . prepared_dictionary_obj . get ( "dictionary_exclude" ) :
194
+ if "dictionary_exclude" in ctx . prepared_dictionary_obj :
197
195
exclude_rule = get_dict_rule_for_table (
198
196
dictionary_rules = ctx .prepared_dictionary_obj ["dictionary_exclude" ],
199
197
schema = table_schema ,
200
198
table = table_name ,
201
199
)
202
- found = exclude_rule is not None
203
- if found and not found_white_list :
200
+
201
+ if exclude_rule is not None and table_rule is None :
204
202
excluded_objs .append (
205
203
[
206
204
exclude_rule ,
@@ -218,7 +216,7 @@ async def get_dump_query(ctx, table_schema: str, table_name: str, table_rule,
218
216
219
217
files [f"{ hashed_name } .bin.gz" ] = {"schema" : table_schema , "table" : table_name }
220
218
221
- if not found_white_list :
219
+ if table_rule is None :
222
220
included_objs .append (
223
221
[table_rule , table_schema , table_name , "if not found_white_list" ]
224
222
)
@@ -286,6 +284,13 @@ def _check_field(_field_name: str):
286
284
or ctx .args .dbg_stage_3_validate_full ):
287
285
query += f" { ctx .validate_limit } "
288
286
287
+ if nulls_last :
288
+ ordering = ", " .join ([
289
+ field ["column_name" ] + ' NULLS LAST' for field in fields_list
290
+ if field ["is_nullable" ].lower () == "yes"
291
+ ])
292
+ query += f" ORDER BY { ordering } "
293
+
289
294
return query
290
295
291
296
0 commit comments